37 lines
2.0 KiB
Python
37 lines
2.0 KiB
Python
"""
|
|
LLM 模型配置模型
|
|
"""
|
|
from sqlalchemy import Column, BigInteger, String, Integer, DateTime, Text, Numeric, Boolean
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class LLMModelConfig(Base):
|
|
"""大模型配置表模型"""
|
|
|
|
__tablename__ = "llm_model_config"
|
|
|
|
config_id = Column(BigInteger, primary_key=True, autoincrement=True, comment="配置ID")
|
|
model_code = Column(String(128), nullable=False, unique=True, index=True, comment="模型编码")
|
|
model_name = Column(String(255), nullable=False, comment="模型名称")
|
|
model_type = Column(String(32), nullable=False, default="chat", index=True, comment="模型类型: chat/embedding")
|
|
provider = Column(String(64), comment="模型提供方")
|
|
endpoint_url = Column(String(512), comment="接口地址")
|
|
api_key = Column(String(512), comment="API Key")
|
|
llm_model_name = Column(String(128), nullable=False, comment="模型名称/部署名")
|
|
llm_timeout = Column(Integer, nullable=False, default=120, comment="超时时间(秒)")
|
|
llm_temperature = Column(Numeric(5, 2), nullable=False, default=0.70, comment="温度")
|
|
llm_top_p = Column(Numeric(5, 2), nullable=False, default=0.90, comment="Top P")
|
|
llm_max_tokens = Column(Integer, nullable=False, default=8192, comment="最大输出 Token")
|
|
llm_system_prompt = Column(Text, comment="系统提示词")
|
|
embedding_dimension = Column(Integer, nullable=True, default=None, comment="向量维度(仅 embedding 类型)")
|
|
description = Column(String(500), comment="描述")
|
|
is_active = Column(Boolean, nullable=False, default=True, index=True, comment="是否启用")
|
|
is_default = Column(Boolean, nullable=False, default=False, comment="是否默认")
|
|
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
|
|
|
def __repr__(self):
|
|
return f"<LLMModelConfig(config_id={self.config_id}, model_code='{self.model_code}')>"
|