-
Notifications
You must be signed in to change notification settings - Fork 160
feat: wrap_gemini beta python #2059
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
base: main
Are you sure you want to change the base?
Conversation
|
||
.. code-block:: python | ||
|
||
from google import genai |
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 know they have a bunch of different clients and they were unifying them - but is it worth calling this wrap_google_genai
instead?
Think it's also better because I'm pretty sure you can access non-Gemini models (e.g. Gemma, other Model Garden stuff)
|
||
# Non-streaming: | ||
response = client.models.generate_content( | ||
model="gemini-2.0-flash-001", |
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.
nit: use latest model string
return {k: v for k, v in d.items() if v is not None} | ||
|
||
|
||
def _process_gemini_inputs(inputs: dict) -> dict: |
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.
Any special consideration needed for tool calls?
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.
Would definitely add a tool calling test too
stop = config.get("stop_sequences") | ||
|
||
return { | ||
"ls_provider": "google", |
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.
Worth checking to make sure this is the same as LangChain
wrap_gemini has been requested quite many times (23 upvotes from sdk issues); we wanted to make it in September
Tests: integration test (still need to add google_api_key in github settings) and inspection in langsmith https://smith.langchain.com/public/d3958002-41cd-4df2-9711-91689ec3ea88/r
Note: mark as beta because even though the messages goes up to langsmith, i expect there'll be edges cases on rendering we need to take care of; don't really expect much breaking changes but wanna be proactive in setting expectation