llm-exe 2.1.5 → 2.1.6
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 +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +73 -13
- package/dist/index.mjs +73 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -990,7 +990,7 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
990
990
|
"anthropic.claude-3-sonnet": {
|
|
991
991
|
input: Omit<AnthropicRequest, "model">;
|
|
992
992
|
};
|
|
993
|
-
"anthropic.claude-3-haiku": {
|
|
993
|
+
"anthropic.claude-3-5-haiku": {
|
|
994
994
|
input: Omit<AnthropicRequest, "model">;
|
|
995
995
|
};
|
|
996
996
|
"google.gemini-2.5-pro-exp-03-25": {
|
|
@@ -1236,9 +1236,8 @@ declare const configs: {
|
|
|
1236
1236
|
"anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1237
1237
|
"anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
|
|
1238
1238
|
"anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
|
|
1239
|
+
"anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
|
|
1239
1240
|
"anthropic.claude-3-opus": Config<keyof AllLlm>;
|
|
1240
|
-
"anthropic.claude-3-sonnet": Config<keyof AllLlm>;
|
|
1241
|
-
"anthropic.claude-3-haiku": Config<keyof AllLlm>;
|
|
1242
1241
|
"openai.chat.v1": Config<keyof AllLlm>;
|
|
1243
1242
|
"openai.chat-mock.v1": Config<keyof AllLlm>;
|
|
1244
1243
|
"openai.gpt-4o": Config<keyof AllLlm>;
|
package/dist/index.d.ts
CHANGED
|
@@ -990,7 +990,7 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
990
990
|
"anthropic.claude-3-sonnet": {
|
|
991
991
|
input: Omit<AnthropicRequest, "model">;
|
|
992
992
|
};
|
|
993
|
-
"anthropic.claude-3-haiku": {
|
|
993
|
+
"anthropic.claude-3-5-haiku": {
|
|
994
994
|
input: Omit<AnthropicRequest, "model">;
|
|
995
995
|
};
|
|
996
996
|
"google.gemini-2.5-pro-exp-03-25": {
|
|
@@ -1236,9 +1236,8 @@ declare const configs: {
|
|
|
1236
1236
|
"anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1237
1237
|
"anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
|
|
1238
1238
|
"anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
|
|
1239
|
+
"anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
|
|
1239
1240
|
"anthropic.claude-3-opus": Config<keyof AllLlm>;
|
|
1240
|
-
"anthropic.claude-3-sonnet": Config<keyof AllLlm>;
|
|
1241
|
-
"anthropic.claude-3-haiku": Config<keyof AllLlm>;
|
|
1242
1241
|
"openai.chat.v1": Config<keyof AllLlm>;
|
|
1243
1242
|
"openai.chat-mock.v1": Config<keyof AllLlm>;
|
|
1244
1243
|
"openai.gpt-4o": Config<keyof AllLlm>;
|
package/dist/index.js
CHANGED
|
@@ -1572,6 +1572,23 @@ function validateParserSchema(schema, parsed) {
|
|
|
1572
1572
|
}
|
|
1573
1573
|
__name(validateParserSchema, "validateParserSchema");
|
|
1574
1574
|
|
|
1575
|
+
// src/utils/modules/errors.ts
|
|
1576
|
+
var _LlmExeError = class _LlmExeError extends Error {
|
|
1577
|
+
constructor(message, code, context) {
|
|
1578
|
+
super(message ?? "");
|
|
1579
|
+
__publicField(this, "code");
|
|
1580
|
+
__publicField(this, "context");
|
|
1581
|
+
this.name = this.constructor.name;
|
|
1582
|
+
this.code = code ?? "unknown";
|
|
1583
|
+
this.context = context;
|
|
1584
|
+
if (Error.captureStackTrace) {
|
|
1585
|
+
Error.captureStackTrace(this, this.constructor);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
__name(_LlmExeError, "LlmExeError");
|
|
1590
|
+
var LlmExeError = _LlmExeError;
|
|
1591
|
+
|
|
1575
1592
|
// src/parser/parsers/JsonParser.ts
|
|
1576
1593
|
var _JsonParser = class _JsonParser extends BaseParserWithJson {
|
|
1577
1594
|
constructor(options = {}) {
|
|
@@ -1584,7 +1601,11 @@ var _JsonParser = class _JsonParser extends BaseParserWithJson {
|
|
|
1584
1601
|
if (this.validateSchema) {
|
|
1585
1602
|
const valid = validateParserSchema(this.schema, enforce);
|
|
1586
1603
|
if (valid && valid.length) {
|
|
1587
|
-
throw new
|
|
1604
|
+
throw new LlmExeError(valid[0].message, "parser", {
|
|
1605
|
+
parser: "json",
|
|
1606
|
+
output: parsed,
|
|
1607
|
+
error: valid[0].message
|
|
1608
|
+
});
|
|
1588
1609
|
}
|
|
1589
1610
|
}
|
|
1590
1611
|
return enforce;
|
|
@@ -1629,7 +1650,11 @@ var _ListToJsonParser = class _ListToJsonParser extends BaseParserWithJson {
|
|
|
1629
1650
|
if (this?.validateSchema) {
|
|
1630
1651
|
const valid = validateParserSchema(this.schema, parsed);
|
|
1631
1652
|
if (valid && valid.length) {
|
|
1632
|
-
throw new
|
|
1653
|
+
throw new LlmExeError(valid[0].message, "parser", {
|
|
1654
|
+
parser: "json",
|
|
1655
|
+
output: parsed,
|
|
1656
|
+
error: valid[0].message
|
|
1657
|
+
});
|
|
1633
1658
|
}
|
|
1634
1659
|
}
|
|
1635
1660
|
return parsed;
|
|
@@ -2349,9 +2374,8 @@ var anthropic = {
|
|
|
2349
2374
|
"anthropic.chat.v1": anthropicChatV1,
|
|
2350
2375
|
"anthropic.claude-3-7-sonnet": withDefaultModel(anthropicChatV1, "claude-3-7-sonnet-latest"),
|
|
2351
2376
|
"anthropic.claude-3-5-sonnet": withDefaultModel(anthropicChatV1, "claude-3-5-sonnet-latest"),
|
|
2352
|
-
"anthropic.claude-3-
|
|
2353
|
-
"anthropic.claude-3-
|
|
2354
|
-
"anthropic.claude-3-haiku": withDefaultModel(anthropicChatV1, "claude-3-haiku-latest")
|
|
2377
|
+
"anthropic.claude-3-5-haiku": withDefaultModel(anthropicChatV1, "claude-3-5-haiku-latest"),
|
|
2378
|
+
"anthropic.claude-3-opus": withDefaultModel(anthropicChatV1, "claude-3-opus-latest")
|
|
2355
2379
|
};
|
|
2356
2380
|
|
|
2357
2381
|
// src/llm/config/x/index.ts
|
|
@@ -2472,10 +2496,6 @@ function googleGeminiPromptMessageCallback(_message) {
|
|
|
2472
2496
|
{
|
|
2473
2497
|
from: "assistant",
|
|
2474
2498
|
to: "model"
|
|
2475
|
-
},
|
|
2476
|
-
{
|
|
2477
|
-
from: "system",
|
|
2478
|
-
to: "model"
|
|
2479
2499
|
}
|
|
2480
2500
|
]);
|
|
2481
2501
|
const { role, ...payload } = message;
|
|
@@ -2495,14 +2515,47 @@ __name(googleGeminiPromptMessageCallback, "googleGeminiPromptMessageCallback");
|
|
|
2495
2515
|
// src/llm/config/google/promptSanitize.ts
|
|
2496
2516
|
function googleGeminiPromptSanitize(_messages, _inputBodyObj, _outputObj) {
|
|
2497
2517
|
if (typeof _messages === "string") {
|
|
2498
|
-
return
|
|
2518
|
+
return [
|
|
2519
|
+
{
|
|
2520
|
+
role: "user",
|
|
2521
|
+
parts: [
|
|
2522
|
+
{
|
|
2523
|
+
text: _messages
|
|
2524
|
+
}
|
|
2525
|
+
]
|
|
2526
|
+
}
|
|
2527
|
+
];
|
|
2499
2528
|
}
|
|
2500
2529
|
if (Array.isArray(_messages)) {
|
|
2501
2530
|
if (_messages.length === 0) {
|
|
2502
2531
|
throw new Error("Empty messages array");
|
|
2503
2532
|
}
|
|
2533
|
+
if (_messages.length === 1 && _messages[0].role === "system") {
|
|
2534
|
+
return [
|
|
2535
|
+
{
|
|
2536
|
+
role: "user",
|
|
2537
|
+
parts: [
|
|
2538
|
+
{
|
|
2539
|
+
text: _messages[0].content
|
|
2540
|
+
}
|
|
2541
|
+
]
|
|
2542
|
+
}
|
|
2543
|
+
];
|
|
2544
|
+
}
|
|
2545
|
+
const hasSystemInstruction = _messages.some((message) => message.role === "system");
|
|
2546
|
+
if (hasSystemInstruction) {
|
|
2547
|
+
const theSystemInstructions = _messages.filter((message) => message.role === "system");
|
|
2548
|
+
const withoutSystemInstructions = _messages.filter((message) => message.role !== "system");
|
|
2549
|
+
_outputObj.system_instruction = {
|
|
2550
|
+
parts: theSystemInstructions.map((message) => ({
|
|
2551
|
+
text: message.content
|
|
2552
|
+
}))
|
|
2553
|
+
};
|
|
2554
|
+
return withoutSystemInstructions.map(googleGeminiPromptMessageCallback);
|
|
2555
|
+
}
|
|
2556
|
+
return _messages.map(googleGeminiPromptMessageCallback);
|
|
2504
2557
|
}
|
|
2505
|
-
|
|
2558
|
+
throw new Error("Invalid messages format");
|
|
2506
2559
|
}
|
|
2507
2560
|
__name(googleGeminiPromptSanitize, "googleGeminiPromptSanitize");
|
|
2508
2561
|
|
|
@@ -2545,13 +2598,20 @@ var configs = {
|
|
|
2545
2598
|
};
|
|
2546
2599
|
function getLlmConfig(provider) {
|
|
2547
2600
|
if (!provider) {
|
|
2548
|
-
throw new
|
|
2601
|
+
throw new LlmExeError(`Missing provider`, "unknown", {
|
|
2602
|
+
error: "Missing provider",
|
|
2603
|
+
resolution: "Provide a valid provider"
|
|
2604
|
+
});
|
|
2549
2605
|
}
|
|
2550
2606
|
const pick2 = configs[provider];
|
|
2551
2607
|
if (pick2) {
|
|
2552
2608
|
return pick2;
|
|
2553
2609
|
}
|
|
2554
|
-
throw new
|
|
2610
|
+
throw new LlmExeError(`Invalid provider: ${provider}`, "unknown", {
|
|
2611
|
+
provider,
|
|
2612
|
+
error: `Invalid provider: ${provider}`,
|
|
2613
|
+
resolution: "Provide a valid provider"
|
|
2614
|
+
});
|
|
2555
2615
|
}
|
|
2556
2616
|
__name(getLlmConfig, "getLlmConfig");
|
|
2557
2617
|
|
package/dist/index.mjs
CHANGED
|
@@ -1524,6 +1524,23 @@ function validateParserSchema(schema, parsed) {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
__name(validateParserSchema, "validateParserSchema");
|
|
1526
1526
|
|
|
1527
|
+
// src/utils/modules/errors.ts
|
|
1528
|
+
var _LlmExeError = class _LlmExeError extends Error {
|
|
1529
|
+
constructor(message, code, context) {
|
|
1530
|
+
super(message ?? "");
|
|
1531
|
+
__publicField(this, "code");
|
|
1532
|
+
__publicField(this, "context");
|
|
1533
|
+
this.name = this.constructor.name;
|
|
1534
|
+
this.code = code ?? "unknown";
|
|
1535
|
+
this.context = context;
|
|
1536
|
+
if (Error.captureStackTrace) {
|
|
1537
|
+
Error.captureStackTrace(this, this.constructor);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
__name(_LlmExeError, "LlmExeError");
|
|
1542
|
+
var LlmExeError = _LlmExeError;
|
|
1543
|
+
|
|
1527
1544
|
// src/parser/parsers/JsonParser.ts
|
|
1528
1545
|
var _JsonParser = class _JsonParser extends BaseParserWithJson {
|
|
1529
1546
|
constructor(options = {}) {
|
|
@@ -1536,7 +1553,11 @@ var _JsonParser = class _JsonParser extends BaseParserWithJson {
|
|
|
1536
1553
|
if (this.validateSchema) {
|
|
1537
1554
|
const valid = validateParserSchema(this.schema, enforce);
|
|
1538
1555
|
if (valid && valid.length) {
|
|
1539
|
-
throw new
|
|
1556
|
+
throw new LlmExeError(valid[0].message, "parser", {
|
|
1557
|
+
parser: "json",
|
|
1558
|
+
output: parsed,
|
|
1559
|
+
error: valid[0].message
|
|
1560
|
+
});
|
|
1540
1561
|
}
|
|
1541
1562
|
}
|
|
1542
1563
|
return enforce;
|
|
@@ -1581,7 +1602,11 @@ var _ListToJsonParser = class _ListToJsonParser extends BaseParserWithJson {
|
|
|
1581
1602
|
if (this?.validateSchema) {
|
|
1582
1603
|
const valid = validateParserSchema(this.schema, parsed);
|
|
1583
1604
|
if (valid && valid.length) {
|
|
1584
|
-
throw new
|
|
1605
|
+
throw new LlmExeError(valid[0].message, "parser", {
|
|
1606
|
+
parser: "json",
|
|
1607
|
+
output: parsed,
|
|
1608
|
+
error: valid[0].message
|
|
1609
|
+
});
|
|
1585
1610
|
}
|
|
1586
1611
|
}
|
|
1587
1612
|
return parsed;
|
|
@@ -2301,9 +2326,8 @@ var anthropic = {
|
|
|
2301
2326
|
"anthropic.chat.v1": anthropicChatV1,
|
|
2302
2327
|
"anthropic.claude-3-7-sonnet": withDefaultModel(anthropicChatV1, "claude-3-7-sonnet-latest"),
|
|
2303
2328
|
"anthropic.claude-3-5-sonnet": withDefaultModel(anthropicChatV1, "claude-3-5-sonnet-latest"),
|
|
2304
|
-
"anthropic.claude-3-
|
|
2305
|
-
"anthropic.claude-3-
|
|
2306
|
-
"anthropic.claude-3-haiku": withDefaultModel(anthropicChatV1, "claude-3-haiku-latest")
|
|
2329
|
+
"anthropic.claude-3-5-haiku": withDefaultModel(anthropicChatV1, "claude-3-5-haiku-latest"),
|
|
2330
|
+
"anthropic.claude-3-opus": withDefaultModel(anthropicChatV1, "claude-3-opus-latest")
|
|
2307
2331
|
};
|
|
2308
2332
|
|
|
2309
2333
|
// src/llm/config/x/index.ts
|
|
@@ -2424,10 +2448,6 @@ function googleGeminiPromptMessageCallback(_message) {
|
|
|
2424
2448
|
{
|
|
2425
2449
|
from: "assistant",
|
|
2426
2450
|
to: "model"
|
|
2427
|
-
},
|
|
2428
|
-
{
|
|
2429
|
-
from: "system",
|
|
2430
|
-
to: "model"
|
|
2431
2451
|
}
|
|
2432
2452
|
]);
|
|
2433
2453
|
const { role, ...payload } = message;
|
|
@@ -2447,14 +2467,47 @@ __name(googleGeminiPromptMessageCallback, "googleGeminiPromptMessageCallback");
|
|
|
2447
2467
|
// src/llm/config/google/promptSanitize.ts
|
|
2448
2468
|
function googleGeminiPromptSanitize(_messages, _inputBodyObj, _outputObj) {
|
|
2449
2469
|
if (typeof _messages === "string") {
|
|
2450
|
-
return
|
|
2470
|
+
return [
|
|
2471
|
+
{
|
|
2472
|
+
role: "user",
|
|
2473
|
+
parts: [
|
|
2474
|
+
{
|
|
2475
|
+
text: _messages
|
|
2476
|
+
}
|
|
2477
|
+
]
|
|
2478
|
+
}
|
|
2479
|
+
];
|
|
2451
2480
|
}
|
|
2452
2481
|
if (Array.isArray(_messages)) {
|
|
2453
2482
|
if (_messages.length === 0) {
|
|
2454
2483
|
throw new Error("Empty messages array");
|
|
2455
2484
|
}
|
|
2485
|
+
if (_messages.length === 1 && _messages[0].role === "system") {
|
|
2486
|
+
return [
|
|
2487
|
+
{
|
|
2488
|
+
role: "user",
|
|
2489
|
+
parts: [
|
|
2490
|
+
{
|
|
2491
|
+
text: _messages[0].content
|
|
2492
|
+
}
|
|
2493
|
+
]
|
|
2494
|
+
}
|
|
2495
|
+
];
|
|
2496
|
+
}
|
|
2497
|
+
const hasSystemInstruction = _messages.some((message) => message.role === "system");
|
|
2498
|
+
if (hasSystemInstruction) {
|
|
2499
|
+
const theSystemInstructions = _messages.filter((message) => message.role === "system");
|
|
2500
|
+
const withoutSystemInstructions = _messages.filter((message) => message.role !== "system");
|
|
2501
|
+
_outputObj.system_instruction = {
|
|
2502
|
+
parts: theSystemInstructions.map((message) => ({
|
|
2503
|
+
text: message.content
|
|
2504
|
+
}))
|
|
2505
|
+
};
|
|
2506
|
+
return withoutSystemInstructions.map(googleGeminiPromptMessageCallback);
|
|
2507
|
+
}
|
|
2508
|
+
return _messages.map(googleGeminiPromptMessageCallback);
|
|
2456
2509
|
}
|
|
2457
|
-
|
|
2510
|
+
throw new Error("Invalid messages format");
|
|
2458
2511
|
}
|
|
2459
2512
|
__name(googleGeminiPromptSanitize, "googleGeminiPromptSanitize");
|
|
2460
2513
|
|
|
@@ -2497,13 +2550,20 @@ var configs = {
|
|
|
2497
2550
|
};
|
|
2498
2551
|
function getLlmConfig(provider) {
|
|
2499
2552
|
if (!provider) {
|
|
2500
|
-
throw new
|
|
2553
|
+
throw new LlmExeError(`Missing provider`, "unknown", {
|
|
2554
|
+
error: "Missing provider",
|
|
2555
|
+
resolution: "Provide a valid provider"
|
|
2556
|
+
});
|
|
2501
2557
|
}
|
|
2502
2558
|
const pick2 = configs[provider];
|
|
2503
2559
|
if (pick2) {
|
|
2504
2560
|
return pick2;
|
|
2505
2561
|
}
|
|
2506
|
-
throw new
|
|
2562
|
+
throw new LlmExeError(`Invalid provider: ${provider}`, "unknown", {
|
|
2563
|
+
provider,
|
|
2564
|
+
error: `Invalid provider: ${provider}`,
|
|
2565
|
+
resolution: "Provide a valid provider"
|
|
2566
|
+
});
|
|
2507
2567
|
}
|
|
2508
2568
|
__name(getLlmConfig, "getLlmConfig");
|
|
2509
2569
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-exe",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
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",
|