huoyan-enterprise/backend/models/chat_thread_file.py

66 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
聊天对话文件模型
"""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
class ChatThreadFile(BaseModel):
"""聊天对话文件模型"""
id: Optional[int] = None
thread_id: str = Field(..., max_length=255)
user_id: int
file_name: str = Field(..., max_length=255)
file_path: str = Field(..., max_length=500)
file_size: int = 0
file_type: str = Field(default="pdf", max_length=50)
status: str = Field(default="processing", max_length=20)
chunk_count: int = 0
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
is_deleted: bool = False
deleted_at: Optional[datetime] = None
class Config:
from_attributes = True
class ChatThreadChunk(BaseModel):
"""聊天对话文档块模型"""
id: Optional[int] = None
file_id: int
thread_id: str = Field(..., max_length=255)
chunk_index: int
content: str
metadata: Optional[dict] = None
vector_id: Optional[str] = None
created_at: Optional[datetime] = None
class Config:
from_attributes = True
class ChatThreadFileUploadResponse(BaseModel):
"""聊天文件上传响应模型"""
id: int
file_name: str
file_size: int
status: str
chunk_count: int
created_at: datetime
file_url: Optional[str] = Field(None, description="文件访问 URLOSS 或本地路径)")
class Config:
from_attributes = True
class ChatThreadFileListResponse(BaseModel):
"""聊天文件列表响应模型"""
total: int = Field(..., description="总数量")
items: list[ChatThreadFileUploadResponse] = Field(..., description="文件列表")
class Config:
from_attributes = True