@ai-sdk/amazon-bedrock 4.0.24 → 4.0.26
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 +1 -1
- package/dist/index.mjs +1 -1
- package/docs/08-amazon-bedrock.mdx +1453 -0
- package/package.json +11 -6
- package/src/__fixtures__/bedrock-json-only-text-first.1.chunks.txt +7 -0
- package/src/__fixtures__/bedrock-json-other-tool.1.chunks.txt +6 -0
- package/src/__fixtures__/bedrock-json-other-tool.1.json +24 -0
- package/src/__fixtures__/bedrock-json-tool-text-then-weather-then-json.1.chunks.txt +12 -0
- package/src/__fixtures__/bedrock-json-tool-with-answer.1.json +29 -0
- package/src/__fixtures__/bedrock-json-tool.1.chunks.txt +4 -0
- package/src/__fixtures__/bedrock-json-tool.1.json +35 -0
- package/src/__fixtures__/bedrock-json-tool.2.chunks.txt +6 -0
- package/src/__fixtures__/bedrock-json-tool.2.json +28 -0
- package/src/__fixtures__/bedrock-json-tool.3.chunks.txt +7 -0
- package/src/__fixtures__/bedrock-json-tool.3.json +36 -0
- package/src/__fixtures__/bedrock-json-with-tool.1.chunks.txt +9 -0
- package/src/__fixtures__/bedrock-json-with-tool.1.json +41 -0
- package/src/__fixtures__/bedrock-json-with-tools.1.chunks.txt +12 -0
- package/src/__fixtures__/bedrock-json-with-tools.1.json +50 -0
- package/src/__fixtures__/bedrock-tool-call.1.chunks.txt +6 -0
- package/src/__fixtures__/bedrock-tool-call.1.json +24 -0
- package/src/__fixtures__/bedrock-tool-no-args.chunks.txt +8 -0
- package/src/__fixtures__/bedrock-tool-no-args.json +25 -0
- package/src/anthropic/bedrock-anthropic-fetch.test.ts +344 -0
- package/src/anthropic/bedrock-anthropic-fetch.ts +62 -0
- package/src/anthropic/bedrock-anthropic-options.ts +28 -0
- package/src/anthropic/bedrock-anthropic-provider.test.ts +456 -0
- package/src/anthropic/bedrock-anthropic-provider.ts +357 -0
- package/src/anthropic/index.ts +9 -0
- package/src/bedrock-api-types.ts +195 -0
- package/src/bedrock-chat-language-model.test.ts +4569 -0
- package/src/bedrock-chat-language-model.ts +1019 -0
- package/src/bedrock-chat-options.ts +114 -0
- package/src/bedrock-embedding-model.test.ts +148 -0
- package/src/bedrock-embedding-model.ts +104 -0
- package/src/bedrock-embedding-options.ts +24 -0
- package/src/bedrock-error.ts +6 -0
- package/src/bedrock-event-stream-decoder.ts +59 -0
- package/src/bedrock-event-stream-response-handler.test.ts +233 -0
- package/src/bedrock-event-stream-response-handler.ts +57 -0
- package/src/bedrock-image-model.test.ts +866 -0
- package/src/bedrock-image-model.ts +297 -0
- package/src/bedrock-image-settings.ts +6 -0
- package/src/bedrock-prepare-tools.ts +190 -0
- package/src/bedrock-provider.test.ts +457 -0
- package/src/bedrock-provider.ts +351 -0
- package/src/bedrock-sigv4-fetch.test.ts +675 -0
- package/src/bedrock-sigv4-fetch.ts +138 -0
- package/src/convert-bedrock-usage.test.ts +207 -0
- package/src/convert-bedrock-usage.ts +50 -0
- package/src/convert-to-bedrock-chat-messages.test.ts +1175 -0
- package/src/convert-to-bedrock-chat-messages.ts +452 -0
- package/src/index.ts +10 -0
- package/src/inject-fetch-headers.test.ts +135 -0
- package/src/inject-fetch-headers.ts +32 -0
- package/src/map-bedrock-finish-reason.ts +22 -0
- package/src/normalize-tool-call-id.test.ts +72 -0
- package/src/normalize-tool-call-id.ts +36 -0
- package/src/reranking/__fixtures__/bedrock-reranking.1.json +12 -0
- package/src/reranking/bedrock-reranking-api.ts +44 -0
- package/src/reranking/bedrock-reranking-model.test.ts +299 -0
- package/src/reranking/bedrock-reranking-model.ts +115 -0
- package/src/reranking/bedrock-reranking-options.ts +36 -0
- package/src/version.ts +6 -0
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.26",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,10 +8,15 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
11
|
+
"docs/**/*",
|
|
12
|
+
"src",
|
|
11
13
|
"CHANGELOG.md",
|
|
12
14
|
"README.md",
|
|
13
15
|
"anthropic/index.d.ts"
|
|
14
16
|
],
|
|
17
|
+
"directories": {
|
|
18
|
+
"doc": "./docs"
|
|
19
|
+
},
|
|
15
20
|
"exports": {
|
|
16
21
|
"./package.json": "./package.json",
|
|
17
22
|
".": {
|
|
@@ -29,16 +34,16 @@
|
|
|
29
34
|
"@smithy/eventstream-codec": "^4.0.1",
|
|
30
35
|
"@smithy/util-utf8": "^4.0.0",
|
|
31
36
|
"aws4fetch": "^1.0.20",
|
|
32
|
-
"@ai-sdk/anthropic": "3.0.
|
|
33
|
-
"@ai-sdk/provider
|
|
34
|
-
"@ai-sdk/provider": "
|
|
37
|
+
"@ai-sdk/anthropic": "3.0.20",
|
|
38
|
+
"@ai-sdk/provider": "3.0.4",
|
|
39
|
+
"@ai-sdk/provider-utils": "4.0.8"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
42
|
"@types/node": "20.17.24",
|
|
38
43
|
"tsup": "^8.3.0",
|
|
39
44
|
"typescript": "5.8.3",
|
|
40
45
|
"zod": "3.25.76",
|
|
41
|
-
"@ai-sdk/test-server": "1.0.
|
|
46
|
+
"@ai-sdk/test-server": "1.0.2",
|
|
42
47
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
43
48
|
},
|
|
44
49
|
"peerDependencies": {
|
|
@@ -64,7 +69,7 @@
|
|
|
64
69
|
"scripts": {
|
|
65
70
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
66
71
|
"build:watch": "pnpm clean && tsup --watch",
|
|
67
|
-
"clean": "del-cli dist *.tsbuildinfo",
|
|
72
|
+
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
68
73
|
"lint": "eslint \"./**/*.ts*\"",
|
|
69
74
|
"type-check": "tsc --build",
|
|
70
75
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
@@ -0,0 +1,7 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,6 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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"}}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|