@jambonz/llm 0.6.2 → 0.6.3
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/dist/index.cjs +51 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +51 -38
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +104 -40
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +2 -2
- package/dist/test-kit/index.d.ts +2 -2
- package/dist/test-kit/index.js +104 -40
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-Y0o6rN3B.d.cts → types-dbgrfviJ.d.cts} +7 -1
- package/dist/{types-Y0o6rN3B.d.ts → types-dbgrfviJ.d.ts} +7 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -284,10 +284,11 @@ async function* streamFromOpenAI(client, req, options) {
|
|
|
284
284
|
}
|
|
285
285
|
yield endEvent;
|
|
286
286
|
}
|
|
287
|
-
function appendOpenAIAssistantToolCall(history, toolCalls) {
|
|
287
|
+
function appendOpenAIAssistantToolCall(history, toolCalls, assistantText) {
|
|
288
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
288
289
|
const wireMessage = {
|
|
289
290
|
role: "assistant",
|
|
290
|
-
content:
|
|
291
|
+
content: text,
|
|
291
292
|
tool_calls: toolCalls.map((tc) => ({
|
|
292
293
|
id: tc.id,
|
|
293
294
|
type: "function",
|
|
@@ -301,7 +302,7 @@ function appendOpenAIAssistantToolCall(history, toolCalls) {
|
|
|
301
302
|
...history,
|
|
302
303
|
{
|
|
303
304
|
role: "assistant",
|
|
304
|
-
content: "",
|
|
305
|
+
content: text ?? "",
|
|
305
306
|
vendorRaw: wireMessage
|
|
306
307
|
}
|
|
307
308
|
];
|
|
@@ -572,8 +573,8 @@ var OpenAIAdapter = class {
|
|
|
572
573
|
includeCacheKey: this.forwardCacheKey()
|
|
573
574
|
});
|
|
574
575
|
}
|
|
575
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
576
|
-
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
576
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
577
|
+
return appendOpenAIAssistantToolCall(history, toolCalls, assistantText);
|
|
577
578
|
}
|
|
578
579
|
appendToolResult(history, toolCallId, result) {
|
|
579
580
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
@@ -1539,21 +1540,25 @@ var AnthropicAdapter = class {
|
|
|
1539
1540
|
}
|
|
1540
1541
|
yield endEvent;
|
|
1541
1542
|
}
|
|
1542
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
1543
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
1544
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
1543
1545
|
const wireMessage = {
|
|
1544
1546
|
role: "assistant",
|
|
1545
|
-
content:
|
|
1546
|
-
type: "
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1547
|
+
content: [
|
|
1548
|
+
...text ? [{ type: "text", text }] : [],
|
|
1549
|
+
...toolCalls.map((tc) => ({
|
|
1550
|
+
type: "tool_use",
|
|
1551
|
+
id: tc.id,
|
|
1552
|
+
name: tc.name,
|
|
1553
|
+
input: tc.arguments ?? {}
|
|
1554
|
+
}))
|
|
1555
|
+
]
|
|
1551
1556
|
};
|
|
1552
1557
|
return [
|
|
1553
1558
|
...history,
|
|
1554
1559
|
{
|
|
1555
1560
|
role: "assistant",
|
|
1556
|
-
content: "",
|
|
1561
|
+
content: text ?? "",
|
|
1557
1562
|
vendorRaw: wireMessage
|
|
1558
1563
|
}
|
|
1559
1564
|
];
|
|
@@ -1805,21 +1810,25 @@ async function* streamFromGemini(client, req) {
|
|
|
1805
1810
|
};
|
|
1806
1811
|
yield endEvent;
|
|
1807
1812
|
}
|
|
1808
|
-
function appendGeminiAssistantToolCall(history, toolCalls) {
|
|
1813
|
+
function appendGeminiAssistantToolCall(history, toolCalls, assistantText) {
|
|
1814
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
1809
1815
|
const wireMessage = {
|
|
1810
1816
|
role: "model",
|
|
1811
|
-
parts:
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
+
parts: [
|
|
1818
|
+
...text ? [{ text }] : [],
|
|
1819
|
+
...toolCalls.map((tc) => ({
|
|
1820
|
+
functionCall: {
|
|
1821
|
+
name: parseToolName(tc.id),
|
|
1822
|
+
args: tc.arguments ?? {}
|
|
1823
|
+
}
|
|
1824
|
+
}))
|
|
1825
|
+
]
|
|
1817
1826
|
};
|
|
1818
1827
|
return [
|
|
1819
1828
|
...history,
|
|
1820
1829
|
{
|
|
1821
1830
|
role: "assistant",
|
|
1822
|
-
content: "",
|
|
1831
|
+
content: text ?? "",
|
|
1823
1832
|
vendorRaw: wireMessage
|
|
1824
1833
|
}
|
|
1825
1834
|
];
|
|
@@ -2079,8 +2088,8 @@ var GoogleAdapter = class {
|
|
|
2079
2088
|
stream(req) {
|
|
2080
2089
|
return streamFromGemini(this.ensureClient(), req);
|
|
2081
2090
|
}
|
|
2082
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2083
|
-
return appendGeminiAssistantToolCall(history, toolCalls);
|
|
2091
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2092
|
+
return appendGeminiAssistantToolCall(history, toolCalls, assistantText);
|
|
2084
2093
|
}
|
|
2085
2094
|
appendToolResult(history, toolCallId, result) {
|
|
2086
2095
|
return appendGeminiToolResult(history, toolCallId, result);
|
|
@@ -2285,8 +2294,8 @@ var VertexGeminiAdapter = class {
|
|
|
2285
2294
|
stream(req) {
|
|
2286
2295
|
return streamFromGemini(this.ensureClient(), req);
|
|
2287
2296
|
}
|
|
2288
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2289
|
-
return appendGeminiAssistantToolCall(history, toolCalls);
|
|
2297
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2298
|
+
return appendGeminiAssistantToolCall(history, toolCalls, assistantText);
|
|
2290
2299
|
}
|
|
2291
2300
|
appendToolResult(history, toolCallId, result) {
|
|
2292
2301
|
return appendGeminiToolResult(history, toolCallId, result);
|
|
@@ -2483,8 +2492,8 @@ var VertexOpenAIAdapter = class {
|
|
|
2483
2492
|
vendorMetadataExtractor: VERTEX_OPENAI_METADATA_EXTRACTOR
|
|
2484
2493
|
});
|
|
2485
2494
|
}
|
|
2486
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2487
|
-
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
2495
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2496
|
+
return appendOpenAIAssistantToolCall(history, toolCalls, assistantText);
|
|
2488
2497
|
}
|
|
2489
2498
|
appendToolResult(history, toolCallId, result) {
|
|
2490
2499
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
@@ -2970,22 +2979,26 @@ var BedrockAdapter = class {
|
|
|
2970
2979
|
}
|
|
2971
2980
|
yield endEvent;
|
|
2972
2981
|
}
|
|
2973
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2982
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2983
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
2974
2984
|
const wireMessage = {
|
|
2975
2985
|
role: "assistant",
|
|
2976
|
-
content:
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2986
|
+
content: [
|
|
2987
|
+
...text ? [{ text }] : [],
|
|
2988
|
+
...toolCalls.map((tc) => ({
|
|
2989
|
+
toolUse: {
|
|
2990
|
+
toolUseId: tc.id,
|
|
2991
|
+
name: tc.name,
|
|
2992
|
+
input: tc.arguments ?? {}
|
|
2993
|
+
}
|
|
2994
|
+
}))
|
|
2995
|
+
]
|
|
2983
2996
|
};
|
|
2984
2997
|
return [
|
|
2985
2998
|
...history,
|
|
2986
2999
|
{
|
|
2987
3000
|
role: "assistant",
|
|
2988
|
-
content: "",
|
|
3001
|
+
content: text ?? "",
|
|
2989
3002
|
vendorRaw: wireMessage
|
|
2990
3003
|
}
|
|
2991
3004
|
];
|
|
@@ -3275,8 +3288,8 @@ var AzureOpenAIAdapter = class {
|
|
|
3275
3288
|
vendorMetadataExtractor: AZURE_OPENAI_METADATA_EXTRACTOR
|
|
3276
3289
|
});
|
|
3277
3290
|
}
|
|
3278
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
3279
|
-
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
3291
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
3292
|
+
return appendOpenAIAssistantToolCall(history, toolCalls, assistantText);
|
|
3280
3293
|
}
|
|
3281
3294
|
appendToolResult(history, toolCallId, result) {
|
|
3282
3295
|
return appendOpenAIToolResult(history, toolCallId, result);
|