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(go/plugins/googlegenai): add constrained generation #2467

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

hugoaguirre
Copy link
Contributor

@hugoaguirre hugoaguirre commented Mar 25, 2025

Checklist (if applicable):

@github-actions github-actions bot added the go label Mar 25, 2025
@hugoaguirre hugoaguirre changed the title feat(go/plugins): add constrained generation to gemini models feat(go/plugins/googlegenai): add constrained generation Mar 25, 2025
@hugoaguirre hugoaguirre requested a review from apascal07 March 26, 2025 02:37
@hugoaguirre hugoaguirre marked this pull request as ready for review March 26, 2025 02:37
@hugoaguirre hugoaguirre requested a review from apascal07 March 26, 2025 21:33
@@ -172,6 +174,8 @@ func TestValidMessage(t *testing.T) {
outputSchema := &ModelOutputConfig{
Format: string(OutputFormatJSON),
}
// FIX: validMessage compares response against a given schema, but
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since validMessage checks if the response message matches the given schema (but no schema is provided), would it make sense to rework this and the next two test cases to not expect an error?

@@ -531,7 +582,7 @@ func validResponse(ctx context.Context, resp *ModelResponse) (*Message, error) {
// validMessage will validate the message against the expected schema.
// It will return an error if it does not match, otherwise it will return a message with JSON content and type.
func validMessage(m *Message, output *ModelOutputConfig) (*Message, error) {
if output != nil && output.Format == string(OutputFormatJSON) {
if output != nil && output.Format == string(OutputFormatJSON) && output.Constrained {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to check if this condition makes sense at this place. From what I understand, we don't require to validate the response message if no output schema is provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants