Spaces:
Sleeping
Sleeping
feat: define shared context data contracts and configure uv project metadata
Browse files- app/models/schemas.py +61 -0
app/models/schemas.py
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
from enum import Enum
|
| 3 |
+
from typing import List, Optional, Dict, Any
|
| 4 |
+
from pydantic import BaseModel, Field
|
| 5 |
+
|
| 6 |
+
class CaseStatus(str, Enum):
|
| 7 |
+
PENDING= "pending"
|
| 8 |
+
INVESTIGATING= "investigating"
|
| 9 |
+
VERIFYING= "verifying"
|
| 10 |
+
COMPLETED= "completed"
|
| 11 |
+
FAILED= "failed"
|
| 12 |
+
|
| 13 |
+
class Fact(BaseModel):
|
| 14 |
+
id: str= Field(..., description= "Unique identifier for the fact")
|
| 15 |
+
source: str= Field(..., description= "Where the fact came from (e.g., 'user_input', 'system_log')")
|
| 16 |
+
content: str= Field(..., description= "The actual factual statement")
|
| 17 |
+
created_at: datetime= Field(default_factory= datetime.utcnow)
|
| 18 |
+
|
| 19 |
+
class Hypothesis(BaseModel):
|
| 20 |
+
id: str= Field(..., description= "Unique identifier for the hypothesis")
|
| 21 |
+
statement: str= Field(..., description= "The hypothesis statement to be investigated")
|
| 22 |
+
status: str= Field(..., description= "Status of this hypothesis (pending, active, investigated, discarded)")
|
| 23 |
+
assigned_investigator: Optional[str]= Field(None, description= "Name or ID of the assigned investigator agent")
|
| 24 |
+
created_at: datetime= Field(default_factory= datetime.utcnow)
|
| 25 |
+
|
| 26 |
+
class Evidence(BaseModel):
|
| 27 |
+
id: str= Field(..., description= "Unique identifier for the evidence")
|
| 28 |
+
hypothesis_id: str= Field(..., description= "The hypothesis this evidence relates to")
|
| 29 |
+
source: str= Field(..., description= "Source of the evidence (e.g., Web Search, API Call, DB Query)")
|
| 30 |
+
content: str = Field(..., description="Detailed content of the evidence collected")
|
| 31 |
+
confidence: float= Field(..., description= "Confidence score of the evidence source (0.0 to 1.0)")
|
| 32 |
+
created_at: datetime= Field(default_factory= datetime.utcnow)
|
| 33 |
+
|
| 34 |
+
class Verification(BaseModel):
|
| 35 |
+
id: str= Field(..., description= "Unique identifier for the verification record")
|
| 36 |
+
evidence_id: str= Field(..., description= "The evidence ID that was verified")
|
| 37 |
+
valid: bool= Field(..., description= "Whether the verification passed or failed")
|
| 38 |
+
confidence_score: float= Field(..., description= "Calculated confidence score of the investigator's claim")
|
| 39 |
+
context_alignment_score: float= Field(..., description= "Detailed explanation of the validation decision")
|
| 40 |
+
reason: str = Field(..., description="Detailed explanation of the validation decision")
|
| 41 |
+
created_at: datetime= Field(default_factory= datetime.utcnow)
|
| 42 |
+
|
| 43 |
+
class CaseContext(BaseModel):
|
| 44 |
+
case_id: str = Field(..., description="Unique UUID for this investigation case")
|
| 45 |
+
problem_statement: str = Field(..., description="The original user query or problem statement")
|
| 46 |
+
status: CaseStatus = Field(default=CaseStatus.PENDING, description="Current lifecycle state of the investigation")
|
| 47 |
+
|
| 48 |
+
constraints: List[str] = Field(default_factory=list, description="Boundaries or assumptions constraints defined by the user/system")
|
| 49 |
+
facts: List[Fact] = Field(default_factory=list, description="Validated ground truth facts")
|
| 50 |
+
hypotheses: List[Hypothesis] = Field(default_factory=list, description="List of hypotheses generated to decompose the problem")
|
| 51 |
+
evidence: List[Evidence] = Field(default_factory=list, description="Raw evidence collected during investigation")
|
| 52 |
+
verifications: List[Verification] = Field(default_factory=list, description="Validation reports checking evidence against facts/constraints")
|
| 53 |
+
|
| 54 |
+
metadata: Dict[str, Any] = Field(default_factory=dict, description="Arbitrary execution metadata, cost/token tracking, or agent performance scores")
|
| 55 |
+
updated_at: datetime = Field(default_factory=datetime.utcnow)
|
| 56 |
+
|
| 57 |
+
class Config:
|
| 58 |
+
use_enum_values= True
|
| 59 |
+
json_encoders= {
|
| 60 |
+
datetime: lambda v: v.isoformat()
|
| 61 |
+
}
|