- 添加 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>
44 lines
1.0 KiB
Python
44 lines
1.0 KiB
Python
"""
|
|
Question Schemas
|
|
"""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class QuestionBase(BaseModel):
|
|
"""Base question schema"""
|
|
content: str = Field(..., min_length=1)
|
|
answer: Optional[str] = None
|
|
question_type: Optional[str] = Field(None, max_length=50)
|
|
source: Optional[str] = "manual"
|
|
|
|
|
|
class QuestionCreate(QuestionBase):
|
|
"""Question create schema"""
|
|
chunk_id: Optional[UUID] = None
|
|
|
|
|
|
class QuestionUpdate(BaseModel):
|
|
"""Question update schema"""
|
|
content: Optional[str] = Field(None, min_length=1)
|
|
answer: Optional[str] = None
|
|
question_type: Optional[str] = Field(None, max_length=50)
|
|
|
|
|
|
class QuestionResponse(QuestionBase):
|
|
"""Question response schema"""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
project_id: UUID
|
|
chunk_id: Optional[UUID]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
# Alias for CRUD
|
|
QuestionCreateSchema = QuestionCreate
|
|
QuestionUpdateSchema = QuestionUpdate
|