@ai-sdk/amazon-bedrock 4.0.28 → 4.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +42 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -10
- package/dist/index.mjs.map +1 -1
- package/docs/08-amazon-bedrock.mdx +7 -0
- package/package.json +10 -6
- package/src/bedrock-embedding-model.ts +48 -11
- package/src/bedrock-embedding-options.ts +14 -0
- package/src/__fixtures__/bedrock-json-only-text-first.1.chunks.txt +0 -7
- package/src/__fixtures__/bedrock-json-other-tool.1.chunks.txt +0 -6
- package/src/__fixtures__/bedrock-json-other-tool.1.json +0 -24
- package/src/__fixtures__/bedrock-json-tool-text-then-weather-then-json.1.chunks.txt +0 -12
- package/src/__fixtures__/bedrock-json-tool-with-answer.1.json +0 -29
- package/src/__fixtures__/bedrock-json-tool.1.chunks.txt +0 -4
- package/src/__fixtures__/bedrock-json-tool.1.json +0 -35
- package/src/__fixtures__/bedrock-json-tool.2.chunks.txt +0 -6
- package/src/__fixtures__/bedrock-json-tool.2.json +0 -28
- package/src/__fixtures__/bedrock-json-tool.3.chunks.txt +0 -7
- package/src/__fixtures__/bedrock-json-tool.3.json +0 -36
- package/src/__fixtures__/bedrock-json-with-tool.1.chunks.txt +0 -9
- package/src/__fixtures__/bedrock-json-with-tool.1.json +0 -41
- package/src/__fixtures__/bedrock-json-with-tools.1.chunks.txt +0 -12
- package/src/__fixtures__/bedrock-json-with-tools.1.json +0 -50
- package/src/__fixtures__/bedrock-tool-call.1.chunks.txt +0 -6
- package/src/__fixtures__/bedrock-tool-call.1.json +0 -24
- package/src/__fixtures__/bedrock-tool-no-args.chunks.txt +0 -8
- package/src/__fixtures__/bedrock-tool-no-args.json +0 -25
- package/src/anthropic/bedrock-anthropic-fetch.test.ts +0 -344
- package/src/anthropic/bedrock-anthropic-provider.test.ts +0 -456
- package/src/bedrock-chat-language-model.test.ts +0 -4569
- package/src/bedrock-embedding-model.test.ts +0 -148
- package/src/bedrock-event-stream-response-handler.test.ts +0 -233
- package/src/bedrock-image-model.test.ts +0 -866
- package/src/bedrock-provider.test.ts +0 -457
- package/src/bedrock-sigv4-fetch.test.ts +0 -675
- package/src/convert-bedrock-usage.test.ts +0 -207
- package/src/convert-to-bedrock-chat-messages.test.ts +0 -1175
- package/src/inject-fetch-headers.test.ts +0 -135
- package/src/normalize-tool-call-id.test.ts +0 -72
- package/src/reranking/__fixtures__/bedrock-reranking.1.json +0 -12
- package/src/reranking/bedrock-reranking-model.test.ts +0 -299
|
@@ -758,6 +758,13 @@ The following optional provider options are available for Bedrock Titan embeddin
|
|
|
758
758
|
| `cohere.embed-english-v3` | 1024 | <Cross size={18} /> |
|
|
759
759
|
| `cohere.embed-multilingual-v3` | 1024 | <Cross size={18} /> |
|
|
760
760
|
|
|
761
|
+
<Note>
|
|
762
|
+
Cohere embedding models on Bedrock require an <code>input_type</code>. Set it
|
|
763
|
+
via
|
|
764
|
+
<code>providerOptions.bedrock.inputType</code> (defaults to{' '}
|
|
765
|
+
<code>search_query</code>).
|
|
766
|
+
</Note>
|
|
767
|
+
|
|
761
768
|
## Reranking Models
|
|
762
769
|
|
|
763
770
|
You can create models that call the [Bedrock Rerank API](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-api.html)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.30",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"dist/**/*",
|
|
11
11
|
"docs/**/*",
|
|
12
12
|
"src",
|
|
13
|
+
"!src/**/*.test.ts",
|
|
14
|
+
"!src/**/*.test-d.ts",
|
|
15
|
+
"!src/**/__snapshots__",
|
|
16
|
+
"!src/**/__fixtures__",
|
|
13
17
|
"CHANGELOG.md",
|
|
14
18
|
"README.md",
|
|
15
19
|
"anthropic/index.d.ts"
|
|
@@ -34,17 +38,17 @@
|
|
|
34
38
|
"@smithy/eventstream-codec": "^4.0.1",
|
|
35
39
|
"@smithy/util-utf8": "^4.0.0",
|
|
36
40
|
"aws4fetch": "^1.0.20",
|
|
37
|
-
"@ai-sdk/anthropic": "3.0.
|
|
38
|
-
"@ai-sdk/provider": "3.0.
|
|
39
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
41
|
+
"@ai-sdk/anthropic": "3.0.23",
|
|
42
|
+
"@ai-sdk/provider": "3.0.5",
|
|
43
|
+
"@ai-sdk/provider-utils": "4.0.9"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/node": "20.17.24",
|
|
43
47
|
"tsup": "^8.3.0",
|
|
44
48
|
"typescript": "5.8.3",
|
|
45
49
|
"zod": "3.25.76",
|
|
46
|
-
"@ai-
|
|
47
|
-
"@
|
|
50
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
51
|
+
"@ai-sdk/test-server": "1.0.3"
|
|
48
52
|
},
|
|
49
53
|
"peerDependencies": {
|
|
50
54
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -67,11 +67,23 @@ export class BedrockEmbeddingModel implements EmbeddingModelV3 {
|
|
|
67
67
|
})) ?? {};
|
|
68
68
|
|
|
69
69
|
// https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
//
|
|
71
|
+
// Note: Different embedding model families expect different request/response
|
|
72
|
+
// payloads (e.g. Titan vs Cohere). We keep the public interface stable and
|
|
73
|
+
// adapt here based on the modelId.
|
|
74
|
+
const args = this.modelId.startsWith('cohere.embed-')
|
|
75
|
+
? {
|
|
76
|
+
// Cohere embedding models on Bedrock require `input_type`.
|
|
77
|
+
// Without it, the service attempts other schema branches and rejects the request.
|
|
78
|
+
input_type: bedrockOptions.inputType ?? 'search_query',
|
|
79
|
+
texts: [values[0]],
|
|
80
|
+
truncate: bedrockOptions.truncate,
|
|
81
|
+
}
|
|
82
|
+
: {
|
|
83
|
+
inputText: values[0],
|
|
84
|
+
dimensions: bedrockOptions.dimensions,
|
|
85
|
+
normalize: bedrockOptions.normalize,
|
|
86
|
+
};
|
|
75
87
|
const url = this.getUrl(this.modelId);
|
|
76
88
|
const { value: response } = await postJsonToApi({
|
|
77
89
|
url,
|
|
@@ -90,15 +102,40 @@ export class BedrockEmbeddingModel implements EmbeddingModelV3 {
|
|
|
90
102
|
abortSignal,
|
|
91
103
|
});
|
|
92
104
|
|
|
105
|
+
const embedding =
|
|
106
|
+
'embedding' in response
|
|
107
|
+
? response.embedding
|
|
108
|
+
: Array.isArray(response.embeddings)
|
|
109
|
+
? response.embeddings[0]
|
|
110
|
+
: response.embeddings.float[0];
|
|
111
|
+
|
|
93
112
|
return {
|
|
94
113
|
warnings: [],
|
|
95
|
-
embeddings: [
|
|
96
|
-
usage: {
|
|
114
|
+
embeddings: [embedding],
|
|
115
|
+
usage: {
|
|
116
|
+
tokens:
|
|
117
|
+
'inputTextTokenCount' in response
|
|
118
|
+
? response.inputTextTokenCount
|
|
119
|
+
: NaN,
|
|
120
|
+
},
|
|
97
121
|
};
|
|
98
122
|
}
|
|
99
123
|
}
|
|
100
124
|
|
|
101
|
-
const BedrockEmbeddingResponseSchema = z.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
125
|
+
const BedrockEmbeddingResponseSchema = z.union([
|
|
126
|
+
// Titan-style response
|
|
127
|
+
z.object({
|
|
128
|
+
embedding: z.array(z.number()),
|
|
129
|
+
inputTextTokenCount: z.number(),
|
|
130
|
+
}),
|
|
131
|
+
// Cohere v3-style response
|
|
132
|
+
z.object({
|
|
133
|
+
embeddings: z.array(z.array(z.number())),
|
|
134
|
+
}),
|
|
135
|
+
// Cohere v4-style response
|
|
136
|
+
z.object({
|
|
137
|
+
embeddings: z.object({
|
|
138
|
+
float: z.array(z.array(z.number())),
|
|
139
|
+
}),
|
|
140
|
+
}),
|
|
141
|
+
]);
|
|
@@ -21,4 +21,18 @@ Flag indicating whether or not to normalize the output embeddings. Defaults to t
|
|
|
21
21
|
Only supported in amazon.titan-embed-text-v2:0.
|
|
22
22
|
*/
|
|
23
23
|
normalize: z.boolean().optional(),
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
Input type for Cohere embedding models on Bedrock.
|
|
27
|
+
Common values: `search_document`, `search_query`, `classification`, `clustering`.
|
|
28
|
+
If not set, the provider defaults to `search_query`.
|
|
29
|
+
*/
|
|
30
|
+
inputType: z
|
|
31
|
+
.enum(['search_document', 'search_query', 'classification', 'clustering'])
|
|
32
|
+
.optional(),
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
Truncation behavior for Cohere embedding models on Bedrock.
|
|
36
|
+
*/
|
|
37
|
+
truncate: z.enum(['NONE', 'START', 'END']).optional(),
|
|
24
38
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Here is your data:"}}}
|
|
2
|
-
{"contentBlockStop":{"contentBlockIndex":0}}
|
|
3
|
-
{"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"json-tool-1","name":"json"}}}}
|
|
4
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"name\":\"John\"}"}}}}
|
|
5
|
-
{"contentBlockStop":{"contentBlockIndex":1}}
|
|
6
|
-
{"metadata":{"usage":{"inputTokens":100,"outputTokens":20,"totalTokens":120}}}
|
|
7
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"contentBlockStart":{"contentBlockIndex":0,"start":{"toolUse":{"toolUseId":"toolu_01PQjhxo3eirCdKNvCJrKc8f","name":"get-weather"}}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"{\"location\":"}}}}
|
|
3
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"\"San Francisco\"}"}}}}
|
|
4
|
-
{"contentBlockStop":{"contentBlockIndex":0}}
|
|
5
|
-
{"metadata":{"usage":{"inputTokens":843,"outputTokens":28,"totalTokens":871}}}
|
|
6
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"toolUse": {
|
|
8
|
-
"toolUseId": "toolu_01PQjhxo3eirCdKNvCJrKc8f",
|
|
9
|
-
"name": "get-weather",
|
|
10
|
-
"input": {
|
|
11
|
-
"location": "San Francisco"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"usage": {
|
|
19
|
-
"inputTokens": 843,
|
|
20
|
-
"outputTokens": 28,
|
|
21
|
-
"totalTokens": 871
|
|
22
|
-
},
|
|
23
|
-
"stopReason": "tool_use"
|
|
24
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"2 + 2 equals 4. Now let me check"}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":" the weather for you."}}}
|
|
3
|
-
{"contentBlockStop":{"contentBlockIndex":0}}
|
|
4
|
-
{"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"weather-tool-1","name":"weather"}}}}
|
|
5
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"location\":"}}}}
|
|
6
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"\"San Francisco\"}"}}}}
|
|
7
|
-
{"contentBlockStop":{"contentBlockIndex":1}}
|
|
8
|
-
{"contentBlockStart":{"contentBlockIndex":2,"start":{"toolUse":{"toolUseId":"weather-tool-2","name":"weather"}}}}
|
|
9
|
-
{"contentBlockDelta":{"contentBlockIndex":2,"delta":{"toolUse":{"input":"{\"location\":\"London\"}"}}}}
|
|
10
|
-
{"contentBlockStop":{"contentBlockIndex":2}}
|
|
11
|
-
{"metadata":{"usage":{"inputTokens":500,"outputTokens":100,"totalTokens":600}}}
|
|
12
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"type": "text",
|
|
8
|
-
"text": "2 + 2 equals 4."
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"toolUse": {
|
|
12
|
-
"toolUseId": "json-tool-id-123",
|
|
13
|
-
"name": "json",
|
|
14
|
-
"input": {
|
|
15
|
-
"firstName": "John",
|
|
16
|
-
"lastName": "Doe"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"usage": {
|
|
24
|
-
"inputTokens": 156,
|
|
25
|
-
"outputTokens": 35,
|
|
26
|
-
"totalTokens": 191
|
|
27
|
-
},
|
|
28
|
-
"stopReason": "tool_use"
|
|
29
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
{"contentBlockStart":{"contentBlockIndex":0,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"{\"value\":\"test\"}"}}}}
|
|
3
|
-
{"contentBlockStop":{"contentBlockIndex":0}}
|
|
4
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"toolUse": {
|
|
8
|
-
"toolUseId": "json-tool-id",
|
|
9
|
-
"name": "json",
|
|
10
|
-
"input": {
|
|
11
|
-
"elements": [
|
|
12
|
-
{
|
|
13
|
-
"location": "San Francisco",
|
|
14
|
-
"temperature": -5,
|
|
15
|
-
"condition": "snowy"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"location": "London",
|
|
19
|
-
"temperature": 0,
|
|
20
|
-
"condition": "snowy"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"usage": {
|
|
30
|
-
"inputTokens": 15,
|
|
31
|
-
"outputTokens": 42,
|
|
32
|
-
"totalTokens": 57
|
|
33
|
-
},
|
|
34
|
-
"stopReason": "tool_use"
|
|
35
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Let me generate"}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":" that JSON for you."}}}
|
|
3
|
-
{"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
|
|
4
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"value\":\"test\"}"}}}}
|
|
5
|
-
{"contentBlockStop":{"contentBlockIndex":1}}
|
|
6
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"type": "text",
|
|
8
|
-
"text": "Let me generate that JSON for you."
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"toolUse": {
|
|
12
|
-
"toolUseId": "json-tool-id",
|
|
13
|
-
"name": "json",
|
|
14
|
-
"input": {
|
|
15
|
-
"value": "test data"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"usage": {
|
|
23
|
-
"inputTokens": 12,
|
|
24
|
-
"outputTokens": 28,
|
|
25
|
-
"totalTokens": 40
|
|
26
|
-
},
|
|
27
|
-
"stopReason": "tool_use"
|
|
28
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"First text block."}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"text":"Second text block."}}}
|
|
3
|
-
{"contentBlockDelta":{"contentBlockIndex":2,"delta":{"text":"Third block."}}}
|
|
4
|
-
{"contentBlockStart":{"contentBlockIndex":3,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
|
|
5
|
-
{"contentBlockDelta":{"contentBlockIndex":3,"delta":{"toolUse":{"input":"{\"result\":42}"}}}}
|
|
6
|
-
{"contentBlockStop":{"contentBlockIndex":3}}
|
|
7
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"type": "text",
|
|
8
|
-
"text": "First text block."
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"type": "text",
|
|
12
|
-
"text": "Second text block."
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"type": "text",
|
|
16
|
-
"text": "Third text block before JSON."
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"toolUse": {
|
|
20
|
-
"toolUseId": "json-tool-id",
|
|
21
|
-
"name": "json",
|
|
22
|
-
"input": {
|
|
23
|
-
"result": 42
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"usage": {
|
|
31
|
-
"inputTokens": 18,
|
|
32
|
-
"outputTokens": 35,
|
|
33
|
-
"totalTokens": 53
|
|
34
|
-
},
|
|
35
|
-
"stopReason": "tool_use"
|
|
36
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Calling a tool first."}}}
|
|
2
|
-
{"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"tool-1","name":"get-weather"}}}}
|
|
3
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"location\":\"SF\"}"}}}}
|
|
4
|
-
{"contentBlockStop":{"contentBlockIndex":1}}
|
|
5
|
-
{"contentBlockDelta":{"contentBlockIndex":2,"delta":{"text":"Now JSON."}}}
|
|
6
|
-
{"contentBlockStart":{"contentBlockIndex":3,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
|
|
7
|
-
{"contentBlockDelta":{"contentBlockIndex":3,"delta":{"toolUse":{"input":"{\"result\":\"data\"}"}}}}
|
|
8
|
-
{"contentBlockStop":{"contentBlockIndex":3}}
|
|
9
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"type": "text",
|
|
8
|
-
"text": "Let me call a tool first."
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"toolUse": {
|
|
12
|
-
"toolUseId": "tool-1",
|
|
13
|
-
"name": "get-weather",
|
|
14
|
-
"input": {
|
|
15
|
-
"location": "SF"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"type": "text",
|
|
21
|
-
"text": "Now the JSON."
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"toolUse": {
|
|
25
|
-
"toolUseId": "json-tool-id",
|
|
26
|
-
"name": "json",
|
|
27
|
-
"input": {
|
|
28
|
-
"result": "data"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"usage": {
|
|
36
|
-
"inputTokens": 22,
|
|
37
|
-
"outputTokens": 48,
|
|
38
|
-
"totalTokens": 70
|
|
39
|
-
},
|
|
40
|
-
"stopReason": "tool_use"
|
|
41
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Multiple tools."}}}
|
|
2
|
-
{"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"tool-1","name":"tool-a"}}}}
|
|
3
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"a\":\"1\"}"}}}}
|
|
4
|
-
{"contentBlockStop":{"contentBlockIndex":1}}
|
|
5
|
-
{"contentBlockStart":{"contentBlockIndex":2,"start":{"toolUse":{"toolUseId":"tool-2","name":"tool-b"}}}}
|
|
6
|
-
{"contentBlockDelta":{"contentBlockIndex":2,"delta":{"toolUse":{"input":"{\"b\":\"2\"}"}}}}
|
|
7
|
-
{"contentBlockStop":{"contentBlockIndex":2}}
|
|
8
|
-
{"contentBlockDelta":{"contentBlockIndex":3,"delta":{"text":"Final JSON."}}}
|
|
9
|
-
{"contentBlockStart":{"contentBlockIndex":4,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
|
|
10
|
-
{"contentBlockDelta":{"contentBlockIndex":4,"delta":{"toolUse":{"input":"{\"final\":\"result\"}"}}}}
|
|
11
|
-
{"contentBlockStop":{"contentBlockIndex":4}}
|
|
12
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"type": "text",
|
|
8
|
-
"text": "Calling multiple tools."
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"toolUse": {
|
|
12
|
-
"toolUseId": "tool-1",
|
|
13
|
-
"name": "tool-a",
|
|
14
|
-
"input": {
|
|
15
|
-
"param": "a"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"toolUse": {
|
|
21
|
-
"toolUseId": "tool-2",
|
|
22
|
-
"name": "tool-b",
|
|
23
|
-
"input": {
|
|
24
|
-
"param": "b"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"type": "text",
|
|
30
|
-
"text": "Finally the JSON response."
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"toolUse": {
|
|
34
|
-
"toolUseId": "json-tool-id",
|
|
35
|
-
"name": "json",
|
|
36
|
-
"input": {
|
|
37
|
-
"final": "result"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"usage": {
|
|
45
|
-
"inputTokens": 28,
|
|
46
|
-
"outputTokens": 62,
|
|
47
|
-
"totalTokens": 90
|
|
48
|
-
},
|
|
49
|
-
"stopReason": "tool_use"
|
|
50
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"contentBlockStart":{"contentBlockIndex":0,"start":{"toolUse":{"toolUseId":"tool-use-id","name":"test-tool"}}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"{\"value\":"}}}}
|
|
3
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"\"Sparkle Day\"}"}}}}
|
|
4
|
-
{"contentBlockStop":{"contentBlockIndex":0}}
|
|
5
|
-
{"metadata":{"usage":{"inputTokens":125,"outputTokens":45,"totalTokens":170},"metrics":{"latencyMs":234}}}
|
|
6
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"toolUse": {
|
|
8
|
-
"toolUseId": "tool-use-id",
|
|
9
|
-
"name": "bash",
|
|
10
|
-
"input": {
|
|
11
|
-
"command": "ls -l"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"usage": {
|
|
19
|
-
"inputTokens": 10,
|
|
20
|
-
"outputTokens": 20,
|
|
21
|
-
"totalTokens": 30
|
|
22
|
-
},
|
|
23
|
-
"stopReason": "tool_use"
|
|
24
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{"contentBlockStart":{"contentBlockIndex":0,"start":{}}}
|
|
2
|
-
{"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"I'll update the issue list for you."}}}
|
|
3
|
-
{"contentBlockStop":{"contentBlockIndex":0}}
|
|
4
|
-
{"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"tool-use-id","name":"updateIssueList"}}}}
|
|
5
|
-
{"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":""}}}}
|
|
6
|
-
{"contentBlockStop":{"contentBlockIndex":1}}
|
|
7
|
-
{"metadata":{"usage":{"inputTokens":100,"outputTokens":25,"totalTokens":125},"metrics":{"latencyMs":150}}}
|
|
8
|
-
{"messageStop":{"stopReason":"tool_use"}}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"output": {
|
|
3
|
-
"message": {
|
|
4
|
-
"role": "assistant",
|
|
5
|
-
"content": [
|
|
6
|
-
{
|
|
7
|
-
"text": "I'll update the issue list for you."
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"toolUse": {
|
|
11
|
-
"toolUseId": "tool-use-id",
|
|
12
|
-
"name": "updateIssueList",
|
|
13
|
-
"input": {}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"usage": {
|
|
20
|
-
"inputTokens": 100,
|
|
21
|
-
"outputTokens": 25,
|
|
22
|
-
"totalTokens": 125
|
|
23
|
-
},
|
|
24
|
-
"stopReason": "tool_use"
|
|
25
|
-
}
|