You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even for Anthropic, we translate their tool calls into our own
consistent format, but we were accidentally passing through a possible
Anthropic style and documentating _that_.
Copy file name to clipboardExpand all lines: packages/ai/README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,14 +87,14 @@ console.log(
87
87
88
88
The `@gel/ai` package supports tool calls, allowing you to extend the capabilities of the AI model with your own functions. Here's how to use them:
89
89
90
-
1.**Define your tools**: Create an array of `ToolDefinition` objects that describe your functions, their parameters, and what they do.
91
-
2.**Send the request**: Call `queryRag` or `streamRag` with the user's prompt and the `tools` array. You can also use the `tool_choice` parameter to control how the model uses your tools.
92
-
3.**Handle the tool call**: If the model decides to use a tool, it will return an `AssistantMessage` with a `tool_calls` array. Your code needs to:
93
-
a. Parse the `tool_calls` array to identify the tool and its arguments.
94
-
b. Execute the tool and get the result.
95
-
c. Create a `ToolMessage` with the result.
96
-
d. Send the `ToolMessage` back to the model in a new request.
97
-
4.**Receive the final response**: The model will use the tool's output to generate a final response.
90
+
1.**Define your tools**: Create an array of `ToolDefinition` objects that describe your functions, their parameters, and what they do.
91
+
2.**Send the request**: Call `queryRag` or `streamRag` with the user's prompt and the `tools` array. You can also use the `tool_choice` parameter to control how the model uses your tools.
92
+
3.**Handle the tool call**: If the model decides to use a tool, it will return an `AssistantMessage` with a `tool_calls` array. Your code needs to:
93
+
a. Parse the `tool_calls` array to identify the tool and its arguments.
94
+
b. Execute the tool and get the result.
95
+
c. Create a `ToolMessage` with the result.
96
+
d. Send the `ToolMessage` back to the model in a new request.
97
+
4.**Receive the final response**: The model will use the tool's output to generate a final response.
98
98
99
99
### Example
100
100
@@ -200,14 +200,14 @@ async function handleStreamingResponse(initialMessages: Message[]) {
0 commit comments