llm-exe 2.3.5 → 2.3.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.js CHANGED
@@ -557,6 +557,21 @@ function toNumber(value) {
557
557
  return NaN;
558
558
  }
559
559
 
560
+ // src/utils/modules/errors.ts
561
+ var LlmExeError = class extends Error {
562
+ constructor(message, code, context) {
563
+ super(message ?? "");
564
+ __publicField(this, "code");
565
+ __publicField(this, "context");
566
+ this.name = this.constructor.name;
567
+ this.code = code ?? "unknown";
568
+ this.context = context;
569
+ if (Error.captureStackTrace) {
570
+ Error.captureStackTrace(this, this.constructor);
571
+ }
572
+ }
573
+ };
574
+
560
575
  // src/parser/parsers/NumberParser.ts
561
576
  var NumberParser = class extends BaseParser {
562
577
  constructor(options) {
@@ -564,7 +579,18 @@ var NumberParser = class extends BaseParser {
564
579
  }
565
580
  parse(text) {
566
581
  const match = text.match(/-?\d+(\.\d+)?/);
567
- return match && isFinite(toNumber(match[0])) ? toNumber(match[0]) : -1;
582
+ if (match && isFinite(toNumber(match[0]))) {
583
+ return toNumber(match[0]);
584
+ }
585
+ throw new LlmExeError(
586
+ `No numeric value found in input.`,
587
+ "parser",
588
+ {
589
+ parser: "number",
590
+ output: text,
591
+ error: `No numeric value found in input.`
592
+ }
593
+ );
568
594
  }
569
595
  };
570
596
 
@@ -1461,7 +1487,7 @@ var asyncCallWithTimeout = async (asyncPromise, timeLimit = 1e4) => {
1461
1487
  const timeoutPromise = new Promise((_resolve, reject) => {
1462
1488
  timeoutHandle = setTimeout(() => {
1463
1489
  return reject(
1464
- new Error("Unable to perform action. Try again, or use another action.")
1490
+ new Error(`LLM call timed out after ${timeLimit}ms`)
1465
1491
  );
1466
1492
  }, timeLimit);
1467
1493
  });
@@ -1549,21 +1575,6 @@ function validateParserSchema(schema, parsed) {
1549
1575
  return null;
1550
1576
  }
1551
1577
 
1552
- // src/utils/modules/errors.ts
1553
- var LlmExeError = class extends Error {
1554
- constructor(message, code, context) {
1555
- super(message ?? "");
1556
- __publicField(this, "code");
1557
- __publicField(this, "context");
1558
- this.name = this.constructor.name;
1559
- this.code = code ?? "unknown";
1560
- this.context = context;
1561
- if (Error.captureStackTrace) {
1562
- Error.captureStackTrace(this, this.constructor);
1563
- }
1564
- }
1565
- };
1566
-
1567
1578
  // src/parser/parsers/JsonParser.ts
1568
1579
  var JsonParser = class extends BaseParserWithJson {
1569
1580
  constructor(options = {}) {
@@ -1607,6 +1618,8 @@ function camelCase(input) {
1607
1618
  var ListToJsonParser = class extends BaseParserWithJson {
1608
1619
  constructor(options = {}) {
1609
1620
  super("listToJson", options);
1621
+ __publicField(this, "keyTransform");
1622
+ this.keyTransform = options.keyTransform ?? "camelCase";
1610
1623
  }
1611
1624
  parse(text) {
1612
1625
  const lines = text.split("\n");
@@ -1617,7 +1630,8 @@ var ListToJsonParser = class extends BaseParserWithJson {
1617
1630
  const key = line.slice(0, colonIndex);
1618
1631
  const value = line.slice(colonIndex + 1).trim();
1619
1632
  if (value) {
1620
- output[camelCase(key)] = value;
1633
+ const transformedKey = this.keyTransform === "preserve" ? key.trim() : camelCase(key);
1634
+ output[transformedKey] = value;
1621
1635
  }
1622
1636
  }
1623
1637
  });
@@ -1790,7 +1804,15 @@ var StringExtractParser = class extends BaseParser {
1790
1804
  return option;
1791
1805
  }
1792
1806
  }
1793
- return "";
1807
+ throw new LlmExeError(
1808
+ `No matching enum value found in input.`,
1809
+ "parser",
1810
+ {
1811
+ parser: "stringExtract",
1812
+ output: text,
1813
+ error: `No matching enum value found in input. Expected one of: ${this.enum.join(", ")}`
1814
+ }
1815
+ );
1794
1816
  }
1795
1817
  };
1796
1818
 
@@ -2307,6 +2329,7 @@ function cleanJsonSchemaFor(schema = {}, provider) {
2307
2329
  // src/llm/config/openai/compatible.ts
2308
2330
  function createOpenAiCompatibleConfiguration(overrides) {
2309
2331
  const [apiKeyPropertyKey, apiKeyPropertyValue] = overrides.apiKeyMapping;
2332
+ const isReasoningModel = overrides.isReasoningModel ?? (() => false);
2310
2333
  const config = {
2311
2334
  key: overrides.key,
2312
2335
  provider: overrides.provider,
@@ -2360,10 +2383,7 @@ function createOpenAiCompatibleConfiguration(overrides) {
2360
2383
  effort: {
2361
2384
  key: "reasoning_effort",
2362
2385
  transform: (v, _s) => {
2363
- if (
2364
- // only supported reasoning models
2365
- ["gpt-5"].includes(_s.model) && typeof v === "string" && ["minimal", "low", "medium", "high"].includes(v)
2366
- ) {
2386
+ if (typeof _s.model === "string" && isReasoningModel(_s.model) && typeof v === "string" && ["minimal", "low", "medium", "high"].includes(v)) {
2367
2387
  return v;
2368
2388
  }
2369
2389
  return void 0;
@@ -2410,7 +2430,8 @@ var openAiChatV1 = createOpenAiCompatibleConfiguration({
2410
2430
  key: "openai.chat.v1",
2411
2431
  provider: "openai.chat",
2412
2432
  endpoint: `https://api.openai.com/v1/chat/completions`,
2413
- apiKeyMapping: ["openAiApiKey", "OPENAI_API_KEY"]
2433
+ apiKeyMapping: ["openAiApiKey", "OPENAI_API_KEY"],
2434
+ isReasoningModel: (model) => model.startsWith("gpt-5") || model.startsWith("o3") || model.startsWith("o4")
2414
2435
  });
2415
2436
  var openAiChatMockV1 = {
2416
2437
  key: "openai.chat-mock.v1",
@@ -2456,10 +2477,12 @@ var openai = {
2456
2477
  "openai.gpt-4.1-nano": withDefaultModel(openAiChatV1, "gpt-4.1-nano"),
2457
2478
  // Reasoning models
2458
2479
  "openai.o3": withDefaultModel(openAiChatV1, "o3"),
2459
- "openai.o4-mini": withDefaultModel(openAiChatV1, "o4-mini"),
2460
2480
  // GPT-4o family
2481
+ "openai.gpt-4": withDefaultModel(openAiChatV1, "gpt-4"),
2461
2482
  "openai.gpt-4o": withDefaultModel(openAiChatV1, "gpt-4o"),
2462
- "openai.gpt-4o-mini": withDefaultModel(openAiChatV1, "gpt-4o-mini")
2483
+ "openai.gpt-4o-mini": withDefaultModel(openAiChatV1, "gpt-4o-mini"),
2484
+ // Deprecated
2485
+ "openai.o4-mini": withDefaultModel(openAiChatV1, "o4-mini")
2463
2486
  };
2464
2487
 
2465
2488
  // src/llm/config/anthropic/promptSanitizeMessageCallback.ts
@@ -2719,6 +2742,14 @@ var bedrock = {
2719
2742
 
2720
2743
  // src/llm/config/anthropic/index.ts
2721
2744
  var ANTHROPIC_VERSION = "2023-06-01";
2745
+ var MODELS_REJECTING_SAMPLING_PARAMS = ["claude-opus-4-7"];
2746
+ var isClaude4x = (model) => /^claude-(opus|sonnet|haiku)-4-/.test(model);
2747
+ var dropIfModelRejectsSamplingParams = (v, body) => MODELS_REJECTING_SAMPLING_PARAMS.includes(body.model) ? void 0 : v;
2748
+ var topPTransform = (v, body) => {
2749
+ if (MODELS_REJECTING_SAMPLING_PARAMS.includes(body.model)) return void 0;
2750
+ if (isClaude4x(body.model) && body.temperature !== void 0) return void 0;
2751
+ return v;
2752
+ };
2722
2753
  var anthropicChatV1 = {
2723
2754
  key: "anthropic.chat.v1",
2724
2755
  provider: "anthropic.chat",
@@ -2751,13 +2782,16 @@ var anthropicChatV1 = {
2751
2782
  transform: anthropicPromptSanitize
2752
2783
  },
2753
2784
  temperature: {
2754
- key: "temperature"
2785
+ key: "temperature",
2786
+ transform: dropIfModelRejectsSamplingParams
2755
2787
  },
2756
2788
  topP: {
2757
- key: "top_p"
2789
+ key: "top_p",
2790
+ transform: topPTransform
2758
2791
  },
2759
2792
  topK: {
2760
- key: "top_k"
2793
+ key: "top_k",
2794
+ transform: dropIfModelRejectsSamplingParams
2761
2795
  },
2762
2796
  stopSequences: {
2763
2797
  key: "stop_sequences"
@@ -2793,6 +2827,11 @@ var anthropicChatV1 = {
2793
2827
  };
2794
2828
  var anthropic = {
2795
2829
  "anthropic.chat.v1": anthropicChatV1,
2830
+ // Claude 4.7 models
2831
+ "anthropic.claude-opus-4-7": withDefaultModel(
2832
+ anthropicChatV1,
2833
+ "claude-opus-4-7"
2834
+ ),
2796
2835
  // Claude 4.6 models
2797
2836
  "anthropic.claude-opus-4-6": withDefaultModel(
2798
2837
  anthropicChatV1,
@@ -2802,7 +2841,20 @@ var anthropic = {
2802
2841
  anthropicChatV1,
2803
2842
  "claude-sonnet-4-6"
2804
2843
  ),
2805
- // Claude 4 models
2844
+ // Claude 4.5 models
2845
+ "anthropic.claude-haiku-4-5": withDefaultModel(
2846
+ anthropicChatV1,
2847
+ "claude-haiku-4-5"
2848
+ ),
2849
+ "anthropic.claude-sonnet-4-5": withDefaultModel(
2850
+ anthropicChatV1,
2851
+ "claude-sonnet-4-5"
2852
+ ),
2853
+ // Deprecated
2854
+ "anthropic.claude-opus-4-1": withDefaultModel(
2855
+ anthropicChatV1,
2856
+ "claude-opus-4-1-20250805"
2857
+ ),
2806
2858
  "anthropic.claude-sonnet-4": withDefaultModel(
2807
2859
  anthropicChatV1,
2808
2860
  "claude-sonnet-4-0"
@@ -2811,7 +2863,6 @@ var anthropic = {
2811
2863
  anthropicChatV1,
2812
2864
  "claude-opus-4-0"
2813
2865
  ),
2814
- // Deprecated
2815
2866
  "anthropic.claude-3-7-sonnet": withDefaultModel(
2816
2867
  anthropicChatV1,
2817
2868
  "claude-3-7-sonnet-20250219"
@@ -2827,10 +2878,6 @@ var anthropic = {
2827
2878
  "anthropic.claude-3-opus": withDefaultModel(
2828
2879
  anthropicChatV1,
2829
2880
  "claude-3-opus-20240229"
2830
- ),
2831
- "anthropic.claude-3-haiku": withDefaultModel(
2832
- anthropicChatV1,
2833
- "claude-3-haiku-20240307"
2834
2881
  )
2835
2882
  };
2836
2883
 
@@ -2839,7 +2886,13 @@ var xaiChatV1 = createOpenAiCompatibleConfiguration({
2839
2886
  key: "xai.chat.v1",
2840
2887
  provider: "xai.chat",
2841
2888
  endpoint: `https://api.x.ai/v1/chat/completions`,
2842
- apiKeyMapping: ["xAiApiKey", "XAI_API_KEY"]
2889
+ apiKeyMapping: ["xAiApiKey", "XAI_API_KEY"],
2890
+ // Per xAI docs (checked 2026-05-13), grok-4 errors if `reasoning_effort` is
2891
+ // sent; grok-3-mini and the fast-non-reasoning variants don't accept it
2892
+ // either. Only grok-4.3 and grok-4.20-multi-agent support it, and neither
2893
+ // has a shorthand here yet. Leave the predicate empty so effort is dropped
2894
+ // for every currently-shipped xAI shorthand.
2895
+ isReasoningModel: () => false
2843
2896
  });
2844
2897
  var xai = {
2845
2898
  "xai.chat.v1": xaiChatV1,
@@ -2847,7 +2900,8 @@ var xai = {
2847
2900
  "xai.grok-3": withDefaultModel(xaiChatV1, "grok-3"),
2848
2901
  "xai.grok-3-mini": withDefaultModel(xaiChatV1, "grok-3-mini"),
2849
2902
  "xai.grok-4": withDefaultModel(xaiChatV1, "grok-4"),
2850
- "xai.grok-4-fast": withDefaultModel(xaiChatV1, "grok-4-fast-non-reasoning")
2903
+ "xai.grok-4-fast": withDefaultModel(xaiChatV1, "grok-4-fast-non-reasoning"),
2904
+ "xai.grok-4-1-fast": withDefaultModel(xaiChatV1, "grok-4-1-fast-non-reasoning")
2851
2905
  };
2852
2906
 
2853
2907
  // src/llm/output/_utils/combineJsonl.ts
@@ -2954,7 +3008,11 @@ var ollama = {
2954
3008
  "ollama.llama3.3": withDefaultModel(ollamaChatV1, "llama3.3"),
2955
3009
  "ollama.llama3.2": withDefaultModel(ollamaChatV1, "llama3.2"),
2956
3010
  "ollama.llama3.1": withDefaultModel(ollamaChatV1, "llama3.1"),
2957
- "ollama.qwq": withDefaultModel(ollamaChatV1, "qwq")
3011
+ "ollama.qwq": withDefaultModel(ollamaChatV1, "qwq"),
3012
+ "ollama.gemma3": withDefaultModel(ollamaChatV1, "gemma3"),
3013
+ "ollama.mistral": withDefaultModel(ollamaChatV1, "mistral"),
3014
+ "ollama.qwen2.5": withDefaultModel(ollamaChatV1, "qwen2.5"),
3015
+ "ollama.qwen3": withDefaultModel(ollamaChatV1, "qwen3")
2958
3016
  };
2959
3017
 
2960
3018
  // src/llm/config/google/promptSanitizeMessageCallback.ts
@@ -3171,14 +3229,6 @@ var googleGeminiChatV1 = {
3171
3229
  };
3172
3230
  var google = {
3173
3231
  "google.chat.v1": googleGeminiChatV1,
3174
- "google.gemini-2.0-flash": withDefaultModel(
3175
- googleGeminiChatV1,
3176
- "gemini-2.0-flash"
3177
- ),
3178
- "google.gemini-2.0-flash-lite": withDefaultModel(
3179
- googleGeminiChatV1,
3180
- "gemini-2.0-flash-lite"
3181
- ),
3182
3232
  "google.gemini-2.5-flash": withDefaultModel(
3183
3233
  googleGeminiChatV1,
3184
3234
  "gemini-2.5-flash"
@@ -3187,13 +3237,22 @@ var google = {
3187
3237
  googleGeminiChatV1,
3188
3238
  "gemini-2.5-flash-lite"
3189
3239
  ),
3190
- "google.gemini-1.5-pro": withDefaultModel(
3191
- googleGeminiChatV1,
3192
- "gemini-1.5-pro"
3193
- ),
3194
3240
  "google.gemini-2.5-pro": withDefaultModel(
3195
3241
  googleGeminiChatV1,
3196
3242
  "gemini-2.5-pro"
3243
+ ),
3244
+ // Deprecated
3245
+ "google.gemini-2.0-flash": withDefaultModel(
3246
+ googleGeminiChatV1,
3247
+ "gemini-2.0-flash"
3248
+ ),
3249
+ "google.gemini-2.0-flash-lite": withDefaultModel(
3250
+ googleGeminiChatV1,
3251
+ "gemini-2.0-flash-lite"
3252
+ ),
3253
+ "google.gemini-1.5-pro": withDefaultModel(
3254
+ googleGeminiChatV1,
3255
+ "gemini-1.5-pro"
3197
3256
  )
3198
3257
  };
3199
3258
 
@@ -3206,7 +3265,9 @@ var deepseekChatV1 = createOpenAiCompatibleConfiguration({
3206
3265
  });
3207
3266
  var deepseek = {
3208
3267
  "deepseek.chat.v1": deepseekChatV1,
3209
- "deepseek.chat": withDefaultModel(deepseekChatV1, "deepseek-chat")
3268
+ "deepseek.chat": withDefaultModel(deepseekChatV1, "deepseek-chat"),
3269
+ "deepseek.v4-flash": withDefaultModel(deepseekChatV1, "deepseek-v4-flash"),
3270
+ "deepseek.v4-pro": withDefaultModel(deepseekChatV1, "deepseek-v4-pro")
3210
3271
  };
3211
3272
 
3212
3273
  // src/llm/config.ts
@@ -3321,12 +3382,19 @@ async function apiRequest(url, options) {
3321
3382
  const response = await fetch(url, finalOptions);
3322
3383
  if (!response.ok) {
3323
3384
  let message = `HTTP error. Status: ${response.status}. Error Message: ${response?.statusText || "Unknown error."}`;
3324
- if (url.startsWith("https://api.openai.com/")) {
3325
- try {
3326
- const body = await response.json();
3327
- message = `HTTP error. Status Code: ${response.status}. Error Message: ${body?.error?.message || "No further details provided."}`;
3328
- } catch (error) {
3385
+ try {
3386
+ const text = await response.text();
3387
+ if (text) {
3388
+ let detail = text;
3389
+ try {
3390
+ const body = JSON.parse(text);
3391
+ detail = body?.error?.message || body?.error || body?.message || text;
3392
+ if (typeof detail !== "string") detail = JSON.stringify(detail);
3393
+ } catch {
3394
+ }
3395
+ message = `HTTP error. Status Code: ${response.status}. Error Message: ${detail}`;
3329
3396
  }
3397
+ } catch {
3330
3398
  }
3331
3399
  throw new Error(message);
3332
3400
  }
@@ -3906,6 +3974,26 @@ function AmazonTitanEmbedding(result, config) {
3906
3974
  });
3907
3975
  }
3908
3976
 
3977
+ // src/embedding/output/CohereBedrockEmbedding.ts
3978
+ function CohereBedrockEmbedding(result, config) {
3979
+ const __result = deepClone(result);
3980
+ const model = config.model || "cohere.unknown";
3981
+ const created = (/* @__PURE__ */ new Date()).getTime();
3982
+ const embedding = Array.isArray(__result.embeddings) ? __result.embeddings : [];
3983
+ const usage = {
3984
+ output_tokens: 0,
3985
+ input_tokens: 0,
3986
+ total_tokens: 0
3987
+ };
3988
+ return BaseEmbeddingOutput({
3989
+ id: __result.id,
3990
+ model,
3991
+ created,
3992
+ usage,
3993
+ embedding
3994
+ });
3995
+ }
3996
+
3909
3997
  // src/embedding/config.ts
3910
3998
  var embeddingConfigs = {
3911
3999
  "openai.embedding.v1": {
@@ -3967,6 +4055,43 @@ var embeddingConfigs = {
3967
4055
  }
3968
4056
  },
3969
4057
  transformResponse: AmazonTitanEmbedding
4058
+ },
4059
+ "amazon:cohere.embedding.v1": {
4060
+ key: "amazon:cohere.embedding.v1",
4061
+ provider: "amazon:cohere.embedding",
4062
+ endpoint: `https://bedrock-runtime.{{awsRegion}}.amazonaws.com/model/{{model}}/invoke`,
4063
+ method: "POST",
4064
+ headers: `{"Content-Type": "application/json" }`,
4065
+ options: {
4066
+ input: {},
4067
+ inputType: {
4068
+ default: "search_document"
4069
+ },
4070
+ truncate: {},
4071
+ dimensions: {},
4072
+ awsRegion: {
4073
+ default: getEnvironmentVariable("AWS_REGION"),
4074
+ required: [true, "aws region is required"]
4075
+ },
4076
+ awsSecretKey: {},
4077
+ awsAccessKey: {}
4078
+ },
4079
+ mapBody: {
4080
+ input: {
4081
+ key: "texts",
4082
+ transform: (value) => Array.isArray(value) ? value : [value]
4083
+ },
4084
+ inputType: {
4085
+ key: "input_type"
4086
+ },
4087
+ truncate: {
4088
+ key: "truncate"
4089
+ },
4090
+ dimensions: {
4091
+ key: "output_dimension"
4092
+ }
4093
+ },
4094
+ transformResponse: CohereBedrockEmbedding
3970
4095
  }
3971
4096
  };
3972
4097
  function getEmbeddingConfig(provider) {
@@ -3987,6 +4112,8 @@ function getEmbeddingOutputParser(config, response) {
3987
4112
  return OpenAiEmbedding(response, config);
3988
4113
  case "amazon.embedding.v1":
3989
4114
  return AmazonTitanEmbedding(response, config);
4115
+ case "amazon:cohere.embedding.v1":
4116
+ return CohereBedrockEmbedding(response, config);
3990
4117
  default:
3991
4118
  throw new Error("Unsupported provider");
3992
4119
  }
@@ -4158,6 +4285,11 @@ var BasePrompt = class {
4158
4285
  return promptValue;
4159
4286
  }
4160
4287
  getReplacements(values) {
4288
+ if (values === void 0 || values === null) {
4289
+ throw new Error(
4290
+ "format() requires an input object. Did you forget to pass arguments?"
4291
+ );
4292
+ }
4161
4293
  const { input = "", ...restOfValues } = values;
4162
4294
  const replacements = Object.assign(
4163
4295
  {},
@@ -4170,11 +4302,11 @@ var BasePrompt = class {
4170
4302
  return replacements;
4171
4303
  }
4172
4304
  /**
4173
- * validate description
4174
- * @return {boolean} Returns false if the template is not valid.
4305
+ * Validates the prompt structure.
4306
+ * @return {boolean} Returns false if the prompt has no messages defined.
4175
4307
  */
4176
4308
  validate() {
4177
- return true;
4309
+ return this.messages.length > 0;
4178
4310
  }
4179
4311
  };
4180
4312
 
@@ -4771,14 +4903,6 @@ var ChatPrompt = class extends BasePrompt {
4771
4903
  }
4772
4904
  return messagesOut;
4773
4905
  }
4774
- /**
4775
- * validate Ensures there are not unresolved tokens in prompt.
4776
- * @TODO Make this work!
4777
- * @return Returns false if the template is not valid.
4778
- */
4779
- validate() {
4780
- return true;
4781
- }
4782
4906
  };
4783
4907
 
4784
4908
  // src/prompt/_functions.ts
@@ -4805,10 +4929,12 @@ var BaseStateItem = class {
4805
4929
  this.initialValue = initialValue;
4806
4930
  }
4807
4931
  setValue(value) {
4808
- assert(
4809
- typeof value === typeof this.value,
4810
- `Invalid value type. Expected ${typeof this.value}, received ${typeof value}`
4811
- );
4932
+ if (this.value !== void 0 && this.value !== null) {
4933
+ assert(
4934
+ typeof value === typeof this.value,
4935
+ `Invalid value type. Expected ${typeof this.value}, received ${typeof value}`
4936
+ );
4937
+ }
4812
4938
  this.value = value;
4813
4939
  }
4814
4940
  getKey() {
@@ -4944,11 +5070,42 @@ var Dialogue = class extends BaseStateItem {
4944
5070
  return this;
4945
5071
  }
4946
5072
  setMessageTurn(userMessage, assistantMessage, systemMessage = "") {
5073
+ this.setSystemMessage(systemMessage);
4947
5074
  this.setUserMessage(userMessage);
4948
5075
  this.setAssistantMessage(assistantMessage);
4949
- this.setSystemMessage(systemMessage);
4950
5076
  return this;
4951
5077
  }
5078
+ /**
5079
+ * Aliases using `add*` naming to match ChatPrompt's API.
5080
+ * These delegate to the corresponding `set*` methods.
5081
+ */
5082
+ addUserMessage(content, name) {
5083
+ return this.setUserMessage(content, name);
5084
+ }
5085
+ addAssistantMessage(content) {
5086
+ return this.setAssistantMessage(content);
5087
+ }
5088
+ addSystemMessage(content) {
5089
+ return this.setSystemMessage(content);
5090
+ }
5091
+ addToolMessage(content, name, id) {
5092
+ return this.setToolMessage(content, name, id);
5093
+ }
5094
+ addToolCallMessage(input) {
5095
+ return this.setToolCallMessage(input);
5096
+ }
5097
+ addFunctionMessage(content, name, id) {
5098
+ return this.setFunctionMessage(content, name, id);
5099
+ }
5100
+ addFunctionCallMessage(input) {
5101
+ return this.setFunctionCallMessage(input);
5102
+ }
5103
+ addMessageTurn(userMessage, assistantMessage, systemMessage = "") {
5104
+ return this.setMessageTurn(userMessage, assistantMessage, systemMessage);
5105
+ }
5106
+ addHistory(messages) {
5107
+ return this.setHistory(messages);
5108
+ }
4952
5109
  setHistory(messages) {
4953
5110
  for (const message of messages) {
4954
5111
  switch (message?.role) {