llm-exe 2.1.5 → 2.1.7

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 CHANGED
@@ -934,6 +934,12 @@ interface GeminiRequest extends GenericLLm {
934
934
  model: string;
935
935
  geminiApiKey?: string;
936
936
  }
937
+ interface DeepseekRequest extends GenericLLm {
938
+ model: string;
939
+ responseFormat?: Record<string, any>;
940
+ deepseekApiKey?: string;
941
+ useJson?: boolean;
942
+ }
937
943
  type AllEmbedding = {
938
944
  "openai.embedding.v1": {
939
945
  input: OpenAiEmbeddingOptions;
@@ -967,6 +973,9 @@ type AllLlm = {
967
973
  "google.chat.v1": {
968
974
  input: GeminiRequest;
969
975
  };
976
+ "deepseek.chat.v1": {
977
+ input: DeepseekRequest;
978
+ };
970
979
  };
971
980
  type AllUseLlmOptions = AllLlm & {
972
981
  "openai.gpt-4": {
@@ -990,7 +999,7 @@ type AllUseLlmOptions = AllLlm & {
990
999
  "anthropic.claude-3-sonnet": {
991
1000
  input: Omit<AnthropicRequest, "model">;
992
1001
  };
993
- "anthropic.claude-3-haiku": {
1002
+ "anthropic.claude-3-5-haiku": {
994
1003
  input: Omit<AnthropicRequest, "model">;
995
1004
  };
996
1005
  "google.gemini-2.5-pro-exp-03-25": {
@@ -1023,6 +1032,9 @@ type AllUseLlmOptions = AllLlm & {
1023
1032
  "ollama.qwq": {
1024
1033
  input: GenericLLm;
1025
1034
  };
1035
+ "deepseek.chat": {
1036
+ input: DeepseekRequest;
1037
+ };
1026
1038
  };
1027
1039
  type LlmProviderKey = keyof AllLlm;
1028
1040
  type EmbeddingProviderKey = keyof AllEmbedding;
@@ -1040,7 +1052,7 @@ interface BaseRequest<_T extends Record<string, any>> {
1040
1052
  interface BaseLlm<_T extends BaseLlCall = BaseLlCall> extends BaseRequest<_T> {
1041
1053
  }
1042
1054
 
1043
- type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "xai.chat" | "google.chat" | "ollama.chat";
1055
+ type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
1044
1056
  interface Config<Pk = LlmProviderKey> {
1045
1057
  key: Pk;
1046
1058
  provider: LlmProvider;
@@ -1219,6 +1231,8 @@ declare namespace index {
1219
1231
  }
1220
1232
 
1221
1233
  declare const configs: {
1234
+ "deepseek.chat.v1": Config<keyof AllLlm>;
1235
+ "deepseek.chat": Config<keyof AllLlm>;
1222
1236
  "google.chat.v1": Config<keyof AllLlm>;
1223
1237
  "google.gemini-2.0-flash": Config<keyof AllLlm>;
1224
1238
  "google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
@@ -1236,9 +1250,8 @@ declare const configs: {
1236
1250
  "anthropic.chat.v1": Config<keyof AllLlm>;
1237
1251
  "anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
1238
1252
  "anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
1253
+ "anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
1239
1254
  "anthropic.claude-3-opus": Config<keyof AllLlm>;
1240
- "anthropic.claude-3-sonnet": Config<keyof AllLlm>;
1241
- "anthropic.claude-3-haiku": Config<keyof AllLlm>;
1242
1255
  "openai.chat.v1": Config<keyof AllLlm>;
1243
1256
  "openai.chat-mock.v1": Config<keyof AllLlm>;
1244
1257
  "openai.gpt-4o": Config<keyof AllLlm>;
package/dist/index.d.ts CHANGED
@@ -934,6 +934,12 @@ interface GeminiRequest extends GenericLLm {
934
934
  model: string;
935
935
  geminiApiKey?: string;
936
936
  }
937
+ interface DeepseekRequest extends GenericLLm {
938
+ model: string;
939
+ responseFormat?: Record<string, any>;
940
+ deepseekApiKey?: string;
941
+ useJson?: boolean;
942
+ }
937
943
  type AllEmbedding = {
938
944
  "openai.embedding.v1": {
939
945
  input: OpenAiEmbeddingOptions;
@@ -967,6 +973,9 @@ type AllLlm = {
967
973
  "google.chat.v1": {
968
974
  input: GeminiRequest;
969
975
  };
976
+ "deepseek.chat.v1": {
977
+ input: DeepseekRequest;
978
+ };
970
979
  };
971
980
  type AllUseLlmOptions = AllLlm & {
972
981
  "openai.gpt-4": {
@@ -990,7 +999,7 @@ type AllUseLlmOptions = AllLlm & {
990
999
  "anthropic.claude-3-sonnet": {
991
1000
  input: Omit<AnthropicRequest, "model">;
992
1001
  };
993
- "anthropic.claude-3-haiku": {
1002
+ "anthropic.claude-3-5-haiku": {
994
1003
  input: Omit<AnthropicRequest, "model">;
995
1004
  };
996
1005
  "google.gemini-2.5-pro-exp-03-25": {
@@ -1023,6 +1032,9 @@ type AllUseLlmOptions = AllLlm & {
1023
1032
  "ollama.qwq": {
1024
1033
  input: GenericLLm;
1025
1034
  };
1035
+ "deepseek.chat": {
1036
+ input: DeepseekRequest;
1037
+ };
1026
1038
  };
1027
1039
  type LlmProviderKey = keyof AllLlm;
1028
1040
  type EmbeddingProviderKey = keyof AllEmbedding;
@@ -1040,7 +1052,7 @@ interface BaseRequest<_T extends Record<string, any>> {
1040
1052
  interface BaseLlm<_T extends BaseLlCall = BaseLlCall> extends BaseRequest<_T> {
1041
1053
  }
1042
1054
 
1043
- type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "xai.chat" | "google.chat" | "ollama.chat";
1055
+ type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
1044
1056
  interface Config<Pk = LlmProviderKey> {
1045
1057
  key: Pk;
1046
1058
  provider: LlmProvider;
@@ -1219,6 +1231,8 @@ declare namespace index {
1219
1231
  }
1220
1232
 
1221
1233
  declare const configs: {
1234
+ "deepseek.chat.v1": Config<keyof AllLlm>;
1235
+ "deepseek.chat": Config<keyof AllLlm>;
1222
1236
  "google.chat.v1": Config<keyof AllLlm>;
1223
1237
  "google.gemini-2.0-flash": Config<keyof AllLlm>;
1224
1238
  "google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
@@ -1236,9 +1250,8 @@ declare const configs: {
1236
1250
  "anthropic.chat.v1": Config<keyof AllLlm>;
1237
1251
  "anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
1238
1252
  "anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
1253
+ "anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
1239
1254
  "anthropic.claude-3-opus": Config<keyof AllLlm>;
1240
- "anthropic.claude-3-sonnet": Config<keyof AllLlm>;
1241
- "anthropic.claude-3-haiku": Config<keyof AllLlm>;
1242
1255
  "openai.chat.v1": Config<keyof AllLlm>;
1243
1256
  "openai.chat-mock.v1": Config<keyof AllLlm>;
1244
1257
  "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 Error(valid[0].message);
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 Error(valid[0].message);
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-opus": withDefaultModel(anthropicChatV1, "claude-3-opus-latest"),
2353
- "anthropic.claude-3-sonnet": withDefaultModel(anthropicChatV1, "claude-3-sonnet-latest"),
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 _messages;
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
- return _messages.map(googleGeminiPromptMessageCallback);
2558
+ throw new Error("Invalid messages format");
2506
2559
  }
2507
2560
  __name(googleGeminiPromptSanitize, "googleGeminiPromptSanitize");
2508
2561
 
@@ -2534,6 +2587,53 @@ var google = {
2534
2587
  "google.gemini-1.5-pro": withDefaultModel(googleGeminiChatV1, "gemini-1.5-pro")
2535
2588
  };
2536
2589
 
2590
+ // src/llm/config/deepseek/index.ts
2591
+ var deepseekChatV1 = {
2592
+ key: "deepseek.chat.v1",
2593
+ provider: "deepseek.chat",
2594
+ endpoint: `https://api.deepseek.com/v1/chat/completions`,
2595
+ options: {
2596
+ prompt: {},
2597
+ topP: {},
2598
+ useJson: {},
2599
+ deepseekApiKey: {
2600
+ default: getEnvironmentVariable("DEEPSEEK_API_KEY")
2601
+ }
2602
+ },
2603
+ method: "POST",
2604
+ headers: `{"Authorization":"Bearer {{deepseekApiKey}}", "Content-Type": "application/json" }`,
2605
+ mapBody: {
2606
+ prompt: {
2607
+ key: "messages",
2608
+ sanitize: /* @__PURE__ */ __name((v) => {
2609
+ if (typeof v === "string") {
2610
+ return [
2611
+ {
2612
+ role: "user",
2613
+ content: v
2614
+ }
2615
+ ];
2616
+ }
2617
+ return v;
2618
+ }, "sanitize")
2619
+ },
2620
+ model: {
2621
+ key: "model"
2622
+ },
2623
+ topP: {
2624
+ key: "top_p"
2625
+ },
2626
+ useJson: {
2627
+ key: "response_format.type",
2628
+ sanitize: /* @__PURE__ */ __name((v) => v ? "json_object" : "text", "sanitize")
2629
+ }
2630
+ }
2631
+ };
2632
+ var deepseek = {
2633
+ "deepseek.chat.v1": deepseekChatV1,
2634
+ "deepseek.chat": withDefaultModel(deepseekChatV1, "deepseek-chat")
2635
+ };
2636
+
2537
2637
  // src/llm/config.ts
2538
2638
  var configs = {
2539
2639
  ...openai,
@@ -2541,17 +2641,25 @@ var configs = {
2541
2641
  ...bedrock,
2542
2642
  ...xai,
2543
2643
  ...ollama,
2544
- ...google
2644
+ ...google,
2645
+ ...deepseek
2545
2646
  };
2546
2647
  function getLlmConfig(provider) {
2547
2648
  if (!provider) {
2548
- throw new Error(`Missing provider`);
2649
+ throw new LlmExeError(`Missing provider`, "unknown", {
2650
+ error: "Missing provider",
2651
+ resolution: "Provide a valid provider"
2652
+ });
2549
2653
  }
2550
2654
  const pick2 = configs[provider];
2551
2655
  if (pick2) {
2552
2656
  return pick2;
2553
2657
  }
2554
- throw new Error(`Invalid provider: ${provider}`);
2658
+ throw new LlmExeError(`Invalid provider: ${provider}`, "unknown", {
2659
+ provider,
2660
+ error: `Invalid provider: ${provider}`,
2661
+ resolution: "Provide a valid provider"
2662
+ });
2555
2663
  }
2556
2664
  __name(getLlmConfig, "getLlmConfig");
2557
2665
 
@@ -2967,6 +3075,9 @@ function getOutputParser(config, response) {
2967
3075
  return OutputOllamaChat(response, config);
2968
3076
  case "google.chat.v1":
2969
3077
  return OutputGoogleGeminiChat(response, config);
3078
+ case "deepseek.chat.v1":
3079
+ return OutputOpenAIChat(response, config);
3080
+ // use oai for now
2970
3081
  default: {
2971
3082
  if (config?.key?.startsWith("custom:")) {
2972
3083
  return OutputDefault(response, config);
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 Error(valid[0].message);
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 Error(valid[0].message);
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-opus": withDefaultModel(anthropicChatV1, "claude-3-opus-latest"),
2305
- "anthropic.claude-3-sonnet": withDefaultModel(anthropicChatV1, "claude-3-sonnet-latest"),
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 _messages;
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
- return _messages.map(googleGeminiPromptMessageCallback);
2510
+ throw new Error("Invalid messages format");
2458
2511
  }
2459
2512
  __name(googleGeminiPromptSanitize, "googleGeminiPromptSanitize");
2460
2513
 
@@ -2486,6 +2539,53 @@ var google = {
2486
2539
  "google.gemini-1.5-pro": withDefaultModel(googleGeminiChatV1, "gemini-1.5-pro")
2487
2540
  };
2488
2541
 
2542
+ // src/llm/config/deepseek/index.ts
2543
+ var deepseekChatV1 = {
2544
+ key: "deepseek.chat.v1",
2545
+ provider: "deepseek.chat",
2546
+ endpoint: `https://api.deepseek.com/v1/chat/completions`,
2547
+ options: {
2548
+ prompt: {},
2549
+ topP: {},
2550
+ useJson: {},
2551
+ deepseekApiKey: {
2552
+ default: getEnvironmentVariable("DEEPSEEK_API_KEY")
2553
+ }
2554
+ },
2555
+ method: "POST",
2556
+ headers: `{"Authorization":"Bearer {{deepseekApiKey}}", "Content-Type": "application/json" }`,
2557
+ mapBody: {
2558
+ prompt: {
2559
+ key: "messages",
2560
+ sanitize: /* @__PURE__ */ __name((v) => {
2561
+ if (typeof v === "string") {
2562
+ return [
2563
+ {
2564
+ role: "user",
2565
+ content: v
2566
+ }
2567
+ ];
2568
+ }
2569
+ return v;
2570
+ }, "sanitize")
2571
+ },
2572
+ model: {
2573
+ key: "model"
2574
+ },
2575
+ topP: {
2576
+ key: "top_p"
2577
+ },
2578
+ useJson: {
2579
+ key: "response_format.type",
2580
+ sanitize: /* @__PURE__ */ __name((v) => v ? "json_object" : "text", "sanitize")
2581
+ }
2582
+ }
2583
+ };
2584
+ var deepseek = {
2585
+ "deepseek.chat.v1": deepseekChatV1,
2586
+ "deepseek.chat": withDefaultModel(deepseekChatV1, "deepseek-chat")
2587
+ };
2588
+
2489
2589
  // src/llm/config.ts
2490
2590
  var configs = {
2491
2591
  ...openai,
@@ -2493,17 +2593,25 @@ var configs = {
2493
2593
  ...bedrock,
2494
2594
  ...xai,
2495
2595
  ...ollama,
2496
- ...google
2596
+ ...google,
2597
+ ...deepseek
2497
2598
  };
2498
2599
  function getLlmConfig(provider) {
2499
2600
  if (!provider) {
2500
- throw new Error(`Missing provider`);
2601
+ throw new LlmExeError(`Missing provider`, "unknown", {
2602
+ error: "Missing provider",
2603
+ resolution: "Provide a valid provider"
2604
+ });
2501
2605
  }
2502
2606
  const pick2 = configs[provider];
2503
2607
  if (pick2) {
2504
2608
  return pick2;
2505
2609
  }
2506
- throw new Error(`Invalid provider: ${provider}`);
2610
+ throw new LlmExeError(`Invalid provider: ${provider}`, "unknown", {
2611
+ provider,
2612
+ error: `Invalid provider: ${provider}`,
2613
+ resolution: "Provide a valid provider"
2614
+ });
2507
2615
  }
2508
2616
  __name(getLlmConfig, "getLlmConfig");
2509
2617
 
@@ -2919,6 +3027,9 @@ function getOutputParser(config, response) {
2919
3027
  return OutputOllamaChat(response, config);
2920
3028
  case "google.chat.v1":
2921
3029
  return OutputGoogleGeminiChat(response, config);
3030
+ case "deepseek.chat.v1":
3031
+ return OutputOpenAIChat(response, config);
3032
+ // use oai for now
2922
3033
  default: {
2923
3034
  if (config?.key?.startsWith("custom:")) {
2924
3035
  return OutputDefault(response, config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-exe",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
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",
package/readme.md CHANGED
@@ -7,7 +7,7 @@ A package that provides simplified base components to make building and maintain
7
7
  - Write functions powered by LLM's with easy to use building blocks.
8
8
  - Pure Javascript and Typescript. Allows you to pass and infer types.
9
9
  - Support for text-based (llama-3) and chat-based prompts. (gpt-4o, claude-3.5, grok-3, Gemini, Bedrock, Ollama, etc)
10
- - Call LLM's from different providers without changing your code. (OpenAi/Anthropic/xAI/Google/AWS Bedrock/Ollama)
10
+ - Call LLM's from different providers without changing your code. (OpenAi/Anthropic/xAI/Google/AWS Bedrock/Ollama/Deepseek)
11
11
  - Supercharge your prompts by using handlebars within prompt template.
12
12
  - Allow LLM's to call functions (or call other LLM executors).
13
13
  - Not very opinionated. You have control on how you use it.