Skip to content

Commit

Permalink
docs: fireworks tool calling docs (langchain-ai#18057)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored and al1p-R committed Feb 27, 2024
1 parent 8ec79fc commit 6810c56
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion docs/docs/integrations/chat/fireworks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
Expand Down

0 comments on commit 6810c56

Please sign in to comment.