if (evaluationResponse.evaluation().equals(EvaluationResponse.Evaluation.PASS)) { // Solution is accepted! returnnewRefinedResponse(generation.response(), chainOfThought); }
// Accumulated new context including the last and the previous attempts and // feedbacks. StringBuildernewContext=newStringBuilder(); newContext.append("Previous attempts:"); for (String m : memory) { newContext.append("\n- ").append(m); } newContext.append("\nFeedback: ").append(evaluationResponse.feedback());
""" Your goal is to complete the task based on the input. If there are feedback from your previous generations, you should reflect on them to improve your solution.
CRITICAL: Your response must be a SINGLE LINE of valid JSON with NO LINE BREAKS except those explicitly escaped with \\n. Here is the exact format to follow, including all quotes and braces:
{"thoughts":"Brief description here","response":"public class Example {\\n // Code here\\n}"}
Rules for the response field: 1. ALL line breaks must use \\n 2. ALL quotes must use \\" 3. ALL backslashes must be doubled: \\ 4. NO actual line breaks or formatting - everything on one line 5. NO tabs or special characters 6. Java code must be complete and properly escaped
Example of properly formatted response: {"thoughts":"Implementing counter","response":"public class Counter {\\n private int count;\\n public Counter() {\\n count = 0;\\n }\\n public void increment() {\\n count++;\\n }\\n}"}
Follow this format EXACTLY - your response must be valid JSON on a single line. """
Evaluator prompt
1 2 3 4 5 6 7 8 9 10
""" Evaluate this code implementation for correctness, time complexity, and best practices. Ensure the code have proper javadoc documentation. Respond with EXACTLY this JSON format on a single line:
{"evaluation":"PASS, NEEDS_IMPROVEMENT, or FAIL", "feedback":"Your feedback here"}
The evaluation field must be one of: "PASS", "NEEDS_IMPROVEMENT", "FAIL" Use "PASS" only if all criteria are met with no improvements needed. """
适用场景
在有清晰的评估标准, 并且迭代改进提供可衡量的价值. 良好契合的两个标志是
当人类清晰地表达反馈时, LLM的答案可以得到显著的改进
LLM能表达这种反馈
原文:
When to use this workflow: This workflow is particularly effective when we have clear evaluation criteria, and when iterative refinement provides measurable value. The two signs of good fit are, first, that LLM responses can be demonstrably improved when a human articulates their feedback; and second, that the LLM can provide such feedback. This is analogous to the iterative writing process a human writer might go through when producing a polished document.