@jambonz/llm 0.1.0 → 0.2.0
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 +92 -0
- 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 +92 -0
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +142 -22
- 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 +142 -22
- 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.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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
}
|
|
@@ -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 = {
|