Skip to content

The agent engineering platform.

docs, google-vertex[patch]: function docs (#16231)

Erick Friisaa35b43bcd3e
diff --git a/docs/docs/integrations/chat/google_vertex_ai_palm.ipynb b/docs/docs/integrations/chat/google_vertex_ai_palm.ipynb
index 050a32f2bf..008746f747 100644
--- a/docs/docs/integrations/chat/google_vertex_ai_palm.ipynb
+++ b/docs/docs/integrations/chat/google_vertex_ai_palm.ipynb
@@ -34,28 +34,18 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {
"tags": []
},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "^C\n",
- "\u001b[31mERROR: Operation cancelled by user\u001b[0m\u001b[31m\n",
- "\u001b[0mNote: you may need to restart the kernel to use updated packages.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"%pip install --upgrade --quiet langchain-google-vertexai"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -352,6 +342,47 @@
"pprint(result.generations[0][0].generation_info)"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Function Calling with Gemini\n",
+ "\n",
+ "We can call Gemini models with tools."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "MyModel(name='Erick', age=27)"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "from langchain.pydantic_v1 import BaseModel\n",
+ "from langchain_google_vertexai import create_structured_runnable\n",
+ "\n",
+ "llm = ChatVertexAI(model_name=\"gemini-pro\")\n",
+ "\n",
+ "\n",
+ "class MyModel(BaseModel):\n",
+ " name: str\n",
+ " age: int\n",
+ "\n",
+ "\n",
+ "chain = create_structured_runnable(MyModel, llm)\n",
+ "chain.invoke(\"My name is Erick and I'm 27 years old\")"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -386,7 +417,7 @@
"AIMessage(content=' Why do you love programming?')"
]
},
- "execution_count": 7,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
diff --git a/libs/partners/google-vertexai/langchain_google_vertexai/functions_utils.py b/libs/partners/google-vertexai/langchain_google_vertexai/functions_utils.py
index 304e6a85c1..d1786ae678 100644
--- a/libs/partners/google-vertexai/langchain_google_vertexai/functions_utils.py
+++ b/libs/partners/google-vertexai/langchain_google_vertexai/functions_utils.py
@@ -24,7 +24,7 @@ def _format_pydantic_to_vertex_function(
return {
"name": schema["title"],
- "description": schema["description"],
+ "description": schema.get("description", ""),
"parameters": {
"properties": {
k: {