mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-04 18:53:02 +00:00
docs: document built-in tools for ChatVertexAI (#31564)
This commit is contained in:
parent
d10fd02bb3
commit
446a9d5647
@ -184,6 +184,64 @@
|
|||||||
"print(ai_msg.content)"
|
"print(ai_msg.content)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "28ccabbb-a450-403c-8de1-fb077e0b5d3d",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Built-in tools\n",
|
||||||
|
"\n",
|
||||||
|
"Gemini supports a range of tools that are executed server-side.\n",
|
||||||
|
"\n",
|
||||||
|
"### Google search\n",
|
||||||
|
"\n",
|
||||||
|
":::info Requires ``langchain-google-vertexai>=2.0.11``\n",
|
||||||
|
":::\n",
|
||||||
|
"\n",
|
||||||
|
"Gemini can execute a Google search and use the results to [ground its responses](https://ai.google.dev/gemini-api/docs/grounding):"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "ffdbec37-85f8-4755-bd72-47efaecfe944",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from langchain_google_vertexai import ChatVertexAI\n",
|
||||||
|
"\n",
|
||||||
|
"llm = ChatVertexAI(model=\"gemini-2.0-flash-001\").bind_tools([{\"google_search\": {}}])\n",
|
||||||
|
"\n",
|
||||||
|
"response = llm.invoke(\"What is today's news?\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "f63824f5-7d6a-4ad7-aa17-1f5c44119a21",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Code execution\n",
|
||||||
|
"\n",
|
||||||
|
":::info Requires ``langchain-google-vertexai>=2.0.25``\n",
|
||||||
|
":::\n",
|
||||||
|
"\n",
|
||||||
|
"Gemini can [generate and execute Python code](https://ai.google.dev/gemini-api/docs/code-execution):"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "aa079529-ef1c-463d-9d25-6390423a328d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from langchain_google_vertexai import ChatVertexAI\n",
|
||||||
|
"\n",
|
||||||
|
"llm = ChatVertexAI(model=\"gemini-2.0-flash-001\").bind_tools([{\"code_execution\": {}}])\n",
|
||||||
|
"\n",
|
||||||
|
"response = llm.invoke(\"What is 3^3?\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "18e2bfc0-7e78-4528-a73f-499ac150dca8",
|
"id": "18e2bfc0-7e78-4528-a73f-499ac150dca8",
|
||||||
@ -247,9 +305,9 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "poetry-venv-2",
|
"display_name": "Python 3 (ipykernel)",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "poetry-venv-2"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
@ -261,7 +319,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.9.1"
|
"version": "3.10.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
Loading…
Reference in New Issue
Block a user