Building AI agents, atomically
Fix hooks example
KennyVaneetveldec4795da374dc
diff --git a/atomic-examples/hooks-example/hooks_example/main.py b/atomic-examples/hooks-example/hooks_example/main.pyindex b35c624..b64585f 100644--- a/atomic-examples/hooks-example/hooks_example/main.py+++ b/atomic-examples/hooks-example/hooks_example/main.py@@ -38,16 +38,19 @@ _request_start_time = Noneclass UserQuery(BaseIOSchema):+ """Schema for user input containing a chat message."""chat_message: str = Field(..., description="User's question or message")class AgentResponse(BaseIOSchema):+ """Schema for agent response with confidence and reasoning."""chat_message: str = Field(..., description="Agent's response to the user")confidence: float = Field(..., ge=0.0, le=1.0, description="Confidence score (0.0-1.0)")reasoning: str = Field(..., description="Brief explanation of the reasoning")class DetailedResponse(BaseIOSchema):+ """Schema for detailed response with alternatives and confidence level."""chat_message: str = Field(..., description="Primary response")alternative_suggestions: list[str] = Field(default_factory=list, description="Alternative suggestions")confidence_level: str = Field(..., description="Must be 'low', 'medium', or 'high'")@@ -197,13 +200,9 @@ def demonstrate_validation_errors():agent = create_agent_with_hooks(DetailedResponse,- """You are a helpful assistant. You must respond with:- - A main answer- - Alternative suggestions (list)- - Confidence level (exactly 'low', 'medium', or 'high')- - Whether follow-up is needed (boolean)-- Be very strict about the confidence_level field - it must be exactly one of the three allowed values.""",+ """You are a helpful assistant. INTENTIONALLY use invalid values to test validation:+ - Set confidence_level to something other than 'low', 'medium', or 'high' (like 'very_high' or 'uncertain')+ - This is for testing validation error handling, so please violate the schema constraints intentionally.""",)validation_test_queries = [