feat(backend): 添加 API Schemas 定义
- 添加 Chunk 数据结构 (chunk.py) - 添加 Dataset Schema (dataset.py) - 添加 Evaluation Schema (eval.py) - 添加 File Schema (file.py) - 添加 Project Schema (project.py) - 添加 Question Schema (question.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
46
backend/app/schemas/chunk.py
Normal file
46
backend/app/schemas/chunk.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
Chunk Schemas
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional, Any
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class ChunkBase(BaseModel):
|
||||
"""Base chunk schema"""
|
||||
name: Optional[str] = Field(None, max_length=255)
|
||||
content: str = Field(..., min_length=1)
|
||||
summary: Optional[str] = None
|
||||
word_count: Optional[int] = None
|
||||
extra_data: Optional[dict] = None
|
||||
|
||||
|
||||
class ChunkCreate(ChunkBase):
|
||||
"""Chunk create schema"""
|
||||
project_id: Optional[UUID] = None
|
||||
file_id: Optional[UUID] = None
|
||||
|
||||
|
||||
class ChunkUpdate(BaseModel):
|
||||
"""Chunk update schema"""
|
||||
name: Optional[str] = Field(None, max_length=255)
|
||||
content: Optional[str] = Field(None, min_length=1)
|
||||
summary: Optional[str] = None
|
||||
extra_data: Optional[dict] = None
|
||||
|
||||
|
||||
class ChunkResponse(ChunkBase):
|
||||
"""Chunk response schema"""
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: UUID
|
||||
project_id: UUID
|
||||
file_id: Optional[UUID]
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
# Alias for CRUD
|
||||
ChunkCreateSchema = ChunkCreate
|
||||
ChunkUpdateSchema = ChunkUpdate
|
||||
Reference in New Issue
Block a user