File size: 712 Bytes
e74241e
f383d3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# evaluator_prompt.py

from langchain_core.prompts import PromptTemplate

evaluator_prompt = PromptTemplate(
    input_variables=["query", "answer", "context"],
    template="""You are a JSON-only evaluator. Output a single JSON object. No other text.





Query: {query}

Answer: {answer}

Context (first 600 chars): {context}





Score these three fields:

- hallucination (bool): true if answer contains facts NOT in context

- context_usage (float 0-1): how much the answer uses the context

- relevance_score (float 0-1): how well the answer addresses the query



JSON:

""")

# Output this exact JSON and nothing else:
# {{"relevance_score": 0.0, "context_usage": 0.0, "hallucination": false}}