"""ElysiumResponse v1.0.0 — matches the exact JSON your fine-tuned model emits. Based on the user-provided training_dataset.jsonl example. """ from __future__ import annotations from typing import Optional, List, Dict, Any, Literal from pydantic import BaseModel, Field, ConfigDict class _Base(BaseModel): model_config = ConfigDict(extra="allow", populate_by_name=True) # ─── Perception ─── class MultimodalPerception(_Base): input_modalities_detected: List[str] = [] ocr_extracted_text: Optional[str] = None image_scene_description: Optional[str] = None visual_entities_detected: List[str] = [] document_type: Optional[str] = None # ─── Hypergraph ─── class HypergraphNode(_Base): node_id: str node_type: str label: str payload: Dict[str, Any] = {} embedding_hint: str = "" class HypergraphEdge(_Base): edge_id: str source_node_id: str target_node_id: str edge_type: str weight: float = 0.5 payload: Dict[str, Any] = {} class NodeUpdate(_Base): node_id: str fields_changed: Dict[str, Any] = {} reason: Optional[str] = None class EdgeWeaken(_Base): edge_id: str new_weight: float reason: Optional[str] = None class HypergraphDelta(_Base): nodes_added: List[HypergraphNode] = [] nodes_updated: List[NodeUpdate] = [] edges_added: List[HypergraphEdge] = [] edges_weakened: List[EdgeWeaken] = [] # ─── Council ─── class VoiceDesign(_Base): voice_id: str = "voice_default" pace: str = "moderate" tone: str = "calm_grounded" class AgentOutput(_Base): agent_id: str agent_name: str archetype: str domain: str thinking: str = "" stance: str = "" confidence: float = 0.8 dissents_from: List[str] = [] coalesces_with: List[str] = [] veto_triggered: bool = False veto_reason: Optional[str] = None tts_speech_text: str = "" tts_voice_design: VoiceDesign = VoiceDesign() class CoalitionEvent(_Base): event_id: str participants: List[str] = [] type: str = "GENERAL" status: str = "ACTIVE" payload: Dict[str, Any] = {} class SpeciationEvent(_Base): triggered: bool = False unsolved_tension_description: Optional[str] = None proposed_new_agent: Optional[Dict[str, Any]] = None class CouncilDeliberation(_Base): active_agents: List[str] = [] spawned_agents: List[str] = [] deprecated_agents: List[str] = [] agent_outputs: List[AgentOutput] = [] coalition_events: List[CoalitionEvent] = [] speciation_event: SpeciationEvent = SpeciationEvent() final_synthesis: str = "" debate_mode: str = "NONE" # NONE | SILENT | AUDIO_DRAMA # ─── Tools ─── class ToolCall(_Base): call_id: str tool_name: str calling_agent: str parameters: Dict[str, Any] = {} justification: str = "" priority: str = "MEDIUM" offline_fallback: str = "" # ─── Action field ─── class ExecutableProtocol(_Base): protocol_id: str domain: str title: str type: str executing_agent: str time_to_execute_minutes: int = 5 instructions: List[str] = [] success_criteria: str = "" hypergraph_nodes_affected: List[str] = [] class QuestUpdate(_Base): quest_id: str domain: str title: str current_step: str next_step: str oracle_forecast: str = "" completion_probability: float = 0.5 class DailyActionField(_Base): morning_briefing_summary: Optional[str] = None evening_evolution_report: Optional[str] = None executable_protocols: List[ExecutableProtocol] = [] quest_tree_updates: List[QuestUpdate] = [] primary_focus: str = "" recommended_actions: List[str] = [] energy_budget: str = "moderate" # ─── Forecasts ─── class ProbabilisticForecast(_Base): forecast_id: str target: str distribution: str = "lognormal" parameters: Dict[str, Any] = {} confidence: float = 0.8 horizon_seconds: int = 60 # ─── Strain ─── class StrainMetadata(_Base): active_strains: List[str] = ["base_civilization_v1"] strain_compatibility_score: float = 1.0 recommended_strain_grafts: List[str] = [] evolution_generation: int = 0 cognitive_strain: float = 0.3 emotional_strain: float = 0.2 notes: str = "" # ─── UI directives ─── class MyceliumThread(_Base): thread_id: str = "" source: str = "" target: str = "" type: str = "DATA_FLOW" from_node: str = "" to_node: str = "" color_hex: str = "#7FB3D5" animation: str = "pulse_slow" class AgentEmergence(_Base): agent_id: str animation: str = "spawn_default" class UIDirectives(_Base): bioluminescence_pulse_nodes: List[str] = [] new_mycelium_threads: List[MyceliumThread] = [] agent_emergence_animations: List[AgentEmergence] = [] alert_level: str = "CALM" soundtrack_mood: str = "ambient_growth" camera_focus_node_id: Optional[str] = None # ─── Meta ─── class Metadata(_Base): model_id: str = "elysium-minicpmv-4.6-ft-v1" inference_time_ms: int = 0 hypergraph_node_count: int = 0 hypergraph_edge_count: int = 0 civilization_age_days: int = 0 total_speciation_events: int = 0 schema_validation_passed: bool = True generator: str = "elysium_runtime_v1" notes: str = "" # ─── Root ─── class ElysiumResponse(_Base): schema_version: str = "1.0.0" session_id: str timestamp_utc: str interaction_type: str direct_answer: str = "" multimodal_perception: MultimodalPerception = MultimodalPerception() hypergraph_delta: HypergraphDelta = HypergraphDelta() council_deliberation: CouncilDeliberation = CouncilDeliberation() tool_calls: List[ToolCall] = [] daily_action_field: DailyActionField = DailyActionField() probabilistic_forecasts: List[ProbabilisticForecast] = [] strain_metadata: StrainMetadata = StrainMetadata() ui_directives: UIDirectives = UIDirectives() metadata: Metadata = Metadata() class ElysiumEnvelope(_Base): user_msg: Optional[str] = None elysium_response: ElysiumResponse