buildEvaluationInstructions method
List<ChatMessage> ?
buildEvaluationInstructions(
- List<
ChatMessage> messages, - ChatResponse modelResponse,
- List<
EvaluationContext> additionalContext
override
Builds the evaluation instructions (system + user messages).
Return null to signal that a required context was missing.
Implementation
@override
List<ChatMessage>? buildEvaluationInstructions(
List<ChatMessage> messages,
ChatResponse modelResponse,
List<EvaluationContext> additionalContext,
) {
final userRequest = messages.lastUserMessage?.text ?? '';
final response = modelResponse.text;
final prompt = '''
# Definition
**Relevance** refers to how effectively the response addresses the main aspects of the query. A relevant response directly addresses the question, covers all necessary points, and avoids unnecessary tangents.
# Ratings
## [Relevance: 1] (Irrelevant)
The response does not address the query at all, or addresses an entirely different topic.
## [Relevance: 2] (Barely Relevant)
The response mentions the topic but fails to address the actual question asked.
## [Relevance: 3] (Partially Relevant)
The response addresses some aspects of the query but misses key points or includes excessive off-topic content.
## [Relevance: 4] (Relevant)
The response effectively addresses the main aspects of the query with minor gaps.
## [Relevance: 5] (Highly Relevant)
The response fully addresses all aspects of the query with precision and completeness.
# Data
QUERY: $userRequest
RESPONSE: $response
# Tasks
## Please provide your assessment Score for the previous RESPONSE in relation to the QUERY based on the Definitions above.
- **ThoughtChain**: Think step by step. Start with "Let's think step by step:".
- **Explanation**: A very short explanation of why you think the input Data should get that Score.
- **Score**: An integer score (1–5) based on the definitions.
## Please provide your answers between the tags: <S0>your chain of thoughts</S0>, <S1>your explanation</S1>, <S2>your Score</S2>.
# Output
''';
return [
ChatMessage.fromText(ChatRole.system, _systemPrompt),
ChatMessage.fromText(ChatRole.user, prompt),
];
}