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: support json schema for gemini models #10835

Merged
merged 3 commits into from
Nov 19, 2024
Merged

Conversation

hjlarry
Copy link
Contributor

@hjlarry hjlarry commented Nov 19, 2024

Summary

Tip

Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Change List

  1. add json_schema for gemini models, offical doc
  2. remove the response_format, which is conflict with json_schema
  3. use max_output_tokens instead of max_tokens_to_sample
  4. remove GEMINI_BLOCK_MODE_PROMPT and logger, seems not used in any place
  5. deprecated gemini-1.0-pro and gemini-1.0-pro-vision

Screenshots

3f8fecb87df16d1f155bb225588da58

test schema:

{  
        "type": "object",  
        "properties": {  
            "location": {  
                "type": "string",  
                "description": "The location to get the weather for"  
            },  
            "unit": {  
                "type": "string",  
                "description": "The unit to return the temperature in",  
                "enum": ["F", "C"]  
            }  
        },  
        "required": ["location", "unit"]  
}

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. ⚙️ feat:model-runtime labels Nov 19, 2024
@hjlarry hjlarry marked this pull request as draft November 19, 2024 03:10
@hjlarry hjlarry marked this pull request as ready for review November 19, 2024 06:30
@dosubot dosubot bot added the 📚 documentation Improvements or additions to documentation label Nov 19, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 19, 2024
@crazywoola crazywoola merged commit bc1013d into langgenius:main Nov 19, 2024
6 checks passed
@wonderlabsio
Copy link

Could you help check if possible to support gemini backed by Google Cloud Vertex? currently seems the json schema only enabled for google AI studio models

@hjlarry
Copy link
Contributor Author

hjlarry commented Dec 12, 2024

Could you help check if possible to support gemini backed by Google Cloud Vertex? currently seems the json schema only enabled for google AI studio models

the google publish a new API yesterday, which support both Vertex AI and Google AI : https://googleapis.github.io/python-genai/index.html
maybe we can working on this later to support the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Improvements or additions to documentation ⚙️ feat:model-runtime lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants