Skip to content

Commit b32cde7

Browse files
authored
docs(generative_ai): Update Grounding with Google Search sample to include dynamic retrieval (GoogleCloudPlatform#13099)
* docs(generative_ai): Update Grounding with Google Search sample to include dynamic retrieval * Update requirements.txt * Update requirements-test.txt
1 parent 09e274c commit b32cde7

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed
+1-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
pandas==1.3.5; python_version == '3.7'
2-
pandas==2.0.3; python_version == '3.8'
3-
pandas==2.1.4; python_version > '3.8'
4-
pillow==10.3.0; python_version < '3.8'
5-
pillow==10.3.0; python_version >= '3.8'
6-
google-cloud-aiplatform[all]==1.69.0
7-
sentencepiece==0.2.0
8-
google-auth==2.29.0
9-
anthropic[vertex]==0.28.0
10-
langchain-core==0.2.33
11-
langchain-google-vertexai==1.0.10
12-
numpy<2
13-
openai==1.30.5
14-
immutabledict==4.2.0
1+
google-cloud-aiplatform==1.78.0

generative_ai/grounding/web_example.py

+8-1
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)