@exulu/backend 1.51.1 → 1.52.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 CHANGED
@@ -11331,12 +11331,16 @@ Mood: friendly and intelligent.
11331
11331
  message = req.body.message;
11332
11332
  }
11333
11333
  const approvedTools = req.body.approvedTools ? typeof req.body.approvedTools === "string" ? JSON.parse(req.body.approvedTools) : req.body.approvedTools : [];
11334
+ const customInstructions = req.body.customInstructions ? typeof req.body.customInstructions === "string" ? req.body.customInstructions : JSON.stringify(req.body.customInstructions) : "";
11335
+ const instructions = customInstructions ? `${agent.instructions}
11336
+
11337
+ ${customInstructions}` : agent.instructions;
11334
11338
  const result = await provider.generateStream({
11335
11339
  contexts,
11336
11340
  rerankers: rerankers || [],
11337
11341
  agent,
11338
11342
  user,
11339
- instructions: agent.instructions,
11343
+ instructions,
11340
11344
  session: headers.session,
11341
11345
  message,
11342
11346
  previousMessages,
@@ -11437,6 +11441,10 @@ Mood: friendly and intelligent.
11437
11441
  });
11438
11442
  return;
11439
11443
  } else {
11444
+ const customInstructions = req.body.customInstructions ? typeof req.body.customInstructions === "string" ? req.body.customInstructions : JSON.stringify(req.body.customInstructions) : "";
11445
+ const instructions = customInstructions ? `${agent.instructions}
11446
+
11447
+ ${customInstructions}` : agent.instructions;
11440
11448
  const response = await provider.generateSync({
11441
11449
  contexts,
11442
11450
  rerankers: rerankers || [],
@@ -11444,7 +11452,7 @@ Mood: friendly and intelligent.
11444
11452
  agent,
11445
11453
  user,
11446
11454
  req,
11447
- instructions: agent.instructions,
11455
+ instructions,
11448
11456
  session: headers.session,
11449
11457
  inputMessages: [req.body.message],
11450
11458
  currentTools: enabledTools,
@@ -11589,6 +11597,10 @@ Mood: friendly and intelligent.
11589
11597
  providers,
11590
11598
  user
11591
11599
  );
11600
+ const customInstructions = req.body.customInstructions ? typeof req.body.customInstructions === "string" ? req.body.customInstructions : JSON.stringify(req.body.customInstructions) : "";
11601
+ const agentInstructions = customInstructions ? `${agent?.instructions}
11602
+
11603
+ ${customInstructions}` : agent?.instructions;
11592
11604
  let system = req.body.system;
11593
11605
  if (Array.isArray(req.body.system)) {
11594
11606
  system = [
@@ -11598,7 +11610,7 @@ Mood: friendly and intelligent.
11598
11610
  type: "text",
11599
11611
  text: `
11600
11612
  You are an agent named: ${agent?.name}
11601
- Here are some additional instructions for you: ${agent?.instructions}`
11613
+ Here are some additional instructions for you: ${agentInstructions}`
11602
11614
  }
11603
11615
  ] : [],
11604
11616
  ...project ? [
@@ -11616,7 +11628,7 @@ Mood: friendly and intelligent.
11616
11628
 
11617
11629
 
11618
11630
  ${agent ? `You are an agent named: ${agent?.name}
11619
- Here are some additional instructions for you: ${agent?.instructions}` : ""}
11631
+ Here are some additional instructions for you: ${agentInstructions}` : ""}
11620
11632
 
11621
11633
  ${project?.id ? `Additional information:
11622
11634
 
@@ -15954,6 +15966,7 @@ var MarkdownChunker = class {
15954
15966
  if (currentSlice.length === 0) {
15955
15967
  currentPosition++;
15956
15968
  targetPosition = currentPosition + chunkSize * this._CHARS_PER_TOKEN;
15969
+ contentLeft = text.length - currentPosition;
15957
15970
  }
15958
15971
  }
15959
15972
  const mergedChunks = [];
@@ -16701,7 +16714,8 @@ var getMistralApiKey = async () => {
16701
16714
  if (process.env.MISTRAL_API_KEY) {
16702
16715
  return process.env.MISTRAL_API_KEY;
16703
16716
  } else {
16704
- return await ExuluVariables.get("MISTRAL_API_KEY");
16717
+ const variable = await ExuluVariables.get("MISTRAL_API_KEY");
16718
+ return variable;
16705
16719
  }
16706
16720
  };
16707
16721
  async function processPdf(buffer, paths, config, verbose = false) {
@@ -16760,7 +16774,7 @@ ${setupResult.output || ""}`);
16760
16774
  }];
16761
16775
  } else if (config?.processor.name === "mistral") {
16762
16776
  const MISTRAL_API_KEY = await getMistralApiKey();
16763
- if (MISTRAL_API_KEY) {
16777
+ if (!MISTRAL_API_KEY) {
16764
16778
  throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variable via process.env or via an Exulu variable named "MISTRAL_API_KEY".');
16765
16779
  }
16766
16780
  await new Promise((resolve3) => setTimeout(resolve3, Math.floor(Math.random() * 4e3) + 1e3));
package/dist/index.js CHANGED
@@ -11297,12 +11297,16 @@ Mood: friendly and intelligent.
11297
11297
  message = req.body.message;
11298
11298
  }
11299
11299
  const approvedTools = req.body.approvedTools ? typeof req.body.approvedTools === "string" ? JSON.parse(req.body.approvedTools) : req.body.approvedTools : [];
11300
+ const customInstructions = req.body.customInstructions ? typeof req.body.customInstructions === "string" ? req.body.customInstructions : JSON.stringify(req.body.customInstructions) : "";
11301
+ const instructions = customInstructions ? `${agent.instructions}
11302
+
11303
+ ${customInstructions}` : agent.instructions;
11300
11304
  const result = await provider.generateStream({
11301
11305
  contexts,
11302
11306
  rerankers: rerankers || [],
11303
11307
  agent,
11304
11308
  user,
11305
- instructions: agent.instructions,
11309
+ instructions,
11306
11310
  session: headers.session,
11307
11311
  message,
11308
11312
  previousMessages,
@@ -11403,6 +11407,10 @@ Mood: friendly and intelligent.
11403
11407
  });
11404
11408
  return;
11405
11409
  } else {
11410
+ const customInstructions = req.body.customInstructions ? typeof req.body.customInstructions === "string" ? req.body.customInstructions : JSON.stringify(req.body.customInstructions) : "";
11411
+ const instructions = customInstructions ? `${agent.instructions}
11412
+
11413
+ ${customInstructions}` : agent.instructions;
11406
11414
  const response = await provider.generateSync({
11407
11415
  contexts,
11408
11416
  rerankers: rerankers || [],
@@ -11410,7 +11418,7 @@ Mood: friendly and intelligent.
11410
11418
  agent,
11411
11419
  user,
11412
11420
  req,
11413
- instructions: agent.instructions,
11421
+ instructions,
11414
11422
  session: headers.session,
11415
11423
  inputMessages: [req.body.message],
11416
11424
  currentTools: enabledTools,
@@ -11555,6 +11563,10 @@ Mood: friendly and intelligent.
11555
11563
  providers,
11556
11564
  user
11557
11565
  );
11566
+ const customInstructions = req.body.customInstructions ? typeof req.body.customInstructions === "string" ? req.body.customInstructions : JSON.stringify(req.body.customInstructions) : "";
11567
+ const agentInstructions = customInstructions ? `${agent?.instructions}
11568
+
11569
+ ${customInstructions}` : agent?.instructions;
11558
11570
  let system = req.body.system;
11559
11571
  if (Array.isArray(req.body.system)) {
11560
11572
  system = [
@@ -11564,7 +11576,7 @@ Mood: friendly and intelligent.
11564
11576
  type: "text",
11565
11577
  text: `
11566
11578
  You are an agent named: ${agent?.name}
11567
- Here are some additional instructions for you: ${agent?.instructions}`
11579
+ Here are some additional instructions for you: ${agentInstructions}`
11568
11580
  }
11569
11581
  ] : [],
11570
11582
  ...project ? [
@@ -11582,7 +11594,7 @@ Mood: friendly and intelligent.
11582
11594
 
11583
11595
 
11584
11596
  ${agent ? `You are an agent named: ${agent?.name}
11585
- Here are some additional instructions for you: ${agent?.instructions}` : ""}
11597
+ Here are some additional instructions for you: ${agentInstructions}` : ""}
11586
11598
 
11587
11599
  ${project?.id ? `Additional information:
11588
11600
 
@@ -15920,6 +15932,7 @@ var MarkdownChunker = class {
15920
15932
  if (currentSlice.length === 0) {
15921
15933
  currentPosition++;
15922
15934
  targetPosition = currentPosition + chunkSize * this._CHARS_PER_TOKEN;
15935
+ contentLeft = text.length - currentPosition;
15923
15936
  }
15924
15937
  }
15925
15938
  const mergedChunks = [];
@@ -16667,7 +16680,8 @@ var getMistralApiKey = async () => {
16667
16680
  if (process.env.MISTRAL_API_KEY) {
16668
16681
  return process.env.MISTRAL_API_KEY;
16669
16682
  } else {
16670
- return await ExuluVariables.get("MISTRAL_API_KEY");
16683
+ const variable = await ExuluVariables.get("MISTRAL_API_KEY");
16684
+ return variable;
16671
16685
  }
16672
16686
  };
16673
16687
  async function processPdf(buffer, paths, config, verbose = false) {
@@ -16726,7 +16740,7 @@ ${setupResult.output || ""}`);
16726
16740
  }];
16727
16741
  } else if (config?.processor.name === "mistral") {
16728
16742
  const MISTRAL_API_KEY = await getMistralApiKey();
16729
- if (MISTRAL_API_KEY) {
16743
+ if (!MISTRAL_API_KEY) {
16730
16744
  throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variable via process.env or via an Exulu variable named "MISTRAL_API_KEY".');
16731
16745
  }
16732
16746
  await new Promise((resolve3) => setTimeout(resolve3, Math.floor(Math.random() * 4e3) + 1e3));
@@ -715,6 +715,7 @@ export class MarkdownChunker {
715
715
  if (currentSlice.length === 0) {
716
716
  currentPosition++;
717
717
  targetPosition = currentPosition + (chunkSize * this._CHARS_PER_TOKEN);
718
+ contentLeft = text.length - currentPosition;
718
719
  }
719
720
  }
720
721
 
@@ -591,7 +591,8 @@ const getMistralApiKey = async () => {
591
591
  if (process.env.MISTRAL_API_KEY) {
592
592
  return process.env.MISTRAL_API_KEY;
593
593
  } else {
594
- return await ExuluVariables.get("MISTRAL_API_KEY");
594
+ const variable = await ExuluVariables.get("MISTRAL_API_KEY");
595
+ return variable;
595
596
  }
596
597
  }
597
598
 
@@ -667,7 +668,7 @@ async function processPdf(
667
668
  } else if (config?.processor.name === "mistral") {
668
669
 
669
670
  const MISTRAL_API_KEY = await getMistralApiKey();
670
- if (MISTRAL_API_KEY) {
671
+ if (!MISTRAL_API_KEY) {
671
672
  throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variable via process.env or via an Exulu variable named "MISTRAL_API_KEY".');
672
673
  }
673
674
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu Bv.",
4
- "version": "1.51.1",
4
+ "version": "1.52.0",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {