Implements three-phase AI assistant feature: - Phase 0: RAG infrastructure with pgvector embeddings, Voyage AI integration, tree chunking service, and semantic search over team's flow library - Phase 1: In-session copilot panel during flow navigation with contextual AI help, current step awareness, and suggested related flows - Phase 2: Standalone AI chat page with persistent conversation history, pin/delete, and configurable retention policies (account-level) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1015 B
Python
45 lines
1015 B
Python
"""Pydantic schemas for the in-session copilot."""
|
|
from typing import Optional, Any
|
|
from uuid import UUID
|
|
from datetime import datetime
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class SuggestedFlow(BaseModel):
|
|
tree_id: UUID
|
|
tree_name: str
|
|
tree_type: str
|
|
relevance_snippet: str
|
|
|
|
|
|
class CopilotStartRequest(BaseModel):
|
|
tree_id: UUID
|
|
session_id: Optional[UUID] = None
|
|
current_node_id: Optional[str] = None
|
|
|
|
|
|
class CopilotStartResponse(BaseModel):
|
|
conversation_id: UUID
|
|
greeting: str
|
|
|
|
|
|
class CopilotMessageRequest(BaseModel):
|
|
message: str = Field(..., min_length=1, max_length=4000)
|
|
current_node_id: Optional[str] = None
|
|
|
|
|
|
class CopilotMessageResponse(BaseModel):
|
|
content: str
|
|
suggested_flows: list[SuggestedFlow] = []
|
|
|
|
|
|
class CopilotConversationResponse(BaseModel):
|
|
id: UUID
|
|
tree_id: UUID
|
|
messages: list[dict[str, Any]]
|
|
current_node_id: Optional[str] = None
|
|
message_count: int
|
|
created_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|