-
Notifications
You must be signed in to change notification settings - Fork 640
Closed
Labels
Description
Describe the bug
The use of integer fields in tool inputs causes a silent error that causes the input schema to not be submitted properly to the googleai API. There are two issues that go into this...
- There is a typo that prevents the error from being propagated.
- The schema conversion looks for the wrong value ("int" instead of "integer).
To Reproduce
package main
import (
"context"
"fmt"
"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/googleai"
)
func main() {
ctx := context.Background()
g, err := genkit.New(&genkit.Options{})
if err != nil {
panic(err)
}
if err := googleai.Init(ctx, g, nil); err != nil {
panic(err)
}
model := googleai.Model(g, "gemini-2.0-flash")
tool := genkit.DefineTool(g, "submitScore", "submit a score",
func(ctx *ai.ToolContext, input struct{ Score int }) (any, error) {
fmt.Printf("Score: %d\n", input.Score)
return nil, nil
},
)
_, err = genkit.Generate(ctx, g,
ai.WithModel(model),
ai.WithTools(tool),
ai.WithTextPrompt("Submit a score of 10"),
ai.WithToolChoice(ai.ToolChoiceRequired),
)
if err != nil {
panic(err)
}
}Expected behavior
Expected Score: 10 to be printed.
Actual behavior
panic: tool "submitScore" failed: error calling tool submitScore: data did not match expected schema:
- (root): Score is required
Go version*
- 1.23.5
Additional context
PR raised: #1911
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done