Spaces:
Paused

ReplyFlow / app /schemas.py
nvikou's picture
Initial commit
582520a verified
Raw History Blame Contribute Delete
2.79 kB
"""Pydantic request/response schemas."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Optional
from pydantic import BaseModel, Field
class ChatStartResponse(BaseModel):
"""New conversation payload."""
conversation_id: int
greeting: str
language: str
class ChatMessageRequest(BaseModel):
"""Incoming user message."""
conversation_id: int
message: str = Field(min_length=1, max_length=4000)
ui_language: str = "en"
class ChatMessageResponse(BaseModel):
"""Bot reply payload."""
conversation_id: int
reply: str
language: str
grounded: bool
lead: Optional[dict[str, Any]] = None
suggested_slots: Optional[list[dict[str, str]]] = None
handed_off: bool = False
appointment_booked: bool = False
class BookAppointmentRequest(BaseModel):
"""Confirm a suggested slot."""
conversation_id: int
slot_start: str
slot_end: str
attendee_name: Optional[str] = None
attendee_email: Optional[str] = None
class AppointmentResponse(BaseModel):
"""Booked appointment confirmation."""
id: int
slot_start: str
slot_end: str
status: str
message: str
class ConversationSummary(BaseModel):
"""List item for conversation history."""
id: int
channel: str
language: str
status: str
handed_off: bool
appointment_booked: bool
resolved_without_human: bool
message_count: int
created_at: datetime
lead_name: Optional[str] = None
class MessageOut(BaseModel):
"""Message in conversation detail."""
id: int
role: str
content: str
language: Optional[str]
grounded: Optional[bool]
created_at: datetime
class ConversationDetail(BaseModel):
"""Full conversation with messages."""
id: int
channel: str
language: str
status: str
handed_off: bool
appointment_booked: bool
resolved_without_human: bool
created_at: datetime
messages: list[MessageOut]
lead: Optional[dict[str, Any]] = None
appointment: Optional[dict[str, Any]] = None
class DashboardStats(BaseModel):
"""Dashboard KPI metrics."""
total_conversations: int
resolved_without_human: int
resolution_rate: float
appointments_booked: int
handed_off: int
unanswered_count: int
leads_complete: int
by_channel: dict[str, int]
by_language: dict[str, int]
recent_unanswered: list[dict[str, Any]]
class KnowledgeIngestResponse(BaseModel):
"""Result of knowledge ingestion."""
filename: str
chunk_count: int
message: str
class HealthResponse(BaseModel):
"""Service health and feature flags."""
status: str
app: str
openai: bool
calcom: bool
whatsapp: bool
knowledge_chunks: int