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

[Bug]: grounding notebook does not work with gemini-2.0-flash-exp #1535

Closed
1 task done
gbmerrall opened this issue Dec 16, 2024 · 3 comments · Fixed by #1539
Closed
1 task done

[Bug]: grounding notebook does not work with gemini-2.0-flash-exp #1535

gbmerrall opened this issue Dec 16, 2024 · 3 comments · Fixed by #1539

Comments

@gbmerrall
Copy link

File Name

gemini/grounding /intro-grounding-gemini.ipynb

What happened?

(hello from a Xoogler)

If you run the initial code from the notebook using

vertexai.init(project=PROJECT_ID, location=LOCATION)
model = GenerativeModel("gemini-2.0-flash-exp")

tool = Tool.from_google_search_retrieval(grounding.GoogleSearchRetrieval())
PROMPT = "You are an expert in astronomy. When is the next solar eclipse in the US?"
response = model.generate_content(PROMPT, tools=[tool])

An error is produced. See below. Switching back to flash-1.5 works just fine.

Noting that this is an issue in google-cloud-aiplatform. See googleapis/python-aiplatform#4779 but if it requires notebook changes once resolved, including an issue report here.

Relevant log output

status = StatusCode.INVALID_ARGUMENT
	details = "Unable to submit request because Please use google_search field instead of google_search_retrieval field.. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini"
	debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B2404:6800:4006:811::200a%5D:443 {created_time:"2024-12-16T12:45:02.751932+13:00", grpc_status:3, grpc_message:"Unable to submit request because Please use google_search field instead of google_search_retrieval field.. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini"}"

Code of Conduct

  • I agree to follow this project's Code of Conduct
@holtskinner
Copy link
Collaborator

This is working as expected. Gemini 2.0 only works with the updated SDK, which this notebook is not using.

Refer to this notebook to see how to use Gemini 2.0 with Grounding. https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_0_flash.ipynb

I'll make a PR to add a notice to these notebooks.

@theloglizard
Copy link

Thanks for this. As a heads up for my fellow test pilots, the grounding is in intro_gemini_2_0_flash.ipynb but you have to go down into the notebook Cell titled Google Search . The calls worked for me upon getting synched to the examples provided. As of 27 Dec 2024 it does not appear that the intro-grounding-gemini.ipynb is set up for Gemini 2.0.

@jsalsman
Copy link

jsalsman commented Jan 2, 2025

@holtskinner so we only need to add the tools=[Tool(google_search=GoogleSearch())] config? Is the dynamic_threshold parameter gone? I got this far:

        return client.models.generate_content(
            model='gemini-2.0-flash-exp',  # free for now, top-performer and very fast
            contents=prompt,
            config=GenerateContentConfig(
                temperature=0, seed=42,  # 0 and constant seed for reproducibility
                response_modalities=["TEXT"],
                tools=[Tool(
                    google_search=GoogleSearch(
                        #dynamic_retrieval_config=DynamicRetrievalConfig(  ### TODO: DEBUG
                        #    mode="MODE_DYNAMIC",
                        #    dynamic_threshold=0.0  # 0 means always ground
                        #)
                    )
                )] if ground else None,
            )
        ).text.strip()

But when uncommenting those lines: "1 validation error for googlesearch dynamic_retrieval_config extra inputs are not permitted [type=extra_forbidden, input_value=dynamicretrievalconfig(mo..., dynamic_threshold=0.0), input_type=dynamicretrievalconfig] for further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden "

My application confabulates URLs like crazy without turning the threshold to 0. Details on request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants