@mastra/deployer 0.24.9-alpha.0 → 0.24.9-alpha.1
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 +10 -0
- package/dist/server/handlers/prompt.d.ts.map +1 -1
- package/dist/server/index.cjs +28 -18
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +28 -18
- package/dist/server/index.js.map +1 -1
- package/package.json +5 -5
package/dist/server/index.js
CHANGED
|
@@ -2312,6 +2312,12 @@ function agentBuilderRouter(bodyLimitOptions) {
|
|
|
2312
2312
|
);
|
|
2313
2313
|
return router;
|
|
2314
2314
|
}
|
|
2315
|
+
var getUserMessageFromRunInput = (input) => {
|
|
2316
|
+
return input?.inputMessages.find(({ role }) => role === "user")?.content;
|
|
2317
|
+
};
|
|
2318
|
+
var extractAgentResponseMessages = (runOutput) => {
|
|
2319
|
+
return runOutput.filter((msg) => msg.role === "assistant").map((msg) => msg.content);
|
|
2320
|
+
};
|
|
2315
2321
|
async function generateSystemPromptHandler(c2) {
|
|
2316
2322
|
try {
|
|
2317
2323
|
const agentId = c2.req.param("agentId");
|
|
@@ -2328,25 +2334,29 @@ async function generateSystemPromptHandler(c2) {
|
|
|
2328
2334
|
if (!agent) {
|
|
2329
2335
|
return c2.json({ error: "Agent not found" }, 404);
|
|
2330
2336
|
}
|
|
2331
|
-
let
|
|
2337
|
+
let scoreSummary = "";
|
|
2332
2338
|
try {
|
|
2333
|
-
const
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
);
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2339
|
+
const scoresResult = await mastra.getStorage()?.getScoresByEntityId?.({
|
|
2340
|
+
entityId: agent.name,
|
|
2341
|
+
entityType: "AGENT",
|
|
2342
|
+
pagination: { page: 0, perPage: 100 }
|
|
2343
|
+
});
|
|
2344
|
+
const scores = scoresResult?.scores || [];
|
|
2345
|
+
scoreSummary = scores.map(({ input, output, score, reason, scorer }) => {
|
|
2346
|
+
const userMessage = getUserMessageFromRunInput(input);
|
|
2347
|
+
const agentResponses = extractAgentResponseMessages(output);
|
|
2348
|
+
return `
|
|
2349
|
+
User: ${userMessage}
|
|
2343
2350
|
|
|
2344
|
-
|
|
2351
|
+
Agent: ${agentResponses.join("\n")}
|
|
2345
2352
|
|
|
2346
|
-
|
|
2347
|
-
|
|
2353
|
+
Score: ${score}${reason ? `
|
|
2354
|
+
Reason: ${reason}` : ""}${scorer?.name ? `
|
|
2355
|
+
Scorer: ${scorer.name}` : ""}
|
|
2356
|
+
`;
|
|
2357
|
+
}).join("");
|
|
2348
2358
|
} catch (error) {
|
|
2349
|
-
mastra.getLogger().error(`Error fetching
|
|
2359
|
+
mastra.getLogger().error(`Error fetching scores`, { error });
|
|
2350
2360
|
}
|
|
2351
2361
|
const ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS = `
|
|
2352
2362
|
You are an expert system prompt engineer, specialized in analyzing and enhancing instructions to create clear, effective, and comprehensive system prompts. Your goal is to help users transform their basic instructions into well-structured system prompts that will guide AI behavior effectively.
|
|
@@ -2405,9 +2415,9 @@ async function generateSystemPromptHandler(c2) {
|
|
|
2405
2415
|
We need to improve the system prompt.
|
|
2406
2416
|
Current: ${instructions}
|
|
2407
2417
|
${comment ? `User feedback: ${comment}` : ""}
|
|
2408
|
-
${
|
|
2409
|
-
|
|
2410
|
-
${
|
|
2418
|
+
${scoreSummary ? `
|
|
2419
|
+
Scoring Results:
|
|
2420
|
+
${scoreSummary}` : ""}
|
|
2411
2421
|
`,
|
|
2412
2422
|
{
|
|
2413
2423
|
output: z.object({
|