From 7326a6351aae9a5cda60cc84fd3ab4b0735f747c Mon Sep 17 00:00:00 2001 From: Sahar Shemesh <48128579+saharis9988@users.noreply.github.com> Date: Sat, 25 Jan 2025 02:15:52 +0200 Subject: [PATCH] docs: Clarify tool creation process in structured outputs documentation (#7578) Co-authored-by: Sahar Shemesh Co-authored-by: jacoblee93 --- docs/core_docs/docs/concepts/structured_outputs.mdx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/core_docs/docs/concepts/structured_outputs.mdx b/docs/core_docs/docs/concepts/structured_outputs.mdx index 173fa2fbcc9b..4491c956f127 100644 --- a/docs/core_docs/docs/concepts/structured_outputs.mdx +++ b/docs/core_docs/docs/concepts/structured_outputs.mdx @@ -79,7 +79,7 @@ Several more powerful methods that utilizes native features in the model provide Many [model providers support](/docs/integrations/chat/) tool calling, a concept discussed in more detail in our [tool calling guide](/docs/concepts/tool_calling/). In short, tool calling involves binding a tool to a model and, when appropriate, the model can _decide_ to call this tool and ensure its response conforms to the tool's schema. -With this in mind, the central concept is straightforward: _simply bind our schema to a model as a tool!_ +With this in mind, the central concept is straightforward: _create a tool with our schema and bind it to the model!_ Here is an example using the `ResponseFormatter` schema defined above: ```typescript @@ -90,8 +90,14 @@ const model = new ChatOpenAI({ temperature: 0, }); -// Bind ResponseFormatter schema as a tool to the model -const modelWithTools = model.bindTools([ResponseFormatter]); +// Create a tool with ResponseFormatter as its schema. +const responseFormatterTool = tool(async () => {}, { + name: "responseFormatter", + schema: ResponseFormatter, +}); + +// Bind the created tool to the model +const modelWithTools = model.bindTools([responseFormatterTool]); // Invoke the model const aiMsg = await modelWithTools.invoke(