llm-exe 2.3.0 → 2.3.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.mts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +93 -47
- package/dist/index.mjs +93 -47
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1042,6 +1042,12 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1042
1042
|
"openai.gpt-4o-mini": {
|
|
1043
1043
|
input: Omit<OpenAiRequest, "model">;
|
|
1044
1044
|
};
|
|
1045
|
+
"anthropic.claude-sonnet-4-0": {
|
|
1046
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1047
|
+
};
|
|
1048
|
+
"anthropic.claude-opus-4-0": {
|
|
1049
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1050
|
+
};
|
|
1045
1051
|
"anthropic.claude-3-7-sonnet": {
|
|
1046
1052
|
input: Omit<AnthropicRequest, "model">;
|
|
1047
1053
|
};
|
|
@@ -1066,12 +1072,27 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1066
1072
|
"google.gemini-2.0-flash-lite": {
|
|
1067
1073
|
input: Omit<GeminiRequest, "model">;
|
|
1068
1074
|
};
|
|
1075
|
+
"google.gemini-2.5-flash": {
|
|
1076
|
+
input: Omit<GeminiRequest, "model">;
|
|
1077
|
+
};
|
|
1078
|
+
"google.gemini-2.5-flash-lite": {
|
|
1079
|
+
input: Omit<GeminiRequest, "model">;
|
|
1080
|
+
};
|
|
1069
1081
|
"google.gemini-1.5-pro": {
|
|
1070
1082
|
input: Omit<GeminiRequest, "model">;
|
|
1071
1083
|
};
|
|
1084
|
+
"google.gemini-2.5-pro": {
|
|
1085
|
+
input: Omit<GeminiRequest, "model">;
|
|
1086
|
+
};
|
|
1072
1087
|
"xai.grok-2": {
|
|
1073
1088
|
input: OpenAiRequest;
|
|
1074
1089
|
};
|
|
1090
|
+
"xai.grok-3": {
|
|
1091
|
+
input: OpenAiRequest;
|
|
1092
|
+
};
|
|
1093
|
+
"xai.grok-4": {
|
|
1094
|
+
input: OpenAiRequest;
|
|
1095
|
+
};
|
|
1075
1096
|
"ollama.deepseek-r1": {
|
|
1076
1097
|
input: GenericLLm;
|
|
1077
1098
|
};
|
|
@@ -1321,7 +1342,10 @@ declare const configs: {
|
|
|
1321
1342
|
"google.chat.v1": Config<keyof AllLlm>;
|
|
1322
1343
|
"google.gemini-2.0-flash": Config<keyof AllLlm>;
|
|
1323
1344
|
"google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
|
|
1345
|
+
"google.gemini-2.5-flash": Config<keyof AllLlm>;
|
|
1346
|
+
"google.gemini-2.5-flash-lite": Config<keyof AllLlm>;
|
|
1324
1347
|
"google.gemini-1.5-pro": Config<keyof AllLlm>;
|
|
1348
|
+
"google.gemini-2.5-pro": Config<keyof AllLlm>;
|
|
1325
1349
|
"ollama.chat.v1": Config<keyof AllLlm>;
|
|
1326
1350
|
"ollama.deepseek-r1": Config<keyof AllLlm>;
|
|
1327
1351
|
"ollama.llama3.3": Config<keyof AllLlm>;
|
|
@@ -1330,9 +1354,13 @@ declare const configs: {
|
|
|
1330
1354
|
"ollama.qwq": Config<keyof AllLlm>;
|
|
1331
1355
|
"xai.chat.v1": Config<keyof AllLlm>;
|
|
1332
1356
|
"xai.grok-2": Config<keyof AllLlm>;
|
|
1357
|
+
"xai.grok-3": Config<keyof AllLlm>;
|
|
1358
|
+
"xai.grok-4": Config<keyof AllLlm>;
|
|
1333
1359
|
"amazon:anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1334
1360
|
"amazon:meta.chat.v1": Config<keyof AllLlm>;
|
|
1335
1361
|
"anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1362
|
+
"anthropic.claude-sonnet-4-0": Config<keyof AllLlm>;
|
|
1363
|
+
"anthropic.claude-opus-4-0": Config<keyof AllLlm>;
|
|
1336
1364
|
"anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
|
|
1337
1365
|
"anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
|
|
1338
1366
|
"anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1042,6 +1042,12 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1042
1042
|
"openai.gpt-4o-mini": {
|
|
1043
1043
|
input: Omit<OpenAiRequest, "model">;
|
|
1044
1044
|
};
|
|
1045
|
+
"anthropic.claude-sonnet-4-0": {
|
|
1046
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1047
|
+
};
|
|
1048
|
+
"anthropic.claude-opus-4-0": {
|
|
1049
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1050
|
+
};
|
|
1045
1051
|
"anthropic.claude-3-7-sonnet": {
|
|
1046
1052
|
input: Omit<AnthropicRequest, "model">;
|
|
1047
1053
|
};
|
|
@@ -1066,12 +1072,27 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1066
1072
|
"google.gemini-2.0-flash-lite": {
|
|
1067
1073
|
input: Omit<GeminiRequest, "model">;
|
|
1068
1074
|
};
|
|
1075
|
+
"google.gemini-2.5-flash": {
|
|
1076
|
+
input: Omit<GeminiRequest, "model">;
|
|
1077
|
+
};
|
|
1078
|
+
"google.gemini-2.5-flash-lite": {
|
|
1079
|
+
input: Omit<GeminiRequest, "model">;
|
|
1080
|
+
};
|
|
1069
1081
|
"google.gemini-1.5-pro": {
|
|
1070
1082
|
input: Omit<GeminiRequest, "model">;
|
|
1071
1083
|
};
|
|
1084
|
+
"google.gemini-2.5-pro": {
|
|
1085
|
+
input: Omit<GeminiRequest, "model">;
|
|
1086
|
+
};
|
|
1072
1087
|
"xai.grok-2": {
|
|
1073
1088
|
input: OpenAiRequest;
|
|
1074
1089
|
};
|
|
1090
|
+
"xai.grok-3": {
|
|
1091
|
+
input: OpenAiRequest;
|
|
1092
|
+
};
|
|
1093
|
+
"xai.grok-4": {
|
|
1094
|
+
input: OpenAiRequest;
|
|
1095
|
+
};
|
|
1075
1096
|
"ollama.deepseek-r1": {
|
|
1076
1097
|
input: GenericLLm;
|
|
1077
1098
|
};
|
|
@@ -1321,7 +1342,10 @@ declare const configs: {
|
|
|
1321
1342
|
"google.chat.v1": Config<keyof AllLlm>;
|
|
1322
1343
|
"google.gemini-2.0-flash": Config<keyof AllLlm>;
|
|
1323
1344
|
"google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
|
|
1345
|
+
"google.gemini-2.5-flash": Config<keyof AllLlm>;
|
|
1346
|
+
"google.gemini-2.5-flash-lite": Config<keyof AllLlm>;
|
|
1324
1347
|
"google.gemini-1.5-pro": Config<keyof AllLlm>;
|
|
1348
|
+
"google.gemini-2.5-pro": Config<keyof AllLlm>;
|
|
1325
1349
|
"ollama.chat.v1": Config<keyof AllLlm>;
|
|
1326
1350
|
"ollama.deepseek-r1": Config<keyof AllLlm>;
|
|
1327
1351
|
"ollama.llama3.3": Config<keyof AllLlm>;
|
|
@@ -1330,9 +1354,13 @@ declare const configs: {
|
|
|
1330
1354
|
"ollama.qwq": Config<keyof AllLlm>;
|
|
1331
1355
|
"xai.chat.v1": Config<keyof AllLlm>;
|
|
1332
1356
|
"xai.grok-2": Config<keyof AllLlm>;
|
|
1357
|
+
"xai.grok-3": Config<keyof AllLlm>;
|
|
1358
|
+
"xai.grok-4": Config<keyof AllLlm>;
|
|
1333
1359
|
"amazon:anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1334
1360
|
"amazon:meta.chat.v1": Config<keyof AllLlm>;
|
|
1335
1361
|
"anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1362
|
+
"anthropic.claude-sonnet-4-0": Config<keyof AllLlm>;
|
|
1363
|
+
"anthropic.claude-opus-4-0": Config<keyof AllLlm>;
|
|
1336
1364
|
"anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
|
|
1337
1365
|
"anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
|
|
1338
1366
|
"anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
|
package/dist/index.js
CHANGED
|
@@ -2411,6 +2411,14 @@ var anthropicChatV1 = {
|
|
|
2411
2411
|
};
|
|
2412
2412
|
var anthropic = {
|
|
2413
2413
|
"anthropic.chat.v1": anthropicChatV1,
|
|
2414
|
+
"anthropic.claude-sonnet-4-0": withDefaultModel(
|
|
2415
|
+
anthropicChatV1,
|
|
2416
|
+
"claude-sonnet-4-0"
|
|
2417
|
+
),
|
|
2418
|
+
"anthropic.claude-opus-4-0": withDefaultModel(
|
|
2419
|
+
anthropicChatV1,
|
|
2420
|
+
"claude-sonnet-4-0"
|
|
2421
|
+
),
|
|
2414
2422
|
"anthropic.claude-3-7-sonnet": withDefaultModel(
|
|
2415
2423
|
anthropicChatV1,
|
|
2416
2424
|
"claude-3-7-sonnet-latest"
|
|
@@ -2423,6 +2431,7 @@ var anthropic = {
|
|
|
2423
2431
|
anthropicChatV1,
|
|
2424
2432
|
"claude-3-5-haiku-latest"
|
|
2425
2433
|
),
|
|
2434
|
+
// Deprecated
|
|
2426
2435
|
"anthropic.claude-3-opus": withDefaultModel(
|
|
2427
2436
|
anthropicChatV1,
|
|
2428
2437
|
"claude-3-opus-latest"
|
|
@@ -2447,12 +2456,7 @@ var xaiChatV1 = {
|
|
|
2447
2456
|
mapBody: {
|
|
2448
2457
|
prompt: {
|
|
2449
2458
|
key: "messages",
|
|
2450
|
-
sanitize:
|
|
2451
|
-
if (typeof v === "string") {
|
|
2452
|
-
return [{ role: "user", content: v }];
|
|
2453
|
-
}
|
|
2454
|
-
return v;
|
|
2455
|
-
}
|
|
2459
|
+
sanitize: openaiPromptSanitize
|
|
2456
2460
|
},
|
|
2457
2461
|
model: {
|
|
2458
2462
|
key: "model"
|
|
@@ -2468,7 +2472,9 @@ var xaiChatV1 = {
|
|
|
2468
2472
|
};
|
|
2469
2473
|
var xai = {
|
|
2470
2474
|
"xai.chat.v1": xaiChatV1,
|
|
2471
|
-
"xai.grok-2": withDefaultModel(xaiChatV1, "grok-2-latest")
|
|
2475
|
+
"xai.grok-2": withDefaultModel(xaiChatV1, "grok-2-latest"),
|
|
2476
|
+
"xai.grok-3": withDefaultModel(xaiChatV1, "grok-3"),
|
|
2477
|
+
"xai.grok-4": withDefaultModel(xaiChatV1, "grok-4")
|
|
2472
2478
|
};
|
|
2473
2479
|
|
|
2474
2480
|
// src/llm/config/ollama/index.ts
|
|
@@ -2622,9 +2628,21 @@ var google = {
|
|
|
2622
2628
|
googleGeminiChatV1,
|
|
2623
2629
|
"gemini-2.0-flash-lite"
|
|
2624
2630
|
),
|
|
2631
|
+
"google.gemini-2.5-flash": withDefaultModel(
|
|
2632
|
+
googleGeminiChatV1,
|
|
2633
|
+
"gemini-2.5-flash"
|
|
2634
|
+
),
|
|
2635
|
+
"google.gemini-2.5-flash-lite": withDefaultModel(
|
|
2636
|
+
googleGeminiChatV1,
|
|
2637
|
+
"gemini-2.5-flash-lite"
|
|
2638
|
+
),
|
|
2625
2639
|
"google.gemini-1.5-pro": withDefaultModel(
|
|
2626
2640
|
googleGeminiChatV1,
|
|
2627
2641
|
"gemini-1.5-pro"
|
|
2642
|
+
),
|
|
2643
|
+
"google.gemini-2.5-pro": withDefaultModel(
|
|
2644
|
+
googleGeminiChatV1,
|
|
2645
|
+
"gemini-2.5-pro"
|
|
2628
2646
|
)
|
|
2629
2647
|
};
|
|
2630
2648
|
|
|
@@ -2646,12 +2664,7 @@ var deepseekChatV1 = {
|
|
|
2646
2664
|
mapBody: {
|
|
2647
2665
|
prompt: {
|
|
2648
2666
|
key: "messages",
|
|
2649
|
-
sanitize:
|
|
2650
|
-
if (typeof v === "string") {
|
|
2651
|
-
return [{ role: "user", content: v }];
|
|
2652
|
-
}
|
|
2653
|
-
return v;
|
|
2654
|
-
}
|
|
2667
|
+
sanitize: openaiPromptSanitize
|
|
2655
2668
|
},
|
|
2656
2669
|
model: {
|
|
2657
2670
|
key: "model"
|
|
@@ -2766,14 +2779,6 @@ function formatOptions(response, handler) {
|
|
|
2766
2779
|
}
|
|
2767
2780
|
return out;
|
|
2768
2781
|
}
|
|
2769
|
-
function formatContent(response, handler) {
|
|
2770
|
-
const out = [];
|
|
2771
|
-
const result = handler(response);
|
|
2772
|
-
if (result) {
|
|
2773
|
-
out.push(result);
|
|
2774
|
-
}
|
|
2775
|
-
return out;
|
|
2776
|
-
}
|
|
2777
2782
|
|
|
2778
2783
|
// src/llm/output/openai.ts
|
|
2779
2784
|
function formatResult(result) {
|
|
@@ -2904,36 +2909,32 @@ function OutputDefault(result, _config) {
|
|
|
2904
2909
|
|
|
2905
2910
|
// src/llm/output/xai.ts
|
|
2906
2911
|
function formatResult3(result) {
|
|
2912
|
+
const out = [];
|
|
2907
2913
|
if (typeof result?.message?.content === "string") {
|
|
2908
|
-
|
|
2914
|
+
out.push({
|
|
2909
2915
|
type: "text",
|
|
2910
2916
|
text: result.message.content
|
|
2911
|
-
};
|
|
2912
|
-
}
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
};
|
|
2922
|
-
}
|
|
2917
|
+
});
|
|
2918
|
+
}
|
|
2919
|
+
if (result?.message?.tool_calls) {
|
|
2920
|
+
for (const call of result.message.tool_calls) {
|
|
2921
|
+
out.push({
|
|
2922
|
+
functionId: call.id,
|
|
2923
|
+
type: "function_use",
|
|
2924
|
+
name: call.function.name,
|
|
2925
|
+
input: maybeParseJSON(call.function.arguments)
|
|
2926
|
+
});
|
|
2923
2927
|
}
|
|
2924
2928
|
}
|
|
2925
|
-
return
|
|
2926
|
-
type: "text",
|
|
2927
|
-
text: ""
|
|
2928
|
-
};
|
|
2929
|
+
return out;
|
|
2929
2930
|
}
|
|
2930
2931
|
function OutputXAIChat(result, _config) {
|
|
2931
2932
|
const id = result.id;
|
|
2932
|
-
const name = result?.model;
|
|
2933
|
+
const name = result.model || _config?.model || "openai.unknown";
|
|
2933
2934
|
const created = result.created;
|
|
2934
2935
|
const [_content, ..._options] = result?.choices || [];
|
|
2935
2936
|
const stopReason = _content?.finish_reason;
|
|
2936
|
-
const content =
|
|
2937
|
+
const content = formatResult3(_content);
|
|
2937
2938
|
const options = formatOptions(_options, formatResult3);
|
|
2938
2939
|
const usage = {
|
|
2939
2940
|
output_tokens: result?.usage?.completion_tokens,
|
|
@@ -3071,6 +3072,51 @@ function OutputGoogleGeminiChat(result, _config) {
|
|
|
3071
3072
|
});
|
|
3072
3073
|
}
|
|
3073
3074
|
|
|
3075
|
+
// src/llm/output/deepseek.ts
|
|
3076
|
+
function formatResult5(result) {
|
|
3077
|
+
const out = [];
|
|
3078
|
+
if (typeof result?.message?.content === "string" && result?.message?.content) {
|
|
3079
|
+
out.push({
|
|
3080
|
+
type: "text",
|
|
3081
|
+
text: result.message.content
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
if (result?.message?.tool_calls) {
|
|
3085
|
+
for (const call of result.message.tool_calls) {
|
|
3086
|
+
out.push({
|
|
3087
|
+
functionId: call.id,
|
|
3088
|
+
type: "function_use",
|
|
3089
|
+
name: call.function.name,
|
|
3090
|
+
input: maybeParseJSON(call.function.arguments)
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
return out;
|
|
3095
|
+
}
|
|
3096
|
+
function OutputDeepSeekChat(result, _config) {
|
|
3097
|
+
const id = result.id;
|
|
3098
|
+
const name = result.model || _config?.model || "deepseek.unknown";
|
|
3099
|
+
const created = result.created;
|
|
3100
|
+
const [_content, ..._options] = result?.choices || [];
|
|
3101
|
+
const stopReason = _content?.finish_reason;
|
|
3102
|
+
const content = formatResult5(_content);
|
|
3103
|
+
const options = formatOptions(_options, formatResult5);
|
|
3104
|
+
const usage = {
|
|
3105
|
+
output_tokens: result?.usage?.completion_tokens,
|
|
3106
|
+
input_tokens: result?.usage?.prompt_tokens,
|
|
3107
|
+
total_tokens: result?.usage?.total_tokens
|
|
3108
|
+
};
|
|
3109
|
+
return BaseLlmOutput2({
|
|
3110
|
+
id,
|
|
3111
|
+
name,
|
|
3112
|
+
created,
|
|
3113
|
+
usage,
|
|
3114
|
+
stopReason,
|
|
3115
|
+
content,
|
|
3116
|
+
options
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3074
3120
|
// src/llm/output/index.ts
|
|
3075
3121
|
function normalizeLlmOutputToInternalFormat(config, response) {
|
|
3076
3122
|
switch (config?.key) {
|
|
@@ -3091,7 +3137,7 @@ function normalizeLlmOutputToInternalFormat(config, response) {
|
|
|
3091
3137
|
case "google.chat.v1":
|
|
3092
3138
|
return OutputGoogleGeminiChat(response, config);
|
|
3093
3139
|
case "deepseek.chat.v1":
|
|
3094
|
-
return
|
|
3140
|
+
return OutputDeepSeekChat(response, config);
|
|
3095
3141
|
// use oai for now
|
|
3096
3142
|
default: {
|
|
3097
3143
|
if (config?.key?.startsWith("custom:")) {
|
|
@@ -3321,9 +3367,9 @@ async function parseHeaders(config, replacements, payload) {
|
|
|
3321
3367
|
// src/llm/output/_utils/cleanJsonSchemaFor.ts
|
|
3322
3368
|
var providerFieldExclusions = {
|
|
3323
3369
|
"openai.chat": ["default"],
|
|
3324
|
-
// fields to exclude for openai.chat
|
|
3325
|
-
"anthropic.chat": []
|
|
3326
|
-
|
|
3370
|
+
// fields to exclude for openai.chat, xai, deepseek
|
|
3371
|
+
"anthropic.chat": [],
|
|
3372
|
+
"google.chat": ["additionalProperties"]
|
|
3327
3373
|
};
|
|
3328
3374
|
function cleanJsonSchemaFor(schema = {}, provider) {
|
|
3329
3375
|
const clone = deepClone(schema);
|
|
@@ -3362,7 +3408,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
3362
3408
|
})
|
|
3363
3409
|
);
|
|
3364
3410
|
if (_options && _options?.jsonSchema) {
|
|
3365
|
-
if (state.provider.startsWith("openai")) {
|
|
3411
|
+
if (state.provider.startsWith("openai") || state.provider.startsWith("deepseek") || state.provider.startsWith("xai")) {
|
|
3366
3412
|
const curr = input["response_format"] || {};
|
|
3367
3413
|
input["response_format"] = Object.assign(curr, {
|
|
3368
3414
|
type: "json_schema",
|
|
@@ -3383,7 +3429,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
3383
3429
|
} else {
|
|
3384
3430
|
input["tool_choice"] = _options?.functionCall;
|
|
3385
3431
|
}
|
|
3386
|
-
} else if (state.provider.startsWith("openai")) {
|
|
3432
|
+
} else if (state.provider.startsWith("openai") || state.provider.startsWith("deepseek") || state.provider.startsWith("xai")) {
|
|
3387
3433
|
input["tool_choice"] = normalizeFunctionCall(
|
|
3388
3434
|
_options?.functionCall,
|
|
3389
3435
|
"openai"
|
|
@@ -3403,7 +3449,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
3403
3449
|
description: f.description,
|
|
3404
3450
|
input_schema: cleanJsonSchemaFor(f.parameters, "anthropic.chat")
|
|
3405
3451
|
}));
|
|
3406
|
-
} else if (state.provider.startsWith("openai")) {
|
|
3452
|
+
} else if (state.provider.startsWith("openai") || state.provider.startsWith("deepseek") || state.provider.startsWith("xai")) {
|
|
3407
3453
|
input["tools"] = _options.functions.map((f) => {
|
|
3408
3454
|
const props = {
|
|
3409
3455
|
name: f?.name,
|
package/dist/index.mjs
CHANGED
|
@@ -2350,6 +2350,14 @@ var anthropicChatV1 = {
|
|
|
2350
2350
|
};
|
|
2351
2351
|
var anthropic = {
|
|
2352
2352
|
"anthropic.chat.v1": anthropicChatV1,
|
|
2353
|
+
"anthropic.claude-sonnet-4-0": withDefaultModel(
|
|
2354
|
+
anthropicChatV1,
|
|
2355
|
+
"claude-sonnet-4-0"
|
|
2356
|
+
),
|
|
2357
|
+
"anthropic.claude-opus-4-0": withDefaultModel(
|
|
2358
|
+
anthropicChatV1,
|
|
2359
|
+
"claude-sonnet-4-0"
|
|
2360
|
+
),
|
|
2353
2361
|
"anthropic.claude-3-7-sonnet": withDefaultModel(
|
|
2354
2362
|
anthropicChatV1,
|
|
2355
2363
|
"claude-3-7-sonnet-latest"
|
|
@@ -2362,6 +2370,7 @@ var anthropic = {
|
|
|
2362
2370
|
anthropicChatV1,
|
|
2363
2371
|
"claude-3-5-haiku-latest"
|
|
2364
2372
|
),
|
|
2373
|
+
// Deprecated
|
|
2365
2374
|
"anthropic.claude-3-opus": withDefaultModel(
|
|
2366
2375
|
anthropicChatV1,
|
|
2367
2376
|
"claude-3-opus-latest"
|
|
@@ -2386,12 +2395,7 @@ var xaiChatV1 = {
|
|
|
2386
2395
|
mapBody: {
|
|
2387
2396
|
prompt: {
|
|
2388
2397
|
key: "messages",
|
|
2389
|
-
sanitize:
|
|
2390
|
-
if (typeof v === "string") {
|
|
2391
|
-
return [{ role: "user", content: v }];
|
|
2392
|
-
}
|
|
2393
|
-
return v;
|
|
2394
|
-
}
|
|
2398
|
+
sanitize: openaiPromptSanitize
|
|
2395
2399
|
},
|
|
2396
2400
|
model: {
|
|
2397
2401
|
key: "model"
|
|
@@ -2407,7 +2411,9 @@ var xaiChatV1 = {
|
|
|
2407
2411
|
};
|
|
2408
2412
|
var xai = {
|
|
2409
2413
|
"xai.chat.v1": xaiChatV1,
|
|
2410
|
-
"xai.grok-2": withDefaultModel(xaiChatV1, "grok-2-latest")
|
|
2414
|
+
"xai.grok-2": withDefaultModel(xaiChatV1, "grok-2-latest"),
|
|
2415
|
+
"xai.grok-3": withDefaultModel(xaiChatV1, "grok-3"),
|
|
2416
|
+
"xai.grok-4": withDefaultModel(xaiChatV1, "grok-4")
|
|
2411
2417
|
};
|
|
2412
2418
|
|
|
2413
2419
|
// src/llm/config/ollama/index.ts
|
|
@@ -2561,9 +2567,21 @@ var google = {
|
|
|
2561
2567
|
googleGeminiChatV1,
|
|
2562
2568
|
"gemini-2.0-flash-lite"
|
|
2563
2569
|
),
|
|
2570
|
+
"google.gemini-2.5-flash": withDefaultModel(
|
|
2571
|
+
googleGeminiChatV1,
|
|
2572
|
+
"gemini-2.5-flash"
|
|
2573
|
+
),
|
|
2574
|
+
"google.gemini-2.5-flash-lite": withDefaultModel(
|
|
2575
|
+
googleGeminiChatV1,
|
|
2576
|
+
"gemini-2.5-flash-lite"
|
|
2577
|
+
),
|
|
2564
2578
|
"google.gemini-1.5-pro": withDefaultModel(
|
|
2565
2579
|
googleGeminiChatV1,
|
|
2566
2580
|
"gemini-1.5-pro"
|
|
2581
|
+
),
|
|
2582
|
+
"google.gemini-2.5-pro": withDefaultModel(
|
|
2583
|
+
googleGeminiChatV1,
|
|
2584
|
+
"gemini-2.5-pro"
|
|
2567
2585
|
)
|
|
2568
2586
|
};
|
|
2569
2587
|
|
|
@@ -2585,12 +2603,7 @@ var deepseekChatV1 = {
|
|
|
2585
2603
|
mapBody: {
|
|
2586
2604
|
prompt: {
|
|
2587
2605
|
key: "messages",
|
|
2588
|
-
sanitize:
|
|
2589
|
-
if (typeof v === "string") {
|
|
2590
|
-
return [{ role: "user", content: v }];
|
|
2591
|
-
}
|
|
2592
|
-
return v;
|
|
2593
|
-
}
|
|
2606
|
+
sanitize: openaiPromptSanitize
|
|
2594
2607
|
},
|
|
2595
2608
|
model: {
|
|
2596
2609
|
key: "model"
|
|
@@ -2705,14 +2718,6 @@ function formatOptions(response, handler) {
|
|
|
2705
2718
|
}
|
|
2706
2719
|
return out;
|
|
2707
2720
|
}
|
|
2708
|
-
function formatContent(response, handler) {
|
|
2709
|
-
const out = [];
|
|
2710
|
-
const result = handler(response);
|
|
2711
|
-
if (result) {
|
|
2712
|
-
out.push(result);
|
|
2713
|
-
}
|
|
2714
|
-
return out;
|
|
2715
|
-
}
|
|
2716
2721
|
|
|
2717
2722
|
// src/llm/output/openai.ts
|
|
2718
2723
|
function formatResult(result) {
|
|
@@ -2843,36 +2848,32 @@ function OutputDefault(result, _config) {
|
|
|
2843
2848
|
|
|
2844
2849
|
// src/llm/output/xai.ts
|
|
2845
2850
|
function formatResult3(result) {
|
|
2851
|
+
const out = [];
|
|
2846
2852
|
if (typeof result?.message?.content === "string") {
|
|
2847
|
-
|
|
2853
|
+
out.push({
|
|
2848
2854
|
type: "text",
|
|
2849
2855
|
text: result.message.content
|
|
2850
|
-
};
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
};
|
|
2861
|
-
}
|
|
2856
|
+
});
|
|
2857
|
+
}
|
|
2858
|
+
if (result?.message?.tool_calls) {
|
|
2859
|
+
for (const call of result.message.tool_calls) {
|
|
2860
|
+
out.push({
|
|
2861
|
+
functionId: call.id,
|
|
2862
|
+
type: "function_use",
|
|
2863
|
+
name: call.function.name,
|
|
2864
|
+
input: maybeParseJSON(call.function.arguments)
|
|
2865
|
+
});
|
|
2862
2866
|
}
|
|
2863
2867
|
}
|
|
2864
|
-
return
|
|
2865
|
-
type: "text",
|
|
2866
|
-
text: ""
|
|
2867
|
-
};
|
|
2868
|
+
return out;
|
|
2868
2869
|
}
|
|
2869
2870
|
function OutputXAIChat(result, _config) {
|
|
2870
2871
|
const id = result.id;
|
|
2871
|
-
const name = result?.model;
|
|
2872
|
+
const name = result.model || _config?.model || "openai.unknown";
|
|
2872
2873
|
const created = result.created;
|
|
2873
2874
|
const [_content, ..._options] = result?.choices || [];
|
|
2874
2875
|
const stopReason = _content?.finish_reason;
|
|
2875
|
-
const content =
|
|
2876
|
+
const content = formatResult3(_content);
|
|
2876
2877
|
const options = formatOptions(_options, formatResult3);
|
|
2877
2878
|
const usage = {
|
|
2878
2879
|
output_tokens: result?.usage?.completion_tokens,
|
|
@@ -3010,6 +3011,51 @@ function OutputGoogleGeminiChat(result, _config) {
|
|
|
3010
3011
|
});
|
|
3011
3012
|
}
|
|
3012
3013
|
|
|
3014
|
+
// src/llm/output/deepseek.ts
|
|
3015
|
+
function formatResult5(result) {
|
|
3016
|
+
const out = [];
|
|
3017
|
+
if (typeof result?.message?.content === "string" && result?.message?.content) {
|
|
3018
|
+
out.push({
|
|
3019
|
+
type: "text",
|
|
3020
|
+
text: result.message.content
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
if (result?.message?.tool_calls) {
|
|
3024
|
+
for (const call of result.message.tool_calls) {
|
|
3025
|
+
out.push({
|
|
3026
|
+
functionId: call.id,
|
|
3027
|
+
type: "function_use",
|
|
3028
|
+
name: call.function.name,
|
|
3029
|
+
input: maybeParseJSON(call.function.arguments)
|
|
3030
|
+
});
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
return out;
|
|
3034
|
+
}
|
|
3035
|
+
function OutputDeepSeekChat(result, _config) {
|
|
3036
|
+
const id = result.id;
|
|
3037
|
+
const name = result.model || _config?.model || "deepseek.unknown";
|
|
3038
|
+
const created = result.created;
|
|
3039
|
+
const [_content, ..._options] = result?.choices || [];
|
|
3040
|
+
const stopReason = _content?.finish_reason;
|
|
3041
|
+
const content = formatResult5(_content);
|
|
3042
|
+
const options = formatOptions(_options, formatResult5);
|
|
3043
|
+
const usage = {
|
|
3044
|
+
output_tokens: result?.usage?.completion_tokens,
|
|
3045
|
+
input_tokens: result?.usage?.prompt_tokens,
|
|
3046
|
+
total_tokens: result?.usage?.total_tokens
|
|
3047
|
+
};
|
|
3048
|
+
return BaseLlmOutput2({
|
|
3049
|
+
id,
|
|
3050
|
+
name,
|
|
3051
|
+
created,
|
|
3052
|
+
usage,
|
|
3053
|
+
stopReason,
|
|
3054
|
+
content,
|
|
3055
|
+
options
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3013
3059
|
// src/llm/output/index.ts
|
|
3014
3060
|
function normalizeLlmOutputToInternalFormat(config, response) {
|
|
3015
3061
|
switch (config?.key) {
|
|
@@ -3030,7 +3076,7 @@ function normalizeLlmOutputToInternalFormat(config, response) {
|
|
|
3030
3076
|
case "google.chat.v1":
|
|
3031
3077
|
return OutputGoogleGeminiChat(response, config);
|
|
3032
3078
|
case "deepseek.chat.v1":
|
|
3033
|
-
return
|
|
3079
|
+
return OutputDeepSeekChat(response, config);
|
|
3034
3080
|
// use oai for now
|
|
3035
3081
|
default: {
|
|
3036
3082
|
if (config?.key?.startsWith("custom:")) {
|
|
@@ -3260,9 +3306,9 @@ async function parseHeaders(config, replacements, payload) {
|
|
|
3260
3306
|
// src/llm/output/_utils/cleanJsonSchemaFor.ts
|
|
3261
3307
|
var providerFieldExclusions = {
|
|
3262
3308
|
"openai.chat": ["default"],
|
|
3263
|
-
// fields to exclude for openai.chat
|
|
3264
|
-
"anthropic.chat": []
|
|
3265
|
-
|
|
3309
|
+
// fields to exclude for openai.chat, xai, deepseek
|
|
3310
|
+
"anthropic.chat": [],
|
|
3311
|
+
"google.chat": ["additionalProperties"]
|
|
3266
3312
|
};
|
|
3267
3313
|
function cleanJsonSchemaFor(schema = {}, provider) {
|
|
3268
3314
|
const clone = deepClone(schema);
|
|
@@ -3301,7 +3347,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
3301
3347
|
})
|
|
3302
3348
|
);
|
|
3303
3349
|
if (_options && _options?.jsonSchema) {
|
|
3304
|
-
if (state.provider.startsWith("openai")) {
|
|
3350
|
+
if (state.provider.startsWith("openai") || state.provider.startsWith("deepseek") || state.provider.startsWith("xai")) {
|
|
3305
3351
|
const curr = input["response_format"] || {};
|
|
3306
3352
|
input["response_format"] = Object.assign(curr, {
|
|
3307
3353
|
type: "json_schema",
|
|
@@ -3322,7 +3368,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
3322
3368
|
} else {
|
|
3323
3369
|
input["tool_choice"] = _options?.functionCall;
|
|
3324
3370
|
}
|
|
3325
|
-
} else if (state.provider.startsWith("openai")) {
|
|
3371
|
+
} else if (state.provider.startsWith("openai") || state.provider.startsWith("deepseek") || state.provider.startsWith("xai")) {
|
|
3326
3372
|
input["tool_choice"] = normalizeFunctionCall(
|
|
3327
3373
|
_options?.functionCall,
|
|
3328
3374
|
"openai"
|
|
@@ -3342,7 +3388,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
3342
3388
|
description: f.description,
|
|
3343
3389
|
input_schema: cleanJsonSchemaFor(f.parameters, "anthropic.chat")
|
|
3344
3390
|
}));
|
|
3345
|
-
} else if (state.provider.startsWith("openai")) {
|
|
3391
|
+
} else if (state.provider.startsWith("openai") || state.provider.startsWith("deepseek") || state.provider.startsWith("xai")) {
|
|
3346
3392
|
input["tools"] = _options.functions.map((f) => {
|
|
3347
3393
|
const props = {
|
|
3348
3394
|
name: f?.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-exe",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Simplify building LLM-powered apps with easy-to-use base components, supporting text and chat-based prompts with handlebars template engine, output parsers, and flexible function calling capabilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|