File size: 3,489 Bytes
dc1c6a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from pydantic import BaseModel, Field
from typing import Dict, Any, List, Optional, Literal

class QuestionAnalysis(BaseModel):
    """
    Analysis focused on generating the correct answer.
    No redirect/entry page logic needed.
    """
    
    # ===== QUESTION CLASSIFICATION =====
    question_type: Literal[
        'cli_command',           # Q2, Q3: shell commands
        'file_path',             # Q4: paths/URLs
        'data_processing',       # Q7, Q9, Q11: CSV/JSON processing
        'image_analysis',        # Q6, Q17: image operations
        'audio_transcription',   # Q5: audio to text
        'api_interaction',       # Q8: external API calls
        'document_parsing',      # Q10: PDF extraction
        'calculation',           # Q20, Q21: mathematical computations
        'text_generation',       # Q12, Q13, Q19: YAML, prompts
        'optimization',          # Q14, Q18: constraint solving
        'llm_reasoning'          # Q16: tool planning/reasoning
    ] = Field(description="Type of task to solve")
    
    # ===== ANSWER FORMAT =====
    answer_format: Literal[
        'plain_string',          # Q2, Q3, Q4: raw text
        'json_object',           # Q11, Q14, Q16, Q21: {"key": "value"}
        'json_array',            # Q20: ["a", "b", "c"]
        'number',                # Q8, Q9, Q10, Q17, Q18: integer/float
        'single_letter'          # Q12: A, B, or C
    ] = Field(description="How to format the final answer")
    
    # ===== ANSWER COMPONENTS =====
    key_components: Dict[str, Any] = Field(
        default_factory=dict,
        description="Extracted components needed to generate answer"
    )
    
    # ===== PERSONALIZATION =====
    requires_personalization: bool = Field(
        default=False,
        description="Does answer depend on user email?"
    )
    
    personalization_type: Optional[Literal[
        'email_in_url',          # Q2: ?email=<user_email>
        'email_length_offset',   # Q8, Q9, Q15, Q18: offset = len(email) mod N
        'email_length_conditional'  # Q15: if even/odd
    ]] = None
    
    personalization_details: Optional[str] = Field(
        default=None,
        description="Specific personalization logic"
    )
    
    # ===== FILE REQUIREMENTS =====
    requires_files: bool = Field(
        default=False,
        description="Does question need file downloads?"
    )
    
    required_file_types: List[str] = Field(
        default_factory=list,
        description="File types needed: csv, json, png, pdf, opus, zip"
    )
    
    # ===== EXTERNAL RESOURCES =====
    requires_external_fetch: bool = Field(
        default=False,
        description="Need to fetch data from another URL (not just files)?"
    )
    
    external_resources: List[str] = Field(
        default_factory=list,
        description="URLs/endpoints to fetch before solving"
    )
    
    # ===== CRITICAL CONSTRAINTS =====
    critical_constraints: List[str] = Field(
        default_factory=list,
        description="Must-follow rules for answer format"
    )
    
    # ===== SUBMISSION INFO =====
    submission_url_path: str = Field(
        description="URL path for this question (e.g., '/project2-uv')"
    )
    
    # ===== CONFIDENCE & REASONING =====
    reasoning: str = Field(
        description="Why this classification and components were chosen"
    )
    
    confidence: float = Field(
        ge=0.0,
        le=1.0,
        description="Confidence in analysis (0.0-1.0)"
    )