Skip to content

Commit a27a31b

Browse files
committed
docs(generative_ai): Update Grounding with Google Search sample to include dynamic retrieval
1 parent 09e274c commit a27a31b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

generative_ai/grounding/web_example.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ def generate_text_with_grounding_web() -> GenerationResponse:
3636
model = GenerativeModel("gemini-1.5-flash-001")
3737

3838
# Use Google Search for grounding
39-
tool = Tool.from_google_search_retrieval(grounding.GoogleSearchRetrieval())
39+
tool = Tool.from_google_search_retrieval(
40+
grounding.GoogleSearchRetrieval(
41+
# Optional: For Dynamic Retrieval
42+
dynamic_retrieval_config=grounding.DynamicRetrievalConfig(
43+
dynamic_threshold=0.7,
44+
)
45+
)
46+
)
4047

4148
prompt = "When is the next total solar eclipse in US?"
4249
response = model.generate_content(

0 commit comments

Comments
 (0)