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

fix: Add Google Search example to MM Live API Notebook #1652

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"- Text-to-audio conversation\n",
"- Function calling\n",
"- Code execution\n",
"- Google Search\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Consider adding a brief explanation of what the Google Search tool does in this overview. For example, you could add a sentence like "The Google Search tool allows the model to access and process real-time information from the web."

Suggested change
"- Google Search\n",
- Google Search\nThe `google_search` tool allows the model to access and process real-time information from the web.

"\n",
"See the [Multimodal Live API](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/multimodal-live) page for more details."
]
Expand Down Expand Up @@ -177,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"id": "xBCH3hnAX9Bh"
},
Expand All @@ -189,6 +190,7 @@
"from google import genai\n",
"from google.genai.types import (\n",
" FunctionDeclaration,\n",
" GoogleSearch,\n",
" LiveConnectConfig,\n",
" PrebuiltVoiceConfig,\n",
" SpeechConfig,\n",
Expand All @@ -214,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"id": "Nqwi-5ufWp_B"
},
Expand All @@ -229,7 +231,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"id": "T-tiytzQE0uM"
},
Expand All @@ -251,7 +253,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"id": "-coEslfWPrxo"
},
Expand Down Expand Up @@ -577,6 +579,50 @@
" display(Markdown(f\"**Response >** {''.join(response)}\"))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "73660342318d"
},
"source": [
"### **Example 6**: Google Search\n",
"\n",
"The `google_search` tool lets the model conduct Google searches. For example, try asking it about events that are too recent to be in the training data.\n"
Comment on lines +588 to +590
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

The example query in this section could be more specific. Instead of asking about a general earthquake, consider asking about a specific event or aspect related to a recent earthquake. This would better demonstrate the tool's ability to retrieve real-time information. For example, you could ask "What were the initial reported damages from the earthquake?" or "Were there any aftershocks reported following the main earthquake?"

Suggested change
"### **Example 6**: Google Search\n",
"\n",
"The `google_search` tool lets the model conduct Google searches. For example, try asking it about events that are too recent to be in the training data.\n"
### **Example 6**: Google Search
The `google_search` tool lets the model conduct Google searches. For example, try asking it about specific details related to a recent event, like an earthquake, that are too recent to be in the training data.

]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "e64fc3a94d49"
},
"outputs": [],
"source": [
"config = LiveConnectConfig(\n",
" response_modalities=[\"TEXT\"],\n",
" tools=[Tool(google_search=GoogleSearch())],\n",
")\n",
"\n",
"async with client.aio.live.connect(\n",
" model=MODEL_ID,\n",
" config=config,\n",
") as session:\n",
" text_input = (\n",
" \"Tell me about the largest earthquake in California the week of Dec 5 2024?\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

As mentioned in the previous comment, consider making the example query more specific. For instance, instead of asking about the largest earthquake in general, try asking about a specific detail, such as the magnitude or the epicenter of the earthquake. This would better illustrate the tool's ability to retrieve precise information. For example, you could ask "What was the magnitude and epicenter of the largest earthquake in California during the week of December 5, 2024?"

Suggested change
" \"Tell me about the largest earthquake in California the week of Dec 5 2024?\"\n",
"What was the magnitude and epicenter of the largest earthquake in California during the week of December 5, 2024?"

" )\n",
" display(Markdown(f\"**Input:** {text_input}\"))\n",
"\n",
" await session.send(input=text_input, end_of_turn=True)\n",
"\n",
" response = []\n",
"\n",
" async for message in session.receive():\n",
" if message.text:\n",
" response.append(message.text)\n",
"\n",
" display(Markdown(f\"**Response >** {''.join(response)}\"))"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
Loading