All files / api/src/connectors/evaluations/argument-correctness/templates extraction.ts

0% Statements 0/14
100% Branches 1/1
100% Functions 1/1
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                                         
import type { ArgumentCorrectnessTemplateConfig } from '@api/connectors/evaluations/argument-correctness/types';
 
/**
 * Template for extracting per-tool argument correctness from input, tools, and output
 */
export function getArgumentCorrectnessExtractionTemplate(data: {
  input: string;
  tools_called: unknown[];
  actual_output: string;
}): ArgumentCorrectnessTemplateConfig {
  const systemPrompt = `You are an expert at analyzing AI agent tool usage to determine argument correctness for each tool call.
 
Instructions:
- Consider the task implied by the input and the agent's output.
- For each tool call, judge whether its input arguments are appropriate and sufficient for the task at that point in time.
 
Return a JSON object with this exact structure:
{
  "per_tool": [
    { "name": "<tool name>", "correct": <true|false>, "explanation": "<brief reason>" }
  ]
}`;
 
  const userPrompt = `Analyze this interaction and evaluate per-tool argument correctness:
 
INPUT:
${data.input}
 
TOOLS CALLED:
${JSON.stringify(data.tools_called, null, 2)}
 
AGENT OUTPUT:
${data.actual_output}
 
For each tool call, decide if the arguments are correct and explain briefly.`;
 
  return {
    systemPrompt,
    userPrompt,
    outputFormat: 'json',
  };
}
 
export default getArgumentCorrectnessExtractionTemplate;