Skip to content

Commit a571d6e

Browse files
authored
chore(provider-utils): move ToolResultContent to provider-utils (vercel#6121)
## Background After a lot of cross-referencing, the only cleanup we need is to unify this interface into provider-utils ## Summary Move ToolResultContent to provider-utils
1 parent a8c8bd5 commit a571d6e

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

.changeset/angry-crabs-develop.md

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

packages/ai/core/prompt/tool-result-content.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1+
import { ToolResultContent } from '@ai-sdk/provider-utils';
12
import { z } from 'zod';
23

3-
export type ToolResultContent = Array<
4-
| {
5-
type: 'text';
6-
text: string;
7-
}
8-
| {
9-
type: 'image';
10-
data: string; // base64 encoded png image, e.g. screenshot
11-
mediaType?: string; // e.g. 'image/png';
12-
13-
/**
14-
* @deprecated Use `mediaType` instead.
15-
*/
16-
mimeType?: string; // e.g. 'image/png';
17-
}
18-
>;
4+
export type { ToolResultContent };
195

206
export const toolResultContentSchema: z.ZodType<ToolResultContent> = z.array(
217
z.union([

packages/anthropic/src/anthropic-tools.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1+
import { ToolResultContent } from '@ai-sdk/provider-utils';
12
import { z } from 'zod';
23

3-
// Copied from ai package
44
type ExecuteFunction<PARAMETERS, RESULT> =
55
| undefined
66
| ((
77
args: PARAMETERS,
88
options: { abortSignal?: AbortSignal },
99
) => Promise<RESULT>);
1010

11-
// Copied from ai package
12-
export type ToolResultContent = Array<
13-
| {
14-
type: 'text';
15-
text: string;
16-
}
17-
| {
18-
type: 'image';
19-
data: string; // base64 encoded png image, e.g. screenshot
20-
mediaType?: string; // e.g. 'image/png';
21-
}
22-
>;
23-
2411
const Bash20241022Parameters = z.object({
2512
command: z.string(),
2613
restart: z.boolean().optional(),

packages/provider-utils/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ export type { Schema } from './schema';
3030
export { zodSchema } from './zod-schema';
3131

3232
export type { ToolCall } from './types/tool-call';
33-
export type { ToolResult } from './types/tool-result';
33+
export type { ToolResult, ToolResultContent } from './types/tool-result';

packages/provider-utils/src/types/tool-result.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,20 @@ Result of the tool call. This is the result of the tool's execution.
2323
*/
2424
result: RESULT;
2525
}
26+
27+
export type ToolResultContent = Array<
28+
| {
29+
type: 'text';
30+
text: string;
31+
}
32+
| {
33+
type: 'image';
34+
data: string; // base64 encoded png image, e.g. screenshot
35+
mediaType?: string; // e.g. 'image/png';
36+
37+
/**
38+
* @deprecated Use `mediaType` instead.
39+
*/
40+
mimeType?: string; // e.g. 'image/png';
41+
}
42+
>;

0 commit comments

Comments
 (0)