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

Gemini flash 2.0 exp native tools use #649

Open
Layvier opened this issue Dec 17, 2024 · 2 comments
Open

Gemini flash 2.0 exp native tools use #649

Layvier opened this issue Dec 17, 2024 · 2 comments

Comments

@Layvier
Copy link

Layvier commented Dec 17, 2024

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

@Kydlaw
Copy link

Kydlaw commented Dec 18, 2024

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:

from google import genai
from google.genai.types import Tool, GenerateContentConfig, GoogleSearch

client = 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"],
    )
)

for each in response.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:

  1. Google makes the search tool available in the previous SDK
  2. Langchain-google migrates to the new SDK (still experimental)

@Layvier
Copy link
Author

Layvier commented Dec 18, 2024

I see, indeed I found this issue on the google-cloud-aiplatform sdk repo. Thanks for the clarification 👍

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

2 participants