@exulu/backend 1.30.1 → 1.30.3
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/CHANGELOG.md +4 -2
- package/dist/index.cjs +60 -44
- package/dist/index.js +60 -44
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
## [1.30.
|
|
1
|
+
## [1.30.3](https://github.com/Qventu/exulu-backend/compare/v1.30.2...v1.30.3) (2025-11-04)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* issue importing default evals ([3b5013d](https://github.com/Qventu/exulu-backend/commit/3b5013dc6357a13e5e35d815ea854cf09ed84440))
|
|
7
|
+
* issue importing default evals ([56ae0e0](https://github.com/Qventu/exulu-backend/commit/56ae0e0fab18781c7b3b26c0df4e2744b9385569))
|
|
8
|
+
* issue importing default evals ([3976ced](https://github.com/Qventu/exulu-backend/commit/3976ced27f7180e1121bc1ba57aa01263828577f))
|
package/dist/index.cjs
CHANGED
|
@@ -7795,6 +7795,8 @@ var ExuluQueues = class {
|
|
|
7795
7795
|
}
|
|
7796
7796
|
if (!redisServer.host?.length || !redisServer.port?.length) {
|
|
7797
7797
|
console.error(`[EXULU] no redis server configured, but you are trying to use a queue ( ${name}), likely in an agent or embedder (look for ExuluQueues.register().use() ).`);
|
|
7798
|
+
console.error("Stack trace:");
|
|
7799
|
+
console.trace();
|
|
7798
7800
|
throw new Error(`[EXULU] no redis server configured.`);
|
|
7799
7801
|
}
|
|
7800
7802
|
const newQueue = new import_bullmq5.Queue(
|
|
@@ -7834,50 +7836,64 @@ var queues = new ExuluQueues();
|
|
|
7834
7836
|
|
|
7835
7837
|
// src/templates/evals/index.ts
|
|
7836
7838
|
var import_zod3 = require("zod");
|
|
7837
|
-
var llmAsJudgeEval =
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7839
|
+
var llmAsJudgeEval = () => {
|
|
7840
|
+
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
7841
|
+
return new ExuluEval2({
|
|
7842
|
+
id: "llm_as_judge",
|
|
7843
|
+
name: "LLM as Judge",
|
|
7844
|
+
description: "Evaluate the output of the LLM as a judge.",
|
|
7845
|
+
execute: async ({ agent, backend, messages, testCase, config }) => {
|
|
7846
|
+
console.log("[EXULU] running llm as judge eval", { agent, backend, messages, testCase, config });
|
|
7847
|
+
let prompt = config?.prompt;
|
|
7848
|
+
if (!prompt) {
|
|
7849
|
+
console.error("[EXULU] prompt is required.");
|
|
7850
|
+
throw new Error("Prompt is required.");
|
|
7851
|
+
}
|
|
7852
|
+
const lastMessage = messages[messages.length - 1]?.parts?.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
7853
|
+
console.log("[EXULU] last message", lastMessage);
|
|
7854
|
+
if (!lastMessage) {
|
|
7855
|
+
return 0;
|
|
7856
|
+
}
|
|
7857
|
+
prompt = prompt.replace("{actual_output}", lastMessage);
|
|
7858
|
+
prompt = prompt.replace("{expected_output}", testCase.expected_output);
|
|
7859
|
+
if (!agent.providerapikey) {
|
|
7860
|
+
throw new Error(`Provider API key for agent ${agent.name} is required, variable name is ${agent.providerapikey} but it is not set.`);
|
|
7861
|
+
}
|
|
7862
|
+
const providerapikey = await ExuluVariables.get(agent.providerapikey);
|
|
7863
|
+
console.log("[EXULU] prompt", prompt);
|
|
7864
|
+
const response = await backend.generateSync({
|
|
7865
|
+
prompt,
|
|
7866
|
+
outputSchema: import_zod3.z.object({
|
|
7867
|
+
score: import_zod3.z.number().min(0).max(100).describe("The score between 0 and 100.")
|
|
7868
|
+
}),
|
|
7869
|
+
providerapikey
|
|
7870
|
+
});
|
|
7871
|
+
console.log("[EXULU] response", response);
|
|
7872
|
+
const score = parseFloat(response.score);
|
|
7873
|
+
if (isNaN(score)) {
|
|
7874
|
+
throw new Error(`Generated score from llm as a judge eval is not a number: ${response.score}`);
|
|
7875
|
+
}
|
|
7876
|
+
return score;
|
|
7877
|
+
},
|
|
7878
|
+
config: [{
|
|
7879
|
+
name: "prompt",
|
|
7880
|
+
description: "The prompt to send to the LLM as a judge, make sure to instruct the LLM to output a numerical score between 0 and 100. Add {actual_output} to the prompt to replace with the last message content, and {expected_output} to replace with the expected output."
|
|
7881
|
+
}],
|
|
7882
|
+
queue: queues.register("llm_as_judge", 1, 1).use(),
|
|
7883
|
+
llm: true
|
|
7866
7884
|
});
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
return
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
llm: true
|
|
7880
|
-
});
|
|
7885
|
+
}
|
|
7886
|
+
return void 0;
|
|
7887
|
+
};
|
|
7888
|
+
var getDefaultEvals = () => {
|
|
7889
|
+
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
7890
|
+
return [
|
|
7891
|
+
llmAsJudgeEval() ?? void 0
|
|
7892
|
+
].filter((x) => x !== void 0);
|
|
7893
|
+
}
|
|
7894
|
+
console.error("[EXULU] no redis server configured, skipping default evals as they require redis queues.");
|
|
7895
|
+
return [];
|
|
7896
|
+
};
|
|
7881
7897
|
|
|
7882
7898
|
// src/templates/tools/math.ts
|
|
7883
7899
|
var import_zod4 = require("zod");
|
|
@@ -8534,7 +8550,7 @@ var ExuluApp = class {
|
|
|
8534
8550
|
// initialize the MCP server if needed.
|
|
8535
8551
|
create = async ({ contexts, agents, config, tools, evals }) => {
|
|
8536
8552
|
this._evals = redisServer.host?.length && redisServer.port?.length ? [
|
|
8537
|
-
|
|
8553
|
+
...getDefaultEvals(),
|
|
8538
8554
|
...evals ?? []
|
|
8539
8555
|
] : [];
|
|
8540
8556
|
this._contexts = {
|
package/dist/index.js
CHANGED
|
@@ -7762,6 +7762,8 @@ var ExuluQueues = class {
|
|
|
7762
7762
|
}
|
|
7763
7763
|
if (!redisServer.host?.length || !redisServer.port?.length) {
|
|
7764
7764
|
console.error(`[EXULU] no redis server configured, but you are trying to use a queue ( ${name}), likely in an agent or embedder (look for ExuluQueues.register().use() ).`);
|
|
7765
|
+
console.error("Stack trace:");
|
|
7766
|
+
console.trace();
|
|
7765
7767
|
throw new Error(`[EXULU] no redis server configured.`);
|
|
7766
7768
|
}
|
|
7767
7769
|
const newQueue = new Queue3(
|
|
@@ -7801,50 +7803,64 @@ var queues = new ExuluQueues();
|
|
|
7801
7803
|
|
|
7802
7804
|
// src/templates/evals/index.ts
|
|
7803
7805
|
import { z as z3 } from "zod";
|
|
7804
|
-
var llmAsJudgeEval =
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7806
|
+
var llmAsJudgeEval = () => {
|
|
7807
|
+
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
7808
|
+
return new ExuluEval2({
|
|
7809
|
+
id: "llm_as_judge",
|
|
7810
|
+
name: "LLM as Judge",
|
|
7811
|
+
description: "Evaluate the output of the LLM as a judge.",
|
|
7812
|
+
execute: async ({ agent, backend, messages, testCase, config }) => {
|
|
7813
|
+
console.log("[EXULU] running llm as judge eval", { agent, backend, messages, testCase, config });
|
|
7814
|
+
let prompt = config?.prompt;
|
|
7815
|
+
if (!prompt) {
|
|
7816
|
+
console.error("[EXULU] prompt is required.");
|
|
7817
|
+
throw new Error("Prompt is required.");
|
|
7818
|
+
}
|
|
7819
|
+
const lastMessage = messages[messages.length - 1]?.parts?.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
7820
|
+
console.log("[EXULU] last message", lastMessage);
|
|
7821
|
+
if (!lastMessage) {
|
|
7822
|
+
return 0;
|
|
7823
|
+
}
|
|
7824
|
+
prompt = prompt.replace("{actual_output}", lastMessage);
|
|
7825
|
+
prompt = prompt.replace("{expected_output}", testCase.expected_output);
|
|
7826
|
+
if (!agent.providerapikey) {
|
|
7827
|
+
throw new Error(`Provider API key for agent ${agent.name} is required, variable name is ${agent.providerapikey} but it is not set.`);
|
|
7828
|
+
}
|
|
7829
|
+
const providerapikey = await ExuluVariables.get(agent.providerapikey);
|
|
7830
|
+
console.log("[EXULU] prompt", prompt);
|
|
7831
|
+
const response = await backend.generateSync({
|
|
7832
|
+
prompt,
|
|
7833
|
+
outputSchema: z3.object({
|
|
7834
|
+
score: z3.number().min(0).max(100).describe("The score between 0 and 100.")
|
|
7835
|
+
}),
|
|
7836
|
+
providerapikey
|
|
7837
|
+
});
|
|
7838
|
+
console.log("[EXULU] response", response);
|
|
7839
|
+
const score = parseFloat(response.score);
|
|
7840
|
+
if (isNaN(score)) {
|
|
7841
|
+
throw new Error(`Generated score from llm as a judge eval is not a number: ${response.score}`);
|
|
7842
|
+
}
|
|
7843
|
+
return score;
|
|
7844
|
+
},
|
|
7845
|
+
config: [{
|
|
7846
|
+
name: "prompt",
|
|
7847
|
+
description: "The prompt to send to the LLM as a judge, make sure to instruct the LLM to output a numerical score between 0 and 100. Add {actual_output} to the prompt to replace with the last message content, and {expected_output} to replace with the expected output."
|
|
7848
|
+
}],
|
|
7849
|
+
queue: queues.register("llm_as_judge", 1, 1).use(),
|
|
7850
|
+
llm: true
|
|
7833
7851
|
});
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
return
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
llm: true
|
|
7847
|
-
});
|
|
7852
|
+
}
|
|
7853
|
+
return void 0;
|
|
7854
|
+
};
|
|
7855
|
+
var getDefaultEvals = () => {
|
|
7856
|
+
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
7857
|
+
return [
|
|
7858
|
+
llmAsJudgeEval() ?? void 0
|
|
7859
|
+
].filter((x) => x !== void 0);
|
|
7860
|
+
}
|
|
7861
|
+
console.error("[EXULU] no redis server configured, skipping default evals as they require redis queues.");
|
|
7862
|
+
return [];
|
|
7863
|
+
};
|
|
7848
7864
|
|
|
7849
7865
|
// src/templates/tools/math.ts
|
|
7850
7866
|
import { z as z4 } from "zod";
|
|
@@ -8501,7 +8517,7 @@ var ExuluApp = class {
|
|
|
8501
8517
|
// initialize the MCP server if needed.
|
|
8502
8518
|
create = async ({ contexts, agents, config, tools, evals }) => {
|
|
8503
8519
|
this._evals = redisServer.host?.length && redisServer.port?.length ? [
|
|
8504
|
-
|
|
8520
|
+
...getDefaultEvals(),
|
|
8505
8521
|
...evals ?? []
|
|
8506
8522
|
] : [];
|
|
8507
8523
|
this._contexts = {
|