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

Allow specify expected response type as JSON and pass schema #27

Open
taurit opened this issue Sep 10, 2024 · 0 comments
Open

Allow specify expected response type as JSON and pass schema #27

taurit opened this issue Sep 10, 2024 · 0 comments

Comments

@taurit
Copy link

taurit commented Sep 10, 2024

Is your feature request related to a problem? Please describe.

The most recent Gemini 1.5 API allows us to specify the exact JSON schema we expect for the response.

The SDK's current version doesn't allow users to request a response in JSON or pass the schema to the API.

Describe the solution you'd like

As a developer using the SDK, I would like to be able to specify the response type as JSON and provide the JSON schema:

var response = await geminiClient.TextPrompt(prompt, new GenerationConfig()
{
    MaxOutputTokens = 300,

    // Feature suggestion: add such property and pass the value to API as `response_mime_type`
    ResponseMimeType = "application/json",

    // Feature suggestion: add such property and pass the value to API as `response_schema`
    ResponseSchema = { ... // SDK could accept `JObject` or a string containing JSON}
});

Describe alternatives you've considered

Currently, I think the only alternative for this use case is to:

  • not use the SDK,
  • prepare a plain HTTP request using HttpClient or something similar.

Additional context

Google's documentation for ResponseMimeType and ResponseSchema doesn't contain examples of HTTP requests (only for SDKs in Python, Node, etc.).

I have experimented and provided examples of working requests to enable Gemini's JSON Mode on my blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant