File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,6 +257,10 @@ func TestLive(t *testing.T) {
257257 t .Fatal (err )
258258 }
259259 part := res .Candidates [0 ].Content .Parts [0 ]
260+ funcalls := res .Candidates [0 ].FunctionCalls ()
261+ if len (funcalls ) != 1 {
262+ t .Fatalf ("got %d FunctionCalls, want 1" , len (funcalls ))
263+ }
260264 funcall , ok := part .(FunctionCall )
261265 if ! ok {
262266 t .Fatalf ("want FunctionCall, got %T" , part )
Original file line number Diff line number Diff line change @@ -134,3 +134,17 @@ func (c *GenerationConfig) SetTopP(x float32) { c.TopP = &x }
134134
135135// SetTopK sets the TopK field.
136136func (c * GenerationConfig ) SetTopK (x int32 ) { c .TopK = & x }
137+
138+ // FunctionCalls return all the FunctionCall parts in the candidate.
139+ func (c * Candidate ) FunctionCalls () []FunctionCall {
140+ if c .Content == nil {
141+ return nil
142+ }
143+ var fcs []FunctionCall
144+ for _ , p := range c .Content .Parts {
145+ if fc , ok := p .(FunctionCall ); ok {
146+ fcs = append (fcs , fc )
147+ }
148+ }
149+ return fcs
150+ }
You can’t perform that action at this time.
0 commit comments