Skip to content

Commit 3a602ca

Browse files
authored
chore (core): rename CoreTool to Tool (#4548)
1 parent 9881bd8 commit 3a602ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+206
-168
lines changed

.changeset/fluffy-snails-hide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@ai-sdk/provider-utils': patch
3+
'@ai-sdk/ui-utils': patch
4+
'ai': patch
5+
---
6+
7+
chore (core): rename CoreTool to Tool

content/docs/03-ai-sdk-core/05-generating-text.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ all text to uppercase:
241241

242242
```ts
243243
const upperCaseTransform =
244-
<TOOLS extends Record<string, CoreTool>>() =>
244+
<TOOLS extends ToolSet>() =>
245245
(options: { tools: TOOLS; stopStream: () => void }) =>
246246
new TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>({
247247
transform(chunk, controller) {
@@ -263,7 +263,7 @@ and all callbacks are invoked.
263263

264264
```ts
265265
const stopWordTransform =
266-
<TOOLS extends Record<string, CoreTool>>() =>
266+
<TOOLS extends ToolSet>() =>
267267
({ stopStream }: { stopStream: () => void }) =>
268268
new TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>({
269269
// note: this is a simplified transformation for testing;

content/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,18 @@ To enable this, the AI SDK provides several helper types for tools, tool calls,
304304
You can use them to strongly type your variables, function parameters, and return types
305305
in parts of the code that are not directly related to `streamText` or `generateText`.
306306

307-
Each tool call is typed with `CoreToolCall<NAME extends string, ARGS>`, depending
307+
Each tool call is typed with `ToolCall<NAME extends string, ARGS>`, depending
308308
on the tool that has been invoked.
309-
Similarly, the tool results are typed with `CoreToolResult<NAME extends string, ARGS, RESULT>`.
309+
Similarly, the tool results are typed with `ToolResult<NAME extends string, ARGS, RESULT>`.
310310

311-
The tools in `streamText` and `generateText` are defined as a `Record<string, CoreTool>`.
312-
The type inference helpers `CoreToolCallUnion<TOOLS extends Record<string, CoreTool>>`
313-
and `CoreToolResultUnion<TOOLS extends Record<string, CoreTool>>` can be used to
311+
The tools in `streamText` and `generateText` are defined as a `ToolSet`.
312+
The type inference helpers `ToolCallUnion<TOOLS extends ToolSet>`
313+
and `ToolResultUnion<TOOLS extends ToolSet>` can be used to
314314
extract the tool call and tool result types from the tools.
315315

316316
```ts highlight="18-19,23-24"
317317
import { openai } from '@ai-sdk/openai';
318-
import { CoreToolCallUnion, CoreToolResultUnion, generateText, tool } from 'ai';
318+
import { ToolCallUnion, ToolResultUnion, generateText, tool } from 'ai';
319319
import { z } from 'zod';
320320

321321
const myToolSet = {
@@ -331,8 +331,8 @@ const myToolSet = {
331331
}),
332332
};
333333

334-
type MyToolCall = CoreToolCallUnion<typeof myToolSet>;
335-
type MyToolResult = CoreToolResultUnion<typeof myToolSet>;
334+
type MyToolCall = ToolCallUnion<typeof myToolSet>;
335+
type MyToolResult = ToolResultUnion<typeof myToolSet>;
336336

337337
async function generateSomething(prompt: string): Promise<{
338338
text: string;

content/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ To see `generateText` in action, check out [these examples](#examples).
260260
},
261261
{
262262
name: 'tools',
263-
type: 'Record<string, CoreTool>',
263+
type: 'ToolSet',
264264
description:
265265
'Tools that are accessible to and can be called by the model. The model needs to support calling tools.',
266266
properties: [
267267
{
268-
type: 'CoreTool',
268+
type: 'Tool',
269269
parameters: [
270270
{
271271
name: 'description',

content/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ To see `streamText` in action, check out [these examples](#examples).
262262
},
263263
{
264264
name: 'tools',
265-
type: 'Record<string, CoreTool>',
265+
type: 'ToolSet',
266266
description:
267267
'Tools that are accessible to and can be called by the model. The model needs to support calling tools.',
268268
properties: [
269269
{
270-
type: 'CoreTool',
270+
type: 'Tool',
271271
parameters: [
272272
{
273273
name: 'description',

content/docs/07-reference/01-ai-sdk-core/20-tool.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export const weatherTool = tool({
4141
content={[
4242
{
4343
name: 'tool',
44-
type: 'CoreTool',
44+
type: 'Tool',
4545
description: 'The tool definition.',
4646
properties: [
4747
{
48-
type: 'CoreTool',
48+
type: 'Tool',
4949
parameters: [
5050
{
5151
name: 'description',

content/docs/07-reference/02-ai-sdk-ui/31-convert-to-core-messages.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function POST(req: Request) {
4646
},
4747
{
4848
name: 'options',
49-
type: '{ tools?: Record<string, Tool> }',
49+
type: '{ tools?: ToolSet }',
5050
description:
5151
'Optional configuration object. Provide tools to enable multi-modal tool responses.',
5252
},

content/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ To see `streamUI` in action, check out [these examples](#examples).
332332
},
333333
{
334334
name: 'tools',
335-
type: 'Record<string, Tool>',
335+
type: 'ToolSet',
336336
description:
337337
'Tools that are accessible to and can be called by the model.',
338338
properties: [

content/docs/07-reference/03-ai-sdk-rsc/20-render.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ A helper function to create a streamable UI from LLM providers. This function is
162162
},
163163
{
164164
name: 'functions',
165-
type: 'Record<string, Tool>',
165+
type: 'ToolSet',
166166
isOptional: true,
167167
description:
168168
'Tools that are accessible to and can be called by the model.',
@@ -196,7 +196,7 @@ A helper function to create a streamable UI from LLM providers. This function is
196196
},
197197
{
198198
name: 'tools',
199-
type: 'Record<string, Tool>',
199+
type: 'ToolSet',
200200
isOptional: true,
201201
description:
202202
'Tools that are accessible to and can be called by the model.',

examples/ai-core/src/types/tool-set.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { openai } from '@ai-sdk/openai';
2-
import { CoreToolCallUnion, CoreToolResultUnion, generateText, tool } from 'ai';
2+
import { ToolCallUnion, ToolResultUnion, generateText, tool } from 'ai';
33
import { z } from 'zod';
44

55
const myToolSet = {
@@ -15,8 +15,8 @@ const myToolSet = {
1515
}),
1616
};
1717

18-
type MyToolCall = CoreToolCallUnion<typeof myToolSet>;
19-
type MyToolResult = CoreToolResultUnion<typeof myToolSet>;
18+
type MyToolCall = ToolCallUnion<typeof myToolSet>;
19+
type MyToolResult = ToolResultUnion<typeof myToolSet>;
2020

2121
async function generateSomething(prompt: string): Promise<{
2222
text: string;

0 commit comments

Comments
 (0)