You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I spent the day trying to solve the same question.
For context, along with the new Gemini 2.0 Flash release, Google also released a new, experimental, Python SDK.
The "native search tool" is a tool available in the new SDK.
It is how you use it in the new SDK:
fromgoogleimportgenaifromgoogle.genai.typesimportTool, GenerateContentConfig, GoogleSearchclient=genai.Client()
model_id="gemini-2.0-flash-exp"google_search_tool=Tool(
google_search=GoogleSearch()
)
response=client.models.generate_content(
model=model_id,
contents="When is the next total solar eclipse in the United States?",
config=GenerateContentConfig(
tools=[google_search_tool],
response_modalities=["TEXT"],
)
)
foreachinresponse.candidates[0].content.parts:
print(each.text)
# Example response:# The next total solar eclipse visible in the contiguous United States will be on ...# To get grounding metadata as web content.print(response.candidates[0].grounding_metadata.search_entry_point.rendered_content)
However, this project (langchain-google) relies on the previous SDK.
Now the problem is that the search feature is not available in the previous SDK.
So either:
Google makes the search tool available in the previous SDK
Langchain-google migrates to the new SDK (still experimental)
Hi,
I'm trying to use the new native search tool in gemini flash 2.0, but I'm not sure how to do so. Is it already supported?
Cheers
The text was updated successfully, but these errors were encountered: