""" Pydantic schemas for ContextSnippet model. Request and response schemas for reusable context snippets. """ from datetime import datetime from typing import Optional from uuid import UUID from pydantic import BaseModel, Field class ContextSnippetBase(BaseModel): """Base schema with shared ContextSnippet fields.""" project_id: Optional[UUID] = Field(None, description="Project ID (optional)") client_id: Optional[UUID] = Field(None, description="Client ID (optional)") category: str = Field(..., description="Category: tech_decision, configuration, pattern, lesson_learned") title: str = Field(..., description="Brief title describing the snippet") dense_content: str = Field(..., description="Highly compressed information content") structured_data: Optional[str] = Field(None, description="JSON object for optional structured representation") tags: Optional[str] = Field(None, description="JSON array of tags for retrieval and categorization") relevance_score: float = Field(1.0, ge=0.0, le=10.0, description="Float score for ranking relevance (0.0-10.0)") usage_count: int = Field(0, ge=0, description="Integer count of how many times this snippet was retrieved") class ContextSnippetCreate(ContextSnippetBase): """Schema for creating a new ContextSnippet.""" pass class ContextSnippetUpdate(BaseModel): """Schema for updating an existing ContextSnippet. All fields are optional.""" project_id: Optional[UUID] = Field(None, description="Project ID (optional)") client_id: Optional[UUID] = Field(None, description="Client ID (optional)") category: Optional[str] = Field(None, description="Category: tech_decision, configuration, pattern, lesson_learned") title: Optional[str] = Field(None, description="Brief title describing the snippet") dense_content: Optional[str] = Field(None, description="Highly compressed information content") structured_data: Optional[str] = Field(None, description="JSON object for optional structured representation") tags: Optional[str] = Field(None, description="JSON array of tags for retrieval and categorization") relevance_score: Optional[float] = Field(None, ge=0.0, le=10.0, description="Float score for ranking relevance (0.0-10.0)") usage_count: Optional[int] = Field(None, ge=0, description="Integer count of how many times this snippet was retrieved") class ContextSnippetResponse(ContextSnippetBase): """Schema for ContextSnippet responses with ID and timestamps.""" id: UUID = Field(..., description="Unique identifier for the context snippet") created_at: datetime = Field(..., description="Timestamp when the snippet was created") updated_at: datetime = Field(..., description="Timestamp when the snippet was last updated") model_config = {"from_attributes": True}