mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-11 10:06:05 +00:00
docs, google-vertex[patch]: function docs (#16231)
This commit is contained in:
parent
f2b2d59e82
commit
aa35b43bcd
@ -34,28 +34,18 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"%pip install --upgrade --quiet langchain-google-vertexai"
|
"%pip install --upgrade --quiet langchain-google-vertexai"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@ -352,6 +342,47 @@
|
|||||||
"pprint(result.generations[0][0].generation_info)"
|
"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",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -386,7 +417,7 @@
|
|||||||
"AIMessage(content=' Why do you love programming?')"
|
"AIMessage(content=' Why do you love programming?')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 7,
|
"execution_count": 6,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ def _format_pydantic_to_vertex_function(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"name": schema["title"],
|
"name": schema["title"],
|
||||||
"description": schema["description"],
|
"description": schema.get("description", ""),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"properties": {
|
"properties": {
|
||||||
k: {
|
k: {
|
||||||
|
Loading…
Reference in New Issue
Block a user