@jambonz/llm 0.1.0 → 0.2.1
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 +115 -23
- 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 +115 -23
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +165 -45
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +2 -14
- package/dist/test-kit/index.d.ts +2 -14
- package/dist/test-kit/index.js +165 -45
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-D8rgMCbi.d.cts → types-bq1XMi_T.d.cts} +23 -4
- package/dist/{types-D8rgMCbi.d.ts → types-bq1XMi_T.d.ts} +23 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -224,6 +224,28 @@ async function* streamFromOpenAI(client, req, options) {
|
|
|
224
224
|
};
|
|
225
225
|
yield endEvent;
|
|
226
226
|
}
|
|
227
|
+
function appendOpenAIAssistantToolCall(history, toolCalls) {
|
|
228
|
+
const wireMessage = {
|
|
229
|
+
role: "assistant",
|
|
230
|
+
content: null,
|
|
231
|
+
tool_calls: toolCalls.map((tc) => ({
|
|
232
|
+
id: tc.id,
|
|
233
|
+
type: "function",
|
|
234
|
+
function: {
|
|
235
|
+
name: tc.name,
|
|
236
|
+
arguments: typeof tc.arguments === "string" ? tc.arguments : JSON.stringify(tc.arguments ?? {})
|
|
237
|
+
}
|
|
238
|
+
}))
|
|
239
|
+
};
|
|
240
|
+
return [
|
|
241
|
+
...history,
|
|
242
|
+
{
|
|
243
|
+
role: "assistant",
|
|
244
|
+
content: "",
|
|
245
|
+
vendorRaw: wireMessage
|
|
246
|
+
}
|
|
247
|
+
];
|
|
248
|
+
}
|
|
227
249
|
function appendOpenAIToolResult(history, toolCallId, result) {
|
|
228
250
|
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
229
251
|
const wireMessage = {
|
|
@@ -445,6 +467,9 @@ var OpenAIAdapter = class {
|
|
|
445
467
|
knownModels: openAIManifest.knownModels
|
|
446
468
|
});
|
|
447
469
|
}
|
|
470
|
+
appendAssistantToolCall(history, toolCalls) {
|
|
471
|
+
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
472
|
+
}
|
|
448
473
|
appendToolResult(history, toolCallId, result) {
|
|
449
474
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
450
475
|
}
|
|
@@ -795,6 +820,25 @@ var AnthropicAdapter = class {
|
|
|
795
820
|
};
|
|
796
821
|
yield endEvent;
|
|
797
822
|
}
|
|
823
|
+
appendAssistantToolCall(history, toolCalls) {
|
|
824
|
+
const wireMessage = {
|
|
825
|
+
role: "assistant",
|
|
826
|
+
content: toolCalls.map((tc) => ({
|
|
827
|
+
type: "tool_use",
|
|
828
|
+
id: tc.id,
|
|
829
|
+
name: tc.name,
|
|
830
|
+
input: tc.arguments ?? {}
|
|
831
|
+
}))
|
|
832
|
+
};
|
|
833
|
+
return [
|
|
834
|
+
...history,
|
|
835
|
+
{
|
|
836
|
+
role: "assistant",
|
|
837
|
+
content: "",
|
|
838
|
+
vendorRaw: wireMessage
|
|
839
|
+
}
|
|
840
|
+
];
|
|
841
|
+
}
|
|
798
842
|
appendToolResult(history, toolCallId, result) {
|
|
799
843
|
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
800
844
|
const wireMessage = {
|
|
@@ -1010,6 +1054,25 @@ async function* streamFromGemini(client, req) {
|
|
|
1010
1054
|
};
|
|
1011
1055
|
yield endEvent;
|
|
1012
1056
|
}
|
|
1057
|
+
function appendGeminiAssistantToolCall(history, toolCalls) {
|
|
1058
|
+
const wireMessage = {
|
|
1059
|
+
role: "model",
|
|
1060
|
+
parts: toolCalls.map((tc) => ({
|
|
1061
|
+
functionCall: {
|
|
1062
|
+
name: parseToolName(tc.id),
|
|
1063
|
+
args: tc.arguments ?? {}
|
|
1064
|
+
}
|
|
1065
|
+
}))
|
|
1066
|
+
};
|
|
1067
|
+
return [
|
|
1068
|
+
...history,
|
|
1069
|
+
{
|
|
1070
|
+
role: "assistant",
|
|
1071
|
+
content: "",
|
|
1072
|
+
vendorRaw: wireMessage
|
|
1073
|
+
}
|
|
1074
|
+
];
|
|
1075
|
+
}
|
|
1013
1076
|
function appendGeminiToolResult(history, toolCallId, result) {
|
|
1014
1077
|
const name = parseToolName(toolCallId);
|
|
1015
1078
|
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
@@ -1232,6 +1295,9 @@ var GoogleAdapter = class {
|
|
|
1232
1295
|
stream(req) {
|
|
1233
1296
|
return streamFromGemini(this.ensureClient(), req);
|
|
1234
1297
|
}
|
|
1298
|
+
appendAssistantToolCall(history, toolCalls) {
|
|
1299
|
+
return appendGeminiAssistantToolCall(history, toolCalls);
|
|
1300
|
+
}
|
|
1235
1301
|
appendToolResult(history, toolCallId, result) {
|
|
1236
1302
|
return appendGeminiToolResult(history, toolCallId, result);
|
|
1237
1303
|
}
|
|
@@ -1399,6 +1465,9 @@ var VertexGeminiAdapter = class {
|
|
|
1399
1465
|
stream(req) {
|
|
1400
1466
|
return streamFromGemini(this.ensureClient(), req);
|
|
1401
1467
|
}
|
|
1468
|
+
appendAssistantToolCall(history, toolCalls) {
|
|
1469
|
+
return appendGeminiAssistantToolCall(history, toolCalls);
|
|
1470
|
+
}
|
|
1402
1471
|
appendToolResult(history, toolCallId, result) {
|
|
1403
1472
|
return appendGeminiToolResult(history, toolCallId, result);
|
|
1404
1473
|
}
|
|
@@ -1565,6 +1634,9 @@ var VertexOpenAIAdapter = class {
|
|
|
1565
1634
|
knownModels: vertexOpenAIManifest.knownModels
|
|
1566
1635
|
});
|
|
1567
1636
|
}
|
|
1637
|
+
appendAssistantToolCall(history, toolCalls) {
|
|
1638
|
+
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
1639
|
+
}
|
|
1568
1640
|
appendToolResult(history, toolCallId, result) {
|
|
1569
1641
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
1570
1642
|
}
|
|
@@ -1596,30 +1668,30 @@ var import_client_bedrock_runtime = require("@aws-sdk/client-bedrock-runtime");
|
|
|
1596
1668
|
// src/adapters/bedrock/manifest.ts
|
|
1597
1669
|
var BEDROCK_KNOWN_MODELS = [
|
|
1598
1670
|
{
|
|
1599
|
-
id: "anthropic.claude-
|
|
1600
|
-
displayName: "Claude
|
|
1671
|
+
id: "anthropic.claude-3-haiku-20240307-v1:0",
|
|
1672
|
+
displayName: "Claude 3 Haiku (on Bedrock)",
|
|
1601
1673
|
capabilities: {
|
|
1602
1674
|
streaming: true,
|
|
1603
1675
|
tools: true,
|
|
1604
|
-
vision:
|
|
1676
|
+
vision: false,
|
|
1605
1677
|
systemPrompt: true,
|
|
1606
1678
|
maxContextTokens: 2e5
|
|
1607
1679
|
}
|
|
1608
1680
|
},
|
|
1609
1681
|
{
|
|
1610
|
-
id: "anthropic.claude-
|
|
1611
|
-
displayName: "Claude
|
|
1682
|
+
id: "anthropic.claude-3-5-haiku-20241022-v1:0",
|
|
1683
|
+
displayName: "Claude 3.5 Haiku (on Bedrock)",
|
|
1612
1684
|
capabilities: {
|
|
1613
1685
|
streaming: true,
|
|
1614
1686
|
tools: true,
|
|
1615
|
-
vision:
|
|
1687
|
+
vision: false,
|
|
1616
1688
|
systemPrompt: true,
|
|
1617
1689
|
maxContextTokens: 2e5
|
|
1618
1690
|
}
|
|
1619
1691
|
},
|
|
1620
1692
|
{
|
|
1621
|
-
id: "anthropic.claude-3-
|
|
1622
|
-
displayName: "Claude 3.
|
|
1693
|
+
id: "anthropic.claude-3-5-sonnet-20240620-v1:0",
|
|
1694
|
+
displayName: "Claude 3.5 Sonnet (on Bedrock)",
|
|
1623
1695
|
capabilities: {
|
|
1624
1696
|
streaming: true,
|
|
1625
1697
|
tools: true,
|
|
@@ -1640,19 +1712,19 @@ var BEDROCK_KNOWN_MODELS = [
|
|
|
1640
1712
|
}
|
|
1641
1713
|
},
|
|
1642
1714
|
{
|
|
1643
|
-
id: "anthropic.claude-3-
|
|
1644
|
-
displayName: "Claude 3.
|
|
1715
|
+
id: "anthropic.claude-3-7-sonnet-20250219-v1:0",
|
|
1716
|
+
displayName: "Claude 3.7 Sonnet (on Bedrock)",
|
|
1645
1717
|
capabilities: {
|
|
1646
1718
|
streaming: true,
|
|
1647
1719
|
tools: true,
|
|
1648
|
-
vision:
|
|
1720
|
+
vision: true,
|
|
1649
1721
|
systemPrompt: true,
|
|
1650
1722
|
maxContextTokens: 2e5
|
|
1651
1723
|
}
|
|
1652
1724
|
},
|
|
1653
1725
|
{
|
|
1654
|
-
id: "
|
|
1655
|
-
displayName: "
|
|
1726
|
+
id: "amazon.nova-micro-v1:0",
|
|
1727
|
+
displayName: "Amazon Nova Micro",
|
|
1656
1728
|
capabilities: {
|
|
1657
1729
|
streaming: true,
|
|
1658
1730
|
tools: true,
|
|
@@ -1662,14 +1734,14 @@ var BEDROCK_KNOWN_MODELS = [
|
|
|
1662
1734
|
}
|
|
1663
1735
|
},
|
|
1664
1736
|
{
|
|
1665
|
-
id: "
|
|
1666
|
-
displayName: "
|
|
1737
|
+
id: "amazon.nova-lite-v1:0",
|
|
1738
|
+
displayName: "Amazon Nova Lite",
|
|
1667
1739
|
capabilities: {
|
|
1668
1740
|
streaming: true,
|
|
1669
1741
|
tools: true,
|
|
1670
|
-
vision:
|
|
1742
|
+
vision: true,
|
|
1671
1743
|
systemPrompt: true,
|
|
1672
|
-
maxContextTokens:
|
|
1744
|
+
maxContextTokens: 3e5
|
|
1673
1745
|
}
|
|
1674
1746
|
},
|
|
1675
1747
|
{
|
|
@@ -1684,19 +1756,19 @@ var BEDROCK_KNOWN_MODELS = [
|
|
|
1684
1756
|
}
|
|
1685
1757
|
},
|
|
1686
1758
|
{
|
|
1687
|
-
id: "
|
|
1688
|
-
displayName: "
|
|
1759
|
+
id: "meta.llama3-3-70b-instruct-v1:0",
|
|
1760
|
+
displayName: "Llama 3.3 70B Instruct (on Bedrock)",
|
|
1689
1761
|
capabilities: {
|
|
1690
1762
|
streaming: true,
|
|
1691
1763
|
tools: true,
|
|
1692
|
-
vision:
|
|
1764
|
+
vision: false,
|
|
1693
1765
|
systemPrompt: true,
|
|
1694
|
-
maxContextTokens:
|
|
1766
|
+
maxContextTokens: 128e3
|
|
1695
1767
|
}
|
|
1696
1768
|
},
|
|
1697
1769
|
{
|
|
1698
|
-
id: "
|
|
1699
|
-
displayName: "
|
|
1770
|
+
id: "mistral.mistral-large-2407-v1:0",
|
|
1771
|
+
displayName: "Mistral Large (on Bedrock)",
|
|
1700
1772
|
capabilities: {
|
|
1701
1773
|
streaming: true,
|
|
1702
1774
|
tools: true,
|
|
@@ -1954,6 +2026,26 @@ var BedrockAdapter = class {
|
|
|
1954
2026
|
};
|
|
1955
2027
|
yield endEvent;
|
|
1956
2028
|
}
|
|
2029
|
+
appendAssistantToolCall(history, toolCalls) {
|
|
2030
|
+
const wireMessage = {
|
|
2031
|
+
role: "assistant",
|
|
2032
|
+
content: toolCalls.map((tc) => ({
|
|
2033
|
+
toolUse: {
|
|
2034
|
+
toolUseId: tc.id,
|
|
2035
|
+
name: tc.name,
|
|
2036
|
+
input: tc.arguments ?? {}
|
|
2037
|
+
}
|
|
2038
|
+
}))
|
|
2039
|
+
};
|
|
2040
|
+
return [
|
|
2041
|
+
...history,
|
|
2042
|
+
{
|
|
2043
|
+
role: "assistant",
|
|
2044
|
+
content: "",
|
|
2045
|
+
vendorRaw: wireMessage
|
|
2046
|
+
}
|
|
2047
|
+
];
|
|
2048
|
+
}
|
|
1957
2049
|
appendToolResult(history, toolCallId, result) {
|
|
1958
2050
|
const text = typeof result === "string" ? result : JSON.stringify(result);
|
|
1959
2051
|
const wireMessage = {
|