@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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-D8rgMCbi.cjs';
2
- export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, U as Usage, V as VertexServiceAccountAuth } from './types-D8rgMCbi.cjs';
1
+ import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-bq1XMi_T.cjs';
2
+ export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, o as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-bq1XMi_T.cjs';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-D8rgMCbi.js';
2
- export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, U as Usage, V as VertexServiceAccountAuth } from './types-D8rgMCbi.js';
1
+ import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-bq1XMi_T.js';
2
+ export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, o as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-bq1XMi_T.js';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
package/dist/index.js CHANGED
@@ -180,6 +180,28 @@ async function* streamFromOpenAI(client, req, options) {
180
180
  };
181
181
  yield endEvent;
182
182
  }
183
+ function appendOpenAIAssistantToolCall(history, toolCalls) {
184
+ const wireMessage = {
185
+ role: "assistant",
186
+ content: null,
187
+ tool_calls: toolCalls.map((tc) => ({
188
+ id: tc.id,
189
+ type: "function",
190
+ function: {
191
+ name: tc.name,
192
+ arguments: typeof tc.arguments === "string" ? tc.arguments : JSON.stringify(tc.arguments ?? {})
193
+ }
194
+ }))
195
+ };
196
+ return [
197
+ ...history,
198
+ {
199
+ role: "assistant",
200
+ content: "",
201
+ vendorRaw: wireMessage
202
+ }
203
+ ];
204
+ }
183
205
  function appendOpenAIToolResult(history, toolCallId, result) {
184
206
  const content = typeof result === "string" ? result : JSON.stringify(result);
185
207
  const wireMessage = {
@@ -401,6 +423,9 @@ var OpenAIAdapter = class {
401
423
  knownModels: openAIManifest.knownModels
402
424
  });
403
425
  }
426
+ appendAssistantToolCall(history, toolCalls) {
427
+ return appendOpenAIAssistantToolCall(history, toolCalls);
428
+ }
404
429
  appendToolResult(history, toolCallId, result) {
405
430
  return appendOpenAIToolResult(history, toolCallId, result);
406
431
  }
@@ -751,6 +776,25 @@ var AnthropicAdapter = class {
751
776
  };
752
777
  yield endEvent;
753
778
  }
779
+ appendAssistantToolCall(history, toolCalls) {
780
+ const wireMessage = {
781
+ role: "assistant",
782
+ content: toolCalls.map((tc) => ({
783
+ type: "tool_use",
784
+ id: tc.id,
785
+ name: tc.name,
786
+ input: tc.arguments ?? {}
787
+ }))
788
+ };
789
+ return [
790
+ ...history,
791
+ {
792
+ role: "assistant",
793
+ content: "",
794
+ vendorRaw: wireMessage
795
+ }
796
+ ];
797
+ }
754
798
  appendToolResult(history, toolCallId, result) {
755
799
  const content = typeof result === "string" ? result : JSON.stringify(result);
756
800
  const wireMessage = {
@@ -966,6 +1010,25 @@ async function* streamFromGemini(client, req) {
966
1010
  };
967
1011
  yield endEvent;
968
1012
  }
1013
+ function appendGeminiAssistantToolCall(history, toolCalls) {
1014
+ const wireMessage = {
1015
+ role: "model",
1016
+ parts: toolCalls.map((tc) => ({
1017
+ functionCall: {
1018
+ name: parseToolName(tc.id),
1019
+ args: tc.arguments ?? {}
1020
+ }
1021
+ }))
1022
+ };
1023
+ return [
1024
+ ...history,
1025
+ {
1026
+ role: "assistant",
1027
+ content: "",
1028
+ vendorRaw: wireMessage
1029
+ }
1030
+ ];
1031
+ }
969
1032
  function appendGeminiToolResult(history, toolCallId, result) {
970
1033
  const name = parseToolName(toolCallId);
971
1034
  const content = typeof result === "string" ? result : JSON.stringify(result);
@@ -1188,6 +1251,9 @@ var GoogleAdapter = class {
1188
1251
  stream(req) {
1189
1252
  return streamFromGemini(this.ensureClient(), req);
1190
1253
  }
1254
+ appendAssistantToolCall(history, toolCalls) {
1255
+ return appendGeminiAssistantToolCall(history, toolCalls);
1256
+ }
1191
1257
  appendToolResult(history, toolCallId, result) {
1192
1258
  return appendGeminiToolResult(history, toolCallId, result);
1193
1259
  }
@@ -1355,6 +1421,9 @@ var VertexGeminiAdapter = class {
1355
1421
  stream(req) {
1356
1422
  return streamFromGemini(this.ensureClient(), req);
1357
1423
  }
1424
+ appendAssistantToolCall(history, toolCalls) {
1425
+ return appendGeminiAssistantToolCall(history, toolCalls);
1426
+ }
1358
1427
  appendToolResult(history, toolCallId, result) {
1359
1428
  return appendGeminiToolResult(history, toolCallId, result);
1360
1429
  }
@@ -1521,6 +1590,9 @@ var VertexOpenAIAdapter = class {
1521
1590
  knownModels: vertexOpenAIManifest.knownModels
1522
1591
  });
1523
1592
  }
1593
+ appendAssistantToolCall(history, toolCalls) {
1594
+ return appendOpenAIAssistantToolCall(history, toolCalls);
1595
+ }
1524
1596
  appendToolResult(history, toolCallId, result) {
1525
1597
  return appendOpenAIToolResult(history, toolCallId, result);
1526
1598
  }
@@ -1555,30 +1627,30 @@ import {
1555
1627
  // src/adapters/bedrock/manifest.ts
1556
1628
  var BEDROCK_KNOWN_MODELS = [
1557
1629
  {
1558
- id: "anthropic.claude-opus-4-v1:0",
1559
- displayName: "Claude Opus 4 (on Bedrock)",
1630
+ id: "anthropic.claude-3-haiku-20240307-v1:0",
1631
+ displayName: "Claude 3 Haiku (on Bedrock)",
1560
1632
  capabilities: {
1561
1633
  streaming: true,
1562
1634
  tools: true,
1563
- vision: true,
1635
+ vision: false,
1564
1636
  systemPrompt: true,
1565
1637
  maxContextTokens: 2e5
1566
1638
  }
1567
1639
  },
1568
1640
  {
1569
- id: "anthropic.claude-sonnet-4-v1:0",
1570
- displayName: "Claude Sonnet 4 (on Bedrock)",
1641
+ id: "anthropic.claude-3-5-haiku-20241022-v1:0",
1642
+ displayName: "Claude 3.5 Haiku (on Bedrock)",
1571
1643
  capabilities: {
1572
1644
  streaming: true,
1573
1645
  tools: true,
1574
- vision: true,
1646
+ vision: false,
1575
1647
  systemPrompt: true,
1576
1648
  maxContextTokens: 2e5
1577
1649
  }
1578
1650
  },
1579
1651
  {
1580
- id: "anthropic.claude-3-7-sonnet-20250219-v1:0",
1581
- displayName: "Claude 3.7 Sonnet (on Bedrock)",
1652
+ id: "anthropic.claude-3-5-sonnet-20240620-v1:0",
1653
+ displayName: "Claude 3.5 Sonnet (on Bedrock)",
1582
1654
  capabilities: {
1583
1655
  streaming: true,
1584
1656
  tools: true,
@@ -1599,19 +1671,19 @@ var BEDROCK_KNOWN_MODELS = [
1599
1671
  }
1600
1672
  },
1601
1673
  {
1602
- id: "anthropic.claude-3-5-haiku-20241022-v1:0",
1603
- displayName: "Claude 3.5 Haiku (on Bedrock)",
1674
+ id: "anthropic.claude-3-7-sonnet-20250219-v1:0",
1675
+ displayName: "Claude 3.7 Sonnet (on Bedrock)",
1604
1676
  capabilities: {
1605
1677
  streaming: true,
1606
1678
  tools: true,
1607
- vision: false,
1679
+ vision: true,
1608
1680
  systemPrompt: true,
1609
1681
  maxContextTokens: 2e5
1610
1682
  }
1611
1683
  },
1612
1684
  {
1613
- id: "meta.llama3-3-70b-instruct-v1:0",
1614
- displayName: "Llama 3.3 70B Instruct (on Bedrock)",
1685
+ id: "amazon.nova-micro-v1:0",
1686
+ displayName: "Amazon Nova Micro",
1615
1687
  capabilities: {
1616
1688
  streaming: true,
1617
1689
  tools: true,
@@ -1621,14 +1693,14 @@ var BEDROCK_KNOWN_MODELS = [
1621
1693
  }
1622
1694
  },
1623
1695
  {
1624
- id: "mistral.mistral-large-2407-v1:0",
1625
- displayName: "Mistral Large (on Bedrock)",
1696
+ id: "amazon.nova-lite-v1:0",
1697
+ displayName: "Amazon Nova Lite",
1626
1698
  capabilities: {
1627
1699
  streaming: true,
1628
1700
  tools: true,
1629
- vision: false,
1701
+ vision: true,
1630
1702
  systemPrompt: true,
1631
- maxContextTokens: 128e3
1703
+ maxContextTokens: 3e5
1632
1704
  }
1633
1705
  },
1634
1706
  {
@@ -1643,19 +1715,19 @@ var BEDROCK_KNOWN_MODELS = [
1643
1715
  }
1644
1716
  },
1645
1717
  {
1646
- id: "amazon.nova-lite-v1:0",
1647
- displayName: "Amazon Nova Lite",
1718
+ id: "meta.llama3-3-70b-instruct-v1:0",
1719
+ displayName: "Llama 3.3 70B Instruct (on Bedrock)",
1648
1720
  capabilities: {
1649
1721
  streaming: true,
1650
1722
  tools: true,
1651
- vision: true,
1723
+ vision: false,
1652
1724
  systemPrompt: true,
1653
- maxContextTokens: 3e5
1725
+ maxContextTokens: 128e3
1654
1726
  }
1655
1727
  },
1656
1728
  {
1657
- id: "amazon.nova-micro-v1:0",
1658
- displayName: "Amazon Nova Micro",
1729
+ id: "mistral.mistral-large-2407-v1:0",
1730
+ displayName: "Mistral Large (on Bedrock)",
1659
1731
  capabilities: {
1660
1732
  streaming: true,
1661
1733
  tools: true,
@@ -1913,6 +1985,26 @@ var BedrockAdapter = class {
1913
1985
  };
1914
1986
  yield endEvent;
1915
1987
  }
1988
+ appendAssistantToolCall(history, toolCalls) {
1989
+ const wireMessage = {
1990
+ role: "assistant",
1991
+ content: toolCalls.map((tc) => ({
1992
+ toolUse: {
1993
+ toolUseId: tc.id,
1994
+ name: tc.name,
1995
+ input: tc.arguments ?? {}
1996
+ }
1997
+ }))
1998
+ };
1999
+ return [
2000
+ ...history,
2001
+ {
2002
+ role: "assistant",
2003
+ content: "",
2004
+ vendorRaw: wireMessage
2005
+ }
2006
+ ];
2007
+ }
1916
2008
  appendToolResult(history, toolCallId, result) {
1917
2009
  const text = typeof result === "string" ? result : JSON.stringify(result);
1918
2010
  const wireMessage = {