- Add Attachment ORM model (id, conversation_id, message_id, filename, content_type, blob_url, size_bytes, created_at) with FK to conversations
- Add POST /api/attachments/upload (multipart, 50MB limit), GET /api/attachments/{id}, GET /api/attachments/{id}/download (302 to SAS URL), DELETE /api/attachments/{id}
- Add delete_blob() and generate_sas_url() to storage/blob.py for download redirect and cleanup
- Dispatch parse_attachment task to Service Bus for parseable types (PDF, images, CSV, DOCX, XLSX)
- Pre-create blob container on startup (best-effort)
- Add AttachmentOut schema and full API docs in doc/api.md
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
"""Request / Response Pydantic models."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ChatRequest(BaseModel):
|
|
message: str = Field(..., min_length=1)
|
|
conversation_id: str = Field(..., min_length=1)
|
|
tools: list[str] = Field(default_factory=list)
|
|
model: str = Field(default="flash", pattern="^(flash|pro)$")
|
|
|
|
|
|
class ChatResponse(BaseModel):
|
|
"""Non-streaming chat response (for reference; SSE is primary)."""
|
|
conversation_id: str
|
|
content: str
|
|
|
|
|
|
class ConversationCreate(BaseModel):
|
|
title: str = Field(default="New conversation")
|
|
|
|
|
|
class ConversationUpdate(BaseModel):
|
|
title: str
|
|
|
|
|
|
class MessageOut(BaseModel):
|
|
id: str
|
|
role: str
|
|
content: str
|
|
created_at: str
|
|
|
|
|
|
class ConversationOut(BaseModel):
|
|
id: str
|
|
title: str
|
|
created_at: str
|
|
updated_at: str
|
|
|
|
|
|
class ConversationDetail(ConversationOut):
|
|
"""Conversation with messages, returned by GET /api/conversations/{id}."""
|
|
messages: list[MessageOut] = Field(default_factory=list)
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Attachment schemas
|
|
# ---------------------------------------------------------------------------
|
|
|
|
class AttachmentOut(BaseModel):
|
|
"""Attachment metadata returned by upload and GET endpoints."""
|
|
id: str
|
|
filename: str
|
|
content_type: str
|
|
blob_url: str
|
|
size_bytes: int
|
|
conversation_id: str | None = None
|
|
message_id: str | None = None
|
|
created_at: str
|