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

Provide a way to input raw JSON schema #220

Open
areknoster opened this issue Oct 17, 2024 · 0 comments
Open

Provide a way to input raw JSON schema #220

areknoster opened this issue Oct 17, 2024 · 0 comments
Assignees
Labels
component:documentation Improvements or additions to documentation status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request or enhancement

Comments

@areknoster
Copy link

areknoster commented Oct 17, 2024

Description of the feature request:

Provide a way to input JSON schema that's encoded in a raw form - so instead of having to

model := client.GenerativeModel("gemini-1.5-pro-002")
model.ResponseSchema = &genai.Schema{
    Type:        genai.TypeString,
}

I'd like to be able to

model := client.GenerativeModel("gemini-1.5-pro-002")
schema, err := genai.ParseRawSchema(`{"type": "string"}`)
if err != nil {
    return fmt.Errorf("incompatible or incorrect JSON schema: %w", err)
}
model.ResponseSchema = schema

I can think of following ways to solve this, but I think this would be the easiest one.

What problem are you trying to solve with this feature?

There are following usecases in which it's useful to have the response schema as raw JSON:

  1. It's a part of OpenAPI definition
  2. It leverages schema registry (e.g. kafka schema registry)
  3. It is used in other services supporting JSON schema - one major example can be GCP's own Data Stores
  4. One wants to experiment with given schema in the chat UI. In that case, thay can paste the schema in the chat settings. Currently this would involve manually translating in-code schema definition to JSON schema defintion.
  5. One wants to generate their types definitions based on schema using one of existing JSON Schema -> go types generators.
  6. One wants to additionally validate response against schema using existing tooling

Any other information you'd like to share?

No response

@areknoster areknoster added the type:feature request New feature request or enhancement label Oct 17, 2024
@gmKeshari gmKeshari added component:documentation Improvements or additions to documentation status:triaged Issue/PR triaged to the corresponding sub-team labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:documentation Improvements or additions to documentation status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants