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

feat(vertexai): add Candidate.FunctionCalls accessor #10149

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vertexai/genai/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ func TestLive(t *testing.T) {
t.Fatal(err)
}
part := res.Candidates[0].Content.Parts[0]
funcalls := res.Candidates[0].FunctionCalls()
if len(funcalls) != 1 {
t.Fatalf("got %d FunctionCalls, want 1", len(funcalls))
}
funcall, ok := part.(FunctionCall)
if !ok {
t.Fatalf("want FunctionCall, got %T", part)
Expand Down
14 changes: 14 additions & 0 deletions vertexai/genai/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,17 @@ func (c *GenerationConfig) SetTopP(x float32) { c.TopP = &x }

// SetTopK sets the TopK field.
func (c *GenerationConfig) SetTopK(x int32) { c.TopK = &x }

// FunctionCalls return all the FunctionCall parts in the candidate.
func (c *Candidate) FunctionCalls() []FunctionCall {
if c.Content == nil {
return nil
}
var fcs []FunctionCall
for _, p := range c.Content.Parts {
if fc, ok := p.(FunctionCall); ok {
fcs = append(fcs, fc)
}
}
return fcs
}
Loading