From e85948d46bab657c101057f9a41f54aa9d1d8303 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Fri, 23 Feb 2024 16:49:11 -0800 Subject: [PATCH] docs: fireworks tool calling docs (#18057) --- docs/docs/integrations/chat/fireworks.ipynb | 50 ++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/docs/docs/integrations/chat/fireworks.ipynb b/docs/docs/integrations/chat/fireworks.ipynb index ec9a9d3962527f..8cee725511c4fa 100644 --- a/docs/docs/integrations/chat/fireworks.ipynb +++ b/docs/docs/integrations/chat/fireworks.ipynb @@ -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": []