Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent API: Function calling #279

Open
robfig opened this issue Feb 11, 2025 · 2 comments · May be fixed by #283
Open

Agent API: Function calling #279

robfig opened this issue Feb 11, 2025 · 2 comments · May be fixed by #283
Labels
help wanted Extra attention is needed

Comments

@robfig
Copy link

robfig commented Feb 11, 2025

Based on the latest (v1.8.0) godoc, it looks like function calling is not implemented.

type FunctionCallRequestResponse struct {
	Type           string            `json:"type,omitempty"`
	FunctionName   string            `json:"function_name,omitempty"`
	FunctionCallID string            `json:"function_call_id,omitempty"`
	Input          map[string]string `json:"input,omitempty"` // TODO: this is still undefined
}

ref: https://pkg.go.dev/github.com/deepgram/[email protected]/pkg/api/agent/v1/websocket/interfaces#FunctionCallRequestResponse

A map[string]string type is not appropriate for some inputs, like this example in your docs:

{
  "type": "FunctionCallRequest",
  "function_name": "do_math",
  "function_call_id": "7433439b-c4b6-4369-8ce8-4124f6a98a1d",
  "input": { "numbers": ["2", "2"], "operation": "add" }
}

https://developers.deepgram.com/docs/voice-agents-function-calling#server-messages-sent-by-deepgram

My use case requires function calling. Is there a way for me to work around this limitation? I'm using agent.NewWSUsingChanWithCancel, which seems to be the main entry point. It looks like I could use common.NewWS instead if I implement a few interfaces.

Or, if you're open to a PR, I'd be happy to submit one. I would suggest using json.RawMessage for Input and Output. Then the user can handle marshaling however they need. That would be better for efficiency too -- I'm usually just passing them around and don't need to inspect them, so having unnecessary round trip marshaling to a map[string]any would not be desirable.

@jpvajda
Copy link
Contributor

jpvajda commented Feb 13, 2025

@robfig Yeah, we are definitely open to PRs, if you want to make a suggestion here, we can check it out as soon as it's up. You can tag me as a reviewer.

@jpvajda jpvajda added the help wanted Extra attention is needed label Feb 13, 2025
@robfig robfig linked a pull request Feb 18, 2025 that will close this issue
8 tasks
@robfig
Copy link
Author

robfig commented Feb 18, 2025

Here it is: #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants