-
Notifications
You must be signed in to change notification settings - Fork 171
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(model-providers): 16 Add Gemini Completion and Embedding Models #56
feat(model-providers): 16 Add Gemini Completion and Embedding Models #56
Conversation
…dd embeddings example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall approved, but there's a consequence I wrote about related to parsing the additional_parameters
into an explicit requests Model that is significant to think about. You might want to collect additional keys into it's own field and then merge that onto the reuqest after the fact (might be good to do this for the other providers in a later PR).
for (key, value) in obj.iter().filter(|(_, v)| !v.is_null()) { | ||
match key.as_str() { | ||
"temperature" => { | ||
if !value.is_null() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you already check whether value
is is null at line 545?
} | ||
} | ||
|
||
impl TryFrom<serde_json::Value> for GenerationConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may not need this TryFrom
implementation. Instead of doing GenerationConfig::try_from(completion_request.additional_params.unwrap_or_default())?;
, you can do serde_json::from_value::<GenerationConfig>(completion_request.additional_params.unwrap_or_default())?
. Since GenerationConfig
has Option for each field, if the additional params don't contain the generation_config field, it won't fail.
This won't work though if field X of completion_request.additional_params
is a string but field X of GenerationConfig expects a float for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateobelanger is there a reason why you didn't change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good first draft but couple things to change (especially the bug which makes GenerationConfig
required)
…-embedding-models
…6-add-gemini-completion-embedding-models
0e33fd8
to
3fb10d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug that cases requests to fail if additional_params
is not set still exists!
@garance-buricatu can you make sure your comments were addressed and approve? Would like to merge this before eod, thanks! |
🎯 Description & Goal
This pull request adds support for the Google Gemini LLM provider.
EmbeddingModel
andCompletionModel
traits for Google Gemini APIDOCS Updates:
README.md
: Added Google Gemini to the list of supported LLM providers. [1] [2]rig-core/README.md
: Updated to include Google Gemini in the list of LLM providers. [1] [2]rig-core/examples/gemini_agent.rs
: Added an example demonstrating how to use the Google Gemini client to create an agent and prompt it.Gemini Models Integration:
rig-core/src/providers/gemini/client.rs
: Implemented the Google Gemini client with methods for creating embedding models, completion models, agents, and extractors.rig-core/src/providers/gemini/completion.rs
: Added support for Google Gemini completion models and defined the necessary request and response structures.rig-core/src/providers/gemini/embedding.rs
: Implemented the embedding model for Google Gemini, including methods for embedding documents.Note
async fn completion()
. In OpenAI we add the preamble but not with Anthropic