VuduVations commited on
Commit
c6f6ac2
·
verified ·
1 Parent(s): ec0923b

Upload schemas.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. schemas.py +126 -0
schemas.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """State schema and Pydantic output models for the ITIL Reflexion Agent."""
2
+
3
+ from typing import TypedDict, List, Dict, Annotated, Optional
4
+ from pydantic import BaseModel, Field
5
+ import operator
6
+
7
+
8
+ # =============================================================================
9
+ # LangGraph State
10
+ # =============================================================================
11
+
12
+ class RFCState(TypedDict):
13
+ """State object passed between LangGraph nodes."""
14
+ # Input data
15
+ scenario_id: str
16
+ incidents: List[Dict]
17
+ cmdb_info: Dict
18
+ scenario_meta: Dict
19
+ custom_data: Optional[Dict] # User-uploaded incidents/CMDB data
20
+
21
+ # Iteration control
22
+ iteration: int
23
+ max_iterations: int
24
+ score_threshold: int
25
+
26
+ # Agent outputs
27
+ rfc: str
28
+ critique: Dict
29
+ feedback: str
30
+ prompt_strategy: str
31
+ improvement_pattern: str
32
+
33
+ # Accumulated history (append-only via operator.add)
34
+ history: Annotated[List[Dict], operator.add]
35
+
36
+ # Control flow
37
+ should_continue: bool
38
+ final_result: Optional[Dict]
39
+ cab_summary: str
40
+
41
+ # Streaming
42
+ stream_queue: Optional[object]
43
+
44
+
45
+ # =============================================================================
46
+ # Pydantic Output Models (for structured LLM output)
47
+ # =============================================================================
48
+
49
+ class RFCScores(BaseModel):
50
+ """Six-dimension scoring for an RFC iteration."""
51
+ overall_quality: float = Field(ge=0, le=10, description="Overall RFC quality 0-10")
52
+ itil_compliance: float = Field(ge=0, le=10, description="ITIL framework compliance 0-10")
53
+ risk_level: float = Field(ge=0, le=10, description="Risk level 0-10 (lower is better)")
54
+ business_value: float = Field(ge=0, le=10, description="Business value articulation 0-10")
55
+ technical_readiness: float = Field(ge=0, le=10, description="Technical readiness 0-10")
56
+ stakeholder_confidence: float = Field(ge=0, le=10, description="Stakeholder confidence 0-10")
57
+
58
+
59
+ class ExecutiveSummary(BaseModel):
60
+ """Executive summary for CAB review."""
61
+ recommendation: str = Field(description="e.g. CONDITIONAL APPROVAL, APPROVED FOR PRODUCTION")
62
+ deployment_risk: str = Field(description="e.g. HIGH, MEDIUM, LOW")
63
+ business_impact: str = Field(description="Business impact level")
64
+ cab_approval_probability: float = Field(ge=0, le=1, description="Probability 0-1")
65
+ estimated_roi: str = Field(description="ROI estimate")
66
+ key_concerns: List[str] = Field(default_factory=list, description="Remaining concerns")
67
+
68
+
69
+ class RFCSummary(BaseModel):
70
+ """Structured RFC summary."""
71
+ title: str
72
+ objective: str
73
+ business_justification: str
74
+ technical_approach: str
75
+ rollback_plan_status: str
76
+ testing_status: str
77
+ timeline: str
78
+ impact: str
79
+
80
+
81
+ class CriticalIssue(BaseModel):
82
+ """A critical issue identified in the RFC."""
83
+ issue: str
84
+ category: str
85
+ severity: str = Field(description="HIGH, MEDIUM, or LOW")
86
+ priority: str
87
+ impact: str
88
+
89
+
90
+ class Improvement(BaseModel):
91
+ """A recommended improvement."""
92
+ action: str
93
+ priority: str = Field(description="CRITICAL, HIGH, MEDIUM, or LOW")
94
+ estimated_impact: str
95
+ effort_hours: float
96
+
97
+
98
+ class ChangeCategoryScore(BaseModel):
99
+ """Score for a change category."""
100
+ score: float = Field(ge=0, le=10)
101
+ status: str = Field(description="EXCELLENT, GOOD, ADEQUATE, or NEEDS IMPROVEMENT")
102
+
103
+
104
+ class ChangeCategories(BaseModel):
105
+ """Four change management categories."""
106
+ technical: ChangeCategoryScore
107
+ procedural: ChangeCategoryScore
108
+ compliance: ChangeCategoryScore
109
+ communication: ChangeCategoryScore
110
+
111
+
112
+ class EvaluationOutput(BaseModel):
113
+ """Structured output from the evaluator agent."""
114
+ scores: RFCScores
115
+ executive_summary: ExecutiveSummary
116
+ rfc_summary: RFCSummary
117
+ critical_issues: List[CriticalIssue] = Field(default_factory=list)
118
+ improvements: List[Improvement] = Field(default_factory=list)
119
+ change_categories: ChangeCategories
120
+
121
+
122
+ class ReflectionOutput(BaseModel):
123
+ """Structured output from the reflector agent."""
124
+ feedback: str = Field(description="Actionable feedback for the actor")
125
+ focus_areas: List[str] = Field(description="Key areas to improve")
126
+ strategy_recommendation: str = Field(description="Suggested prompt strategy for next iteration")