docs: fireworks tool calling docs (#18057)

pull/17966/head
Erick Friis 7 months ago committed by GitHub
parent e566a3077e
commit e85948d46b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -140,10 +140,58 @@
"chat.invoke([system_message, human_message])"
]
},
{
"cell_type": "markdown",
"id": "8c44cb36",
"metadata": {},
"source": [
"# Tool Calling\n",
"\n",
"Fireworks offers the [`FireFunction-v1` tool calling model](https://fireworks.ai/blog/firefunction-v1-gpt-4-level-function-calling). You can use it for structured output and function calling use cases:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "ee2db682",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'function': {'arguments': '{\"name\": \"Erick\", \"age\": 27}',\n",
" 'name': 'ExtractFields'},\n",
" 'id': 'call_J0WYP2TLenaFw3UeVU0UnWqx',\n",
" 'index': 0,\n",
" 'type': 'function'}\n"
]
}
],
"source": [
"from pprint import pprint\n",
"\n",
"from langchain_core.pydantic_v1 import BaseModel\n",
"\n",
"\n",
"class ExtractFields(BaseModel):\n",
" name: str\n",
" age: int\n",
"\n",
"\n",
"chat = ChatFireworks(\n",
" model=\"accounts/fireworks/models/firefunction-v1\",\n",
").bind_tools([ExtractFields])\n",
"\n",
"result = chat.invoke(\"I am a 27 year old named Erick\")\n",
"\n",
"pprint(result.additional_kwargs[\"tool_calls\"][0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c44cb36",
"id": "2321a4e6",
"metadata": {},
"outputs": [],
"source": []

Loading…
Cancel
Save