srszzw 10c5dcfdde
1、修改知识库列表接口,返回全量属性字段,同时修改受影响的相关代码。 (#4119)
2、run_in_process_pool改为run_in_thread_pool,解决兼容性问题。
3、poetry配置文件修复。
2024-06-01 18:44:06 +08:00

35 lines
1.4 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, func
from pydantic import BaseModel
from typing import Optional
from datetime import datetime
from chatchat.server.db.base import Base
class KnowledgeBaseModel(Base):
"""
知识库模型
"""
__tablename__ = 'knowledge_base'
id = Column(Integer, primary_key=True, autoincrement=True, comment='知识库ID')
kb_name = Column(String(50), comment='知识库名称')
kb_info = Column(String(200), comment='知识库简介(用于Agent)')
vs_type = Column(String(50), comment='向量库类型')
embed_model = Column(String(50), comment='嵌入模型名称')
file_count = Column(Integer, default=0, comment='文件数量')
create_time = Column(DateTime, default=func.now(), comment='创建时间')
def __repr__(self):
return f"<KnowledgeBase(id='{self.id}', kb_name='{self.kb_name}',kb_intro='{self.kb_info} vs_type='{self.vs_type}', embed_model='{self.embed_model}', file_count='{self.file_count}', create_time='{self.create_time}')>"
# 创建一个对应的 Pydantic 模型
class KnowledgeBaseSchema(BaseModel):
id: int
kb_name: str
kb_info: Optional[str]
vs_type: Optional[str]
embed_model: Optional[str]
file_count: Optional[int]
create_time: Optional[datetime]
class Config:
from_attributes = True # 确保可以从 ORM 实例进行验证