Spaces:
Sleeping

File size: 1,669 Bytes
f233663
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# evaluator_agent.py
from pydantic import BaseModel, Field
from typing import List, Literal, Optional
from agents import Agent

class EvalFeedback(BaseModel):
    coverage_score: int = Field(
        description="0-100 score for how well current summaries answer the refined query."
    )
    missing_questions: List[str] = Field(
        default_factory=list,
        description="Specific questions/topics still missing or weakly covered."
    )
    action: Literal["finalize", "continue", "refine_plan"] = Field(
        description="Controller decision recommendation."
    )
    additional_queries: List[str] = Field(
        default_factory=list,
        description="Concrete search queries to run next if action=continue."
    )

INSTRUCTIONS = (
    "You are a research evaluator. You receive a refined query and a set of summaries. "
    "Assess coverage breadth, depth, recency, and authoritativeness. "
    "Respond in JSON strictly matching the EvalFeedback schema:\n"
    "{\n"
    '  "coverage_score": <int 0-100>,\n'
    '  "missing_questions": [<string>...],\n'
    '  "action": "finalize" | "continue" | "refine_plan",\n'
    '  "additional_queries": [<string>...]\n'
    "}\n\n"
    "Heuristics:\n"
    "- If coverage_score >= 85 and critical gaps are minimal -> finalize.\n"
    "- If gaps are specific and can be filled by a few targeted searches -> continue and provide 3-5 queries.\n"
    "- If the plan itself seems mis-scoped (wrong regions, timeframe, entities) -> refine_plan and say what to fix."
)

evaluator_agent = Agent(
    name="EvaluatorAgent",
    instructions=INSTRUCTIONS,
    model="gpt-4o-mini",
    output_type=EvalFeedback,
)