huoyan-enterprise/backend/models/knowledge_base_file.py

66 lines
1.6 KiB
Python
Raw Permalink 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 KnowledgeBaseFile(BaseModel):
"""知识库文件模型"""
id: Optional[int] = None
knowledge_base_id: int
user_id: int
file_name: str = Field(..., max_length=255)
file_path: str = Field(..., max_length=500)
file_size: int
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 KnowledgeBaseChunk(BaseModel):
"""知识库文档块模型"""
id: Optional[int] = None
file_id: int
knowledge_base_id: int
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 FileUploadResponse(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 FileListResponse(BaseModel):
"""文件列表响应模型"""
total: int = Field(..., description="总数量")
items: list[FileUploadResponse] = Field(..., description="文件列表")
class Config:
from_attributes = True