diff --git a/ai_service/.env.example b/ai_service/.env.example new file mode 100644 index 0000000..f8d1e3c --- /dev/null +++ b/ai_service/.env.example @@ -0,0 +1,2 @@ +OPENAI_API_KEY=你的API密钥 +DEEPSEEK_API_KEY='你的API密钥' \ No newline at end of file diff --git a/ai_service/Dockerfile b/ai_service/Dockerfile new file mode 100644 index 0000000..001a440 --- /dev/null +++ b/ai_service/Dockerfile @@ -0,0 +1,24 @@ +# syntax=docker/dockerfile:1 +FROM python:3.12.2 AS base + +WORKDIR /app + +COPY . . + +RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple +# 入口命令由 docker-compose 控制 +# 默认命令,开发和生产通过 docker-compose 覆盖 +#CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] + +FROM base AS dev + +#CMD ["tail", "-f", "/dev/null"] + +#CMD ["daphne", "backend.asgi:application"] + +# CMD ["sh", "-c", "sleep 5 && python manage.py runserver 0.0.0.0:8000"] + + +FROM base AS prod + +CMD ["gunicorn", "main:app", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8010", "--workers", "4"] \ No newline at end of file diff --git a/ai_service/api/v1/ai_chat.py b/ai_service/api/v1/ai_chat.py new file mode 100644 index 0000000..3cf5270 --- /dev/null +++ b/ai_service/api/v1/ai_chat.py @@ -0,0 +1,120 @@ +import os +import asyncio +from fastapi import APIRouter, Depends, Request, Query +from fastapi.responses import StreamingResponse +from sqlalchemy.orm import Session +from typing import List + +from pydantic import BaseModel, SecretStr +from langchain.chains import ConversationChain + +from api.v1.vo import MessageVO +from deps.auth import get_current_user +from services.chat_service import ChatDBService +from db.session import get_db +from models.ai import ChatConversation, ChatMessage +from utils.resp import resp_success, Response +from langchain_deepseek import ChatDeepSeek + +router = APIRouter() + +def get_deepseek_llm(api_key: SecretStr, model: str): + # deepseek 兼容 OpenAI API,需指定 base_url + return ChatDeepSeek( + api_key=api_key, + model=model, + streaming=True, + ) + +@router.post('/stream') +async def chat_stream(request: Request, user=Depends(get_current_user), db: Session = Depends(get_db)): + body = await request.json() + content = body.get('content') + conversation_id = body.get('conversation_id') + model = 'deepseek-chat' + api_key = os.getenv("DEEPSEEK_API_KEY") + llm = get_deepseek_llm(SecretStr(api_key), model) + + if not content or not isinstance(content, str): + from fastapi.responses import JSONResponse + return JSONResponse({"error": "content不能为空"}, status_code=400) + + user_id = user["user_id"] + # 1. 获取对话 + try: + conversation = ChatDBService.get_conversation(db, conversation_id) + conversation = db.merge(conversation) # ✅ 防止 DetachedInstanceError + except ValueError as e: + from fastapi.responses import JSONResponse + return JSONResponse({"error": str(e)}, status_code=400) + # 2. 插入当前消息 + ChatDBService.add_message(db, conversation, user_id, content) + context = [ + ("system", "You are a helpful assistant. Answer all questions to the best of your ability in {language}.") + ] + # 3. 查询历史消息,组装上下文 + history = ChatDBService.get_history(db, conversation.id) + # === 新增:如果只有一条消息,更新 title === + if len(history) == 1: + ChatDBService.update_conversation_title(db, conversation.id, content[:255]) + + for msg in history: + # 假设 msg.type 存储的是 'user' 或 'assistant' + # role = msg.type if msg.type in ("user", "assistant") else "user" + context.append((msg.type, msg.content)) + + ai_reply = "" + async def event_generator(): + nonlocal ai_reply + async for chunk in llm.astream(context): + if hasattr(chunk, 'content'): + ai_reply += chunk.content + yield f"data: {chunk.content}\n\n" + else: + ai_reply += chunk + yield f"data: {chunk}\n\n" + await asyncio.sleep(0.01) + # 只保留最新AI回复 + if ai_reply: + ChatDBService.insert_ai_message(db, conversation, user_id, ai_reply, model) + + return StreamingResponse(event_generator(), media_type='text/event-stream') + +@router.post("/conversations") +def create_conversation(db: Session = Depends(get_db), user=Depends(get_current_user),): + user_id = user["user_id"] + model = 'deepseek-chat' + conversation = ChatDBService.get_or_create_conversation(db, None, user_id, model, '新对话') + return resp_success(data=conversation.id) + +@router.get('/conversations') +async def get_conversations( + db: Session = Depends(get_db), + user=Depends(get_current_user) +): + """获取当前用户的聊天对话列表,last_message为字符串""" + user_id = user["user_id"] + conversations = db.query(ChatConversation).filter(ChatConversation.user_id == user_id).order_by(ChatConversation.update_time.desc()).all() + return resp_success(data=[ + { + 'id': c.id, + 'title': c.title, + 'update_time': c.update_time, + 'last_message': c.messages[-1].content if c.messages else None, + } + for c in conversations + ]) + + +@router.get('/messages', response_model=Response[List[MessageVO]]) +def get_messages( + conversation_id: int = Query(...), + db: Session = Depends(get_db), + user=Depends(get_current_user) +): + """获取指定会话的消息列表(当前用户)""" + user_id = user["user_id"] + query = db.query(ChatMessage).filter(ChatMessage.conversation_id == conversation_id, + ChatMessage.user_id == user_id).order_by(ChatMessage.id).all() + return resp_success(data=query) + diff --git a/ai_service/api/v1/vo.py b/ai_service/api/v1/vo.py new file mode 100644 index 0000000..4ad59ae --- /dev/null +++ b/ai_service/api/v1/vo.py @@ -0,0 +1,20 @@ +from pydantic import BaseModel +from datetime import datetime + +class MessageVO(BaseModel): + id: int + content: str + conversation_id: int + type: str + + class Config: + from_attributes = True # 启用ORM模式支持 + +class ConversationsVO(BaseModel): + id: int + title: str + update_time: datetime + last_message: str | None = None + + class Config: + from_attributes = True \ No newline at end of file diff --git a/ai_service/config.py b/ai_service/config.py new file mode 100644 index 0000000..5308341 --- /dev/null +++ b/ai_service/config.py @@ -0,0 +1,12 @@ +import os + +# 数据库配置 +MYSQL_USER = os.getenv('DB_USER', 'root') +MYSQL_PASSWORD = os.getenv('DB_PASSWORD', 'my-secret-pw') +MYSQL_HOST = os.getenv('DB_HOST', 'localhost') +MYSQL_PORT = os.getenv('DB_PORT', '3306') +MYSQL_DB = os.getenv('DB_NAME', 'django_vue') + +SQLALCHEMY_DATABASE_URL = ( + f"mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset=utf8mb4" +) diff --git a/ai_service/crud/base.py b/ai_service/crud/base.py new file mode 100644 index 0000000..b28212e --- /dev/null +++ b/ai_service/crud/base.py @@ -0,0 +1,90 @@ +from typing import Generic, TypeVar, List, Optional, Dict, Any +from fastapi import HTTPException +from sqlalchemy.orm import Session +from datetime import datetime + +# 定义泛型变量(分别对应:SQLAlchemy模型、创建Pydantic模型、更新Pydantic模型) +ModelType = TypeVar("ModelType") +CreateSchemaType = TypeVar("CreateSchemaType") +UpdateSchemaType = TypeVar("UpdateSchemaType") + + +class CRUDBase(Generic[ModelType, CreateSchemaType, UpdateSchemaType]): + def __init__(self, model: ModelType): + """ + 初始化CRUD类,需要传入SQLAlchemy模型 + :param model: SQLAlchemy模型类(如AIApiKey、AIModel等) + """ + self.model = model + + # 创建 + def create(self, db: Session, *, obj_in: CreateSchemaType) -> ModelType: + """创建一条记录""" + obj_in_data = obj_in.model_dump() # 解构Pydantic模型为字典 + + # 自动填充时间字段(如果模型有created_at/updated_at) + if hasattr(self.model, "created_at"): + obj_in_data["created_at"] = datetime.now() + if hasattr(self.model, "updated_at"): + obj_in_data["updated_at"] = datetime.now() + + db_obj = self.model(**obj_in_data) # 实例化模型 + db.add(db_obj) + db.commit() + db.refresh(db_obj) + return db_obj + + # 按ID查询 + def get(self, db: Session, id: int) -> Optional[ModelType]: + """按ID查询单条记录""" + return db.query(self.model).filter(self.model.id == id).first() + + # 按条件查询单条记录 + def get_by(self, db: Session, **kwargs) -> Optional[ModelType]: + """按条件查询单条记录(如get_by(name="test"))""" + return db.query(self.model).filter_by(**kwargs).first() + + # 分页查询所有 + def get_multi( + self, db: Session, *, page: int = 0, limit: int = 100 + ) -> List[ModelType]: + """分页查询多条记录""" + return db.query(self.model).offset(page).limit(limit).all() + + # 更新 + def update( + self, + db: Session, + *, + db_obj: ModelType, + obj_in: UpdateSchemaType | Dict[str, Any] + ) -> ModelType: + """更新记录(支持Pydantic模型或字典)""" + if isinstance(obj_in, dict): + update_data = obj_in + else: + update_data = obj_in.model_dump(exclude_unset=True) # 只更新提供的字段 + + # 遍历更新字段 + for field in update_data: + if hasattr(db_obj, field): + setattr(db_obj, field, update_data[field]) + + # 自动更新updated_at(如果模型有该字段) + if hasattr(db_obj, "updated_at"): + db_obj.updated_at = datetime.now() + + db.add(db_obj) + db.commit() + db.refresh(db_obj) + return db_obj + + # 删除 + def remove(self, db: Session, *, id: int) -> ModelType: + """删除记录""" + obj = db.query(self.model).get(id) + if not obj: + raise HTTPException(status_code=404, detail=f"{self.model.__name__}不存在") + db.delete(obj) + db.commit() + return obj \ No newline at end of file diff --git a/ai_service/db/session.py b/ai_service/db/session.py new file mode 100644 index 0000000..264bcee --- /dev/null +++ b/ai_service/db/session.py @@ -0,0 +1,15 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker, declarative_base +from config import SQLALCHEMY_DATABASE_URL + +engine = create_engine(SQLALCHEMY_DATABASE_URL, pool_pre_ping=True) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +def get_db(): + db = SessionLocal() + try: + yield db + finally: + db.close() + +Base = declarative_base() diff --git a/ai_service/deps/auth.py b/ai_service/deps/auth.py new file mode 100644 index 0000000..35717a8 --- /dev/null +++ b/ai_service/deps/auth.py @@ -0,0 +1,21 @@ +from fastapi import Depends, HTTPException, status, Request +from sqlalchemy.orm import Session + +from db.session import get_db +from models.user import AuthToken, DjangoUser + + +def get_current_user(request: Request, db: Session = Depends(get_db)): + auth = request.headers.get('Authorization') + if not auth or not auth.startswith('Bearer '): + raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail='未登录') + + token = auth.split(' ', 1)[1] + token_obj = db.query(AuthToken).filter(AuthToken.key == token).first() + if not token_obj: + raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail='Token无效或已过期') + + user = db.query(DjangoUser).filter(DjangoUser.id == token_obj.user_id).first() + if not user: + raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail='用户不存在') + return {"user_id": user.id, "username": user.username, "email": user.email} \ No newline at end of file diff --git a/ai_service/main.py b/ai_service/main.py new file mode 100644 index 0000000..4e3a2a9 --- /dev/null +++ b/ai_service/main.py @@ -0,0 +1,31 @@ +import os +from fastapi import FastAPI +from dotenv import load_dotenv +from api.v1 import ai_chat +from fastapi.middleware.cors import CORSMiddleware + +# 加载.env环境变量,优先项目根目录 +load_dotenv() + +app = FastAPI() + +origins = [ + "http://localhost", + "http://localhost:8010", +] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +# 注册路由 +app.include_router(ai_chat.router, prefix="/api/ai/v1", tags=["chat"]) + +# 健康检查 +@app.get("/ping") +def ping(): + return {"msg": "pong"} diff --git a/ai_service/models/ai.py b/ai_service/models/ai.py new file mode 100644 index 0000000..5c94dd3 --- /dev/null +++ b/ai_service/models/ai.py @@ -0,0 +1,253 @@ +from sqlalchemy import ( + Column, Integer, String, Text, DateTime, Boolean, Float, ForeignKey +) +from sqlalchemy.orm import relationship, declarative_base + +from db.session import Base +from models.base import CoreModel +from models.user import DjangoUser # 确保导入 DjangoUser + +# 状态选择类(示例) +class CommonStatus: + DISABLED = 0 + ENABLED = 1 + + @staticmethod + def choices(): + return [(0, '禁用'), (1, '启用')] + + +# 平台选择类(示例) +class PlatformChoices: + OPENAI = 'openai' + ALIMNS = 'alimns' + + @staticmethod + def choices(): + return [('openai', 'OpenAI'), ('alimns', '阿里云MNS')] + + +# 消息类型选择类(示例) +class MessageType: + SYSTEM = "system" # 系统指令 + USER = "user" # 用户消息 + ASSISTANT = "assistant" # 助手回复 + FUNCTION = "function" # 函数返回结果 + + @staticmethod + def choices(): + """返回可用的消息角色选项""" + return [ + (MessageType.SYSTEM, "系统"), + (MessageType.USER, "用户"), + (MessageType.ASSISTANT, "助手"), + (MessageType.FUNCTION, "函数") + ] + + +class MessageContentType: + """消息内容类型""" + TEXT = "text" + FUNCTION_CALL = "function_call" + + @staticmethod + def choices(): + """返回可用的内容类型选项""" + return [ + (MessageContentType.TEXT, "文本"), + (MessageContentType.FUNCTION_CALL, "函数调用") + ] + +# AI API 密钥表 +class AIApiKey(CoreModel): + __tablename__ = 'ai_api_key' + + name = Column(String(255), nullable=False) + platform = Column(String(100), nullable=False) + api_key = Column(String(255), nullable=False) + url = Column(String(255), nullable=True) + status = Column(Integer, default=CommonStatus.DISABLED) + + def __str__(self): + return self.name + + +# AI 模型表 +class AIModel(CoreModel): + __tablename__ = 'ai_model' + + name = Column(String(64), nullable=False) + sort = Column(Integer, default=0) + status = Column(Integer, default=CommonStatus.DISABLED) + key_id = Column(Integer, ForeignKey('ai_api_key.id'), nullable=False) + model_type = Column(String(32), nullable=True) + platform = Column(String(32), nullable=False) + model = Column(String(64), nullable=False) + temperature = Column(Float, nullable=True) + max_tokens = Column(Integer, nullable=True) + max_contexts = Column(Integer, nullable=True) + + key = relationship('AIApiKey', backref='models') + + def __str__(self): + return self.name + + +# AI 工具表 +class Tool(CoreModel): + __tablename__ = 'ai_tool' + + name = Column(String(128), nullable=False) + description = Column(String(256), nullable=True) + status = Column(Integer, default=0) + + def __str__(self): + return self.name + + +# AI 知识库表 +class Knowledge(CoreModel): + __tablename__ = 'ai_knowledge' + + name = Column(String(255), nullable=False) + description = Column(Text, nullable=True) + embedding_model_id = Column(Integer, ForeignKey('ai_model.id'), nullable=False) + embedding_model = Column(String(32), nullable=False) + top_k = Column(Integer, default=0) + similarity_threshold = Column(Float, nullable=False) + status = Column(Integer, default=CommonStatus.DISABLED) + + embedding_model_rel = relationship('AIModel', backref='knowledges') + documents = relationship('KnowledgeDocument', backref='knowledge', cascade='all, delete-orphan') + segments = relationship('KnowledgeSegment', backref='knowledge', cascade='all, delete-orphan') + roles = relationship('ChatRole', secondary='ai_chat_role_knowledge', backref='knowledges') + + def __str__(self): + return self.name + + +# AI 知识库文档表 +class KnowledgeDocument(CoreModel): + __tablename__ = 'ai_knowledge_document' + + knowledge_id = Column(Integer, ForeignKey('ai_knowledge.id'), nullable=False) + name = Column(String(255), nullable=False) + url = Column(String(1024), nullable=False) + content = Column(Text, nullable=False) + content_length = Column(Integer, nullable=False) + tokens = Column(Integer, nullable=False) + segment_max_tokens = Column(Integer, nullable=False) + retrieval_count = Column(Integer, default=0) + status = Column(Integer, default=CommonStatus.DISABLED) + + segments = relationship('KnowledgeSegment', backref='document', cascade='all, delete-orphan') + + def __str__(self): + return self.name + + +# AI 知识库分段表 +class KnowledgeSegment(CoreModel): + __tablename__ = 'ai_knowledge_segment' + + knowledge_id = Column(Integer, ForeignKey('ai_knowledge.id'), nullable=False) + document_id = Column(Integer, ForeignKey('ai_knowledge_document.id'), nullable=False) + content = Column(Text, nullable=False) + content_length = Column(Integer, nullable=False) + tokens = Column(Integer, nullable=False) + vector_id = Column(String(100), nullable=True) + retrieval_count = Column(Integer, default=0) + status = Column(Integer, default=CommonStatus.DISABLED) + + def __str__(self): + return f"Segment {self.id}" + + +# AI 聊天角色表 +class ChatRole(CoreModel): + __tablename__ = 'ai_chat_role' + + name = Column(String(128), nullable=False) + avatar = Column(String(256), nullable=False) + description = Column(String(256), nullable=True) + status = Column(Integer, default=CommonStatus.DISABLED) + sort = Column(Integer, default=0) + public_status = Column(Boolean, default=False) + category = Column(String(32), nullable=True) + model_id = Column(Integer, ForeignKey('ai_model.id'), nullable=False) + system_message = Column(String(1024), nullable=True) + user_id = Column( + Integer, + ForeignKey('system_users.id'), # 假设DjangoUser表名是system_users + nullable=True # 允许为空(如匿名角色) + ) + user = relationship(DjangoUser, backref='chat_roles') # 正确:DjangoUser 已定义并导入 + + model = relationship('AIModel', backref='chat_roles') + tools = relationship('Tool', secondary='ai_chat_role_tool', backref='roles') + # conversations = relationship('ChatConversation', backref='role', cascade='all, delete-orphan') + # messages = relationship('ChatMessage', backref='role', cascade='all, delete-orphan') + + def __str__(self): + return self.name + +# AI 聊天对话表 +class ChatConversation(CoreModel): + __tablename__ = 'ai_chat_conversation' + + title = Column(String(256), nullable=False) + pinned = Column(Boolean, default=False) + pinned_time = Column(DateTime, nullable=True) + user_id = Column(Integer, ForeignKey('system_users.id'), nullable=True) + role_id = Column(Integer, ForeignKey('ai_chat_role.id'), nullable=True) + model_id = Column(Integer, ForeignKey('ai_model.id'), nullable=False) + model = Column(String(32), nullable=False) + system_message = Column(String(1024), nullable=True) + temperature = Column(Float, nullable=False) + max_tokens = Column(Integer, nullable=False) + max_contexts = Column(Integer, nullable=False) + user = relationship(DjangoUser, backref='conversations') # 正确:DjangoUser 已定义并导入 + + model_rel = relationship('AIModel', backref='conversations') + messages = relationship('ChatMessage', backref='conversation', cascade='all, delete-orphan') + + def __str__(self): + return self.title + + +# AI 聊天消息表 +class ChatMessage(CoreModel): + __tablename__ = 'ai_chat_message' + + conversation_id = Column(Integer, ForeignKey('ai_chat_conversation.id'), nullable=False) + user_id = Column(Integer, ForeignKey('system_users.id'), nullable=True) + role_id = Column(Integer, ForeignKey('ai_chat_role.id'), nullable=True) + model = Column(String(32), nullable=False) + model_id = Column(Integer, ForeignKey('ai_model.id'), nullable=False) + type = Column(String(16), nullable=False) + reply_id = Column(Integer, nullable=True) + content = Column(String(2048), nullable=False) + use_context = Column(Boolean, default=False) + segment_ids = Column(String(2048), nullable=True) + + user = relationship(DjangoUser, backref='messages') # 正确:DjangoUser 已定义并导入 + model_rel = relationship('AIModel', backref='messages') + + def __str__(self): + return self.content[:30] + + +# 聊天角色与知识库的关联表 +class ChatRoleKnowledge(Base): + __tablename__ = 'ai_chat_role_knowledge' + + chat_role_id = Column(Integer, ForeignKey('ai_chat_role.id'), primary_key=True) + knowledge_id = Column(Integer, ForeignKey('ai_knowledge.id'), primary_key=True) + + +# 聊天角色与工具的关联表 +class ChatRoleTool(Base): + __tablename__ = 'ai_chat_role_tool' + + chat_role_id = Column(Integer, ForeignKey('ai_chat_role.id'), primary_key=True) + tool_id = Column(Integer, ForeignKey('ai_tool.id'), primary_key=True) \ No newline at end of file diff --git a/ai_service/models/base.py b/ai_service/models/base.py new file mode 100644 index 0000000..8cfe077 --- /dev/null +++ b/ai_service/models/base.py @@ -0,0 +1,13 @@ +from db.session import Base +from sqlalchemy import ( + Column, Integer, String, Text, DateTime, Boolean, Float, ForeignKey +) + +# 基础模型类 +class CoreModel(Base): + __abstract__ = True + + id = Column(Integer, primary_key=True, autoincrement=True) + create_time = Column(DateTime) + update_time = Column(DateTime) + is_deleted = Column(Boolean, default=False) diff --git a/ai_service/models/user.py b/ai_service/models/user.py new file mode 100644 index 0000000..b9c573f --- /dev/null +++ b/ai_service/models/user.py @@ -0,0 +1,24 @@ +from sqlalchemy import Column, Integer, String, DateTime, Boolean + +from db.session import Base + + +class AuthToken(Base): + __tablename__ = 'authtoken_token' + key = Column(String(40), primary_key=True) + user_id = Column(Integer, nullable=False) + created = Column(DateTime) + + +class DjangoUser(Base): + __tablename__ = 'system_users' + + id = Column(Integer, primary_key=True) + username = Column(String(150), nullable=False) + email = Column(String(254)) + password = Column(String(128)) + is_active = Column(Boolean, default=True) + is_staff = Column(Boolean, default=False) + is_superuser = Column(Boolean, default=False) + last_login = Column(DateTime) + date_joined = Column(DateTime) \ No newline at end of file diff --git a/ai_service/requirements.txt b/ai_service/requirements.txt new file mode 100644 index 0000000..e550d78 --- /dev/null +++ b/ai_service/requirements.txt @@ -0,0 +1,8 @@ +fastapi==0.116.1 +uvicorn[standard]==0.35.0 +langchain-openai==0.3.28 +langchain-deepseek==0.1.3 +langchain==0.3.26 +langchain-community==0.3.26 +PyMySQL==1.1.1 +SQLAlchemy==2.0.41 \ No newline at end of file diff --git a/ai_service/routers/base.py b/ai_service/routers/base.py new file mode 100644 index 0000000..e63acc5 --- /dev/null +++ b/ai_service/routers/base.py @@ -0,0 +1,101 @@ +from fastapi import APIRouter, Depends, HTTPException +from sqlalchemy.orm import Session +from typing import Generic, TypeVar, List + +from db.session import get_db +from schemas.base import ReadSchemaType # 通用的响应模型基类 +from crud.base import CRUDBase + +# 泛型变量(对应:CRUD类、创建模型、更新模型、响应模型) +CRUDType = TypeVar("CRUDType") +CreateSchemaType = TypeVar("CreateSchemaType") +UpdateSchemaType = TypeVar("UpdateSchemaType") +ReadSchemaType = TypeVar("ReadSchemaType") + + +class GenericRouter( + APIRouter, + Generic[CRUDType, CreateSchemaType, UpdateSchemaType, ReadSchemaType] +): + def __init__( + self, + crud: CRUDType, + create_schema: CreateSchemaType, + update_schema: UpdateSchemaType, + read_schema: ReadSchemaType, + prefix: str, + tags: List[str], + **kwargs + ): + """ + 初始化通用路由 + :param crud: CRUD实例(如CRUDApiKey) + :param create_schema: 创建Pydantic模型 + :param update_schema: 更新Pydantic模型 + :param read_schema: 响应Pydantic模型 + :param prefix: 路由前缀(如"/api/ai-api-keys") + :param tags: 文档标签 + """ + super().__init__(prefix=prefix, tags=tags,** kwargs) + self.crud = crud + self.create_schema = create_schema + self.update_schema = update_schema + self.read_schema = read_schema + + # 注册通用路由 + self.add_api_route( + "/", + self.create, + methods=["POST"], + response_model=read_schema, + status_code=201 + ) + self.add_api_route( + "/", + self.get_multi, + methods=["GET"], + response_model=List[read_schema] + ) + self.add_api_route( + "/{id}/", + self.get, + methods=["GET"], + response_model=read_schema + ) + self.add_api_route( + "/{id}/", + self.update, + methods=["PUT"], + response_model=read_schema + ) + self.add_api_route( + "/{id}/", + self.remove, + methods=["DELETE"] + ) + + # 创建 + def create(self, obj_in: CreateSchemaType, db: Session = Depends(get_db)): + return self.crud.create(db=db, obj_in=obj_in) + + # 按ID查询 + def get(self, id: int, db: Session = Depends(get_db)): + obj = self.crud.get(db=db, id=id) + if not obj: + raise HTTPException(status_code=404, detail=f"记录不存在") + return obj + + # 分页查询 + def get_multi(self, page: int = 0, limit: int = 10, db: Session = Depends(get_db)): + return self.crud.get_multi(db=db, page=page, limit=limit) + + # 更新 + def update(self, id: int, obj_in: UpdateSchemaType, db: Session = Depends(get_db)): + obj = self.crud.get(db=db, id=id) + if not obj: + raise HTTPException(status_code=404, detail=f"记录不存在") + return self.crud.update(db=db, db_obj=obj, obj_in=obj_in) + + # 删除 + def remove(self, id: int, db: Session = Depends(get_db)): + return self.crud.remove(db=db, id=id) \ No newline at end of file diff --git a/ai_service/schemas/ai_api_key.py b/ai_service/schemas/ai_api_key.py new file mode 100644 index 0000000..eba96ba --- /dev/null +++ b/ai_service/schemas/ai_api_key.py @@ -0,0 +1,33 @@ +from pydantic import BaseModel, Field +from typing import Optional +from datetime import datetime + +# 基础模型(共享字段) +class AIApiKeyBase(BaseModel): + name: str = Field(..., max_length=255, description="密钥名称") + platform: str = Field(..., max_length=100, description="平台(如openai)") + api_key: str = Field(..., max_length=255, description="API密钥") + url: Optional[str] = Field(None, max_length=255, description="自定义API地址") + status: int = Field(0, description="状态(0=禁用,1=启用)") + +# 创建请求模型(无需ID和时间字段) +class AIApiKeyCreate(AIApiKeyBase): + pass + +# 更新请求模型(所有字段可选) +class AIApiKeyUpdate(BaseModel): + name: Optional[str] = Field(None, max_length=255) + platform: Optional[str] = Field(None, max_length=100) + api_key: Optional[str] = Field(None, max_length=255) + url: Optional[str] = Field(None, max_length=255) + status: Optional[int] = None + +# 响应模型(包含数据库自动生成的字段) +class AIApiKeyRead(AIApiKeyBase): + id: int + created_at: Optional[datetime] + updated_at: Optional[datetime] + + # 支持ORM模型直接转换为响应 + class Config: + from_attributes = True # Pydantic v2用from_attributes,v1用orm_mode \ No newline at end of file diff --git a/ai_service/schemas/ai_chat.py b/ai_service/schemas/ai_chat.py new file mode 100644 index 0000000..c296902 --- /dev/null +++ b/ai_service/schemas/ai_chat.py @@ -0,0 +1,10 @@ +from pydantic import BaseModel + +class ChatCreate(BaseModel): + pass + +class Chat(ChatCreate): + id: int + + class Config: + orm_mode = True \ No newline at end of file diff --git a/ai_service/schemas/base.py b/ai_service/schemas/base.py new file mode 100644 index 0000000..ad50867 --- /dev/null +++ b/ai_service/schemas/base.py @@ -0,0 +1,19 @@ +from pydantic import BaseModel +from datetime import datetime +from typing import Optional + +class ReadSchemaType(BaseModel): + """ + 所有响应模型的基类,包含公共字段和ORM转换配置 + """ + id: int + created_at: Optional[datetime] = None # 数据创建时间(可选,部分模型可能没有) + updated_at: Optional[datetime] = None # 数据更新时间(可选) + + class Config: + """ + 配置Pydantic模型如何处理ORM对象: + - from_attributes=True:支持直接从SQLAlchemy ORM模型转换(Pydantic v2) + - 若使用Pydantic v1,需替换为 orm_mode=True + """ + from_attributes = True \ No newline at end of file diff --git a/ai_service/schemas/user.py b/ai_service/schemas/user.py new file mode 100644 index 0000000..9906b3b --- /dev/null +++ b/ai_service/schemas/user.py @@ -0,0 +1,9 @@ +from pydantic import BaseModel + +class UserOut(BaseModel): + id: int + username: str + email: str = None + + class Config: + orm_mode = True \ No newline at end of file diff --git a/ai_service/services/chat_service.py b/ai_service/services/chat_service.py new file mode 100644 index 0000000..9a34e2d --- /dev/null +++ b/ai_service/services/chat_service.py @@ -0,0 +1,95 @@ +# LangChain集成示例 +from sqlalchemy.orm import Session +from datetime import datetime +from models.ai import ChatConversation, ChatMessage, MessageType + +class ChatDBService: + @staticmethod + def get_conversation(db: Session, conversation_id: int): + return db.query(ChatConversation).filter(ChatConversation.id == conversation_id).first() + + @staticmethod + def get_or_create_conversation(db: Session, conversation_id: int | None, user_id: int, model: str, content: str) -> ChatConversation: + if not conversation_id: + conversation = ChatConversation( + title=content, + user_id=user_id, + role_id=None, + model_id=None, # 需根据实际模型id调整 + model=model, + system_message=None, + temperature=0.7, + max_tokens=2048, + max_contexts=10, + create_time=datetime.now(), + update_time=datetime.now(), + is_deleted=False + ) + db.add(conversation) + db.commit() + db.refresh(conversation) + return conversation + else: + conversation = db.query(ChatConversation).get(conversation_id) + if not conversation: + raise ValueError("无效的conversation_id") + return conversation + + @staticmethod + def update_conversation_title(db, conversation_id: int, title: str): + conversation = db.query(ChatConversation).filter(ChatConversation.id == conversation_id).first() + if conversation: + conversation.title = title[:255] # 保证不超过255字符 + db.add(conversation) + db.commit() + return conversation + else: + raise ValueError("Conversation not found") + + @staticmethod + def add_message(db: Session, conversation: ChatConversation, user_id: int, content: str) -> ChatMessage: + message = ChatMessage( + conversation_id=conversation.id, + user_id=user_id, + role_id=None, + model=conversation.model, + model_id=conversation.model_id, + type=MessageType.USER, + reply_id=None, + content=content, + use_context=True, + segment_ids=None, + create_time=datetime.now(), + update_time=datetime.now(), + is_deleted=False + ) + db.add(message) + db.commit() + return message + + @staticmethod + def insert_ai_message(db: Session, conversation, user_id: int, content: str, model: str): + from datetime import datetime + from models.ai import MessageType + message = ChatMessage( + conversation_id=conversation.id, + user_id=user_id, + role_id=None, + model=model, + model_id=conversation.model_id, + type=MessageType.ASSISTANT, + reply_id=None, + content=content, + use_context=True, + segment_ids=None, + create_time=datetime.now(), + update_time=datetime.now(), + is_deleted=False + ) + db.add(message) + db.commit() + + @staticmethod + def get_history(db: Session, conversation_id: int) -> list[ChatMessage]: + return db.query(ChatMessage).filter_by(conversation_id=conversation_id).order_by(ChatMessage.id).all() + diff --git a/ai_service/utils/jwt.py b/ai_service/utils/jwt.py new file mode 100644 index 0000000..cf9f2b6 --- /dev/null +++ b/ai_service/utils/jwt.py @@ -0,0 +1 @@ +# 预留:如需JWT校验可在此实现 \ No newline at end of file diff --git a/ai_service/utils/resp.py b/ai_service/utils/resp.py new file mode 100644 index 0000000..8af103e --- /dev/null +++ b/ai_service/utils/resp.py @@ -0,0 +1,16 @@ +from typing import Generic, TypeVar, Optional + +from pydantic import BaseModel + +T = TypeVar("T") + +class Response(BaseModel, Generic[T]): + code: int + message: str + data: Optional[T] = None # ✅ 明确 data 可为 None + +def resp_success(data: T, message: str = "success") -> Response[T]: + return Response(code=0, message=message, data=data) + +def resp_error(message="error", code=1) -> Response[T]: + return Response(code=code, message=message, data=None) \ No newline at end of file diff --git a/backend/ai/migrations/0004_alter_chatconversation_model_id_and_more.py b/backend/ai/migrations/0004_alter_chatconversation_model_id_and_more.py new file mode 100644 index 0000000..5ec6358 --- /dev/null +++ b/backend/ai/migrations/0004_alter_chatconversation_model_id_and_more.py @@ -0,0 +1,40 @@ +# Generated by Django 5.2.1 on 2025-07-17 07:07 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("ai", "0003_aimodel_model_type"), + ] + + operations = [ + migrations.AlterField( + model_name="chatconversation", + name="model_id", + field=models.ForeignKey( + blank=True, + db_column="model_id", + db_comment="向量模型编号", + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="ai.aimodel", + verbose_name="向量模型编号", + ), + ), + migrations.AlterField( + model_name="chatmessage", + name="model_id", + field=models.ForeignKey( + blank=True, + db_column="model_id", + db_comment="向量模型编号", + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="ai.aimodel", + verbose_name="向量模型编号", + ), + ), + ] diff --git a/backend/ai/models.py b/backend/ai/models.py index 10f94b6..3f4266a 100644 --- a/backend/ai/models.py +++ b/backend/ai/models.py @@ -258,6 +258,7 @@ class ChatConversation(CoreModel): model_id = models.ForeignKey( 'AIModel', on_delete=models.CASCADE, + null=True, blank=True, db_column='model_id', verbose_name="向量模型编号", db_comment='向量模型编号' @@ -302,6 +303,7 @@ class ChatMessage(CoreModel): model_id = models.ForeignKey( 'AIModel', on_delete=models.CASCADE, + null=True, blank=True, db_column='model_id', verbose_name="向量模型编号", db_comment='向量模型编号' diff --git a/backend/ai/urls.py b/backend/ai/urls.py index 73a489d..3df0452 100644 --- a/backend/ai/urls.py +++ b/backend/ai/urls.py @@ -4,10 +4,13 @@ from rest_framework import routers from . import views router = routers.DefaultRouter() -router.register(r'ai_api_key', views.AIApiKeyViewSet) +router.register(r'api_key', views.AIApiKeyViewSet) router.register(r'ai_model', views.AIModelViewSet) router.register(r'tool', views.ToolViewSet) router.register(r'knowledge', views.KnowledgeViewSet) +router.register(r'chat_conversation', views.ChatConversationViewSet) +router.register(r'chat_message', views.ChatMessageViewSet) + urlpatterns = [ path('', include(router.urls)), diff --git a/backend/ai/views/__init__.py b/backend/ai/views/__init__.py index 66c8d61..7e5fa57 100644 --- a/backend/ai/views/__init__.py +++ b/backend/ai/views/__init__.py @@ -3,9 +3,13 @@ __all__ = [ 'AIModelViewSet', 'ToolViewSet', 'KnowledgeViewSet', + 'ChatConversationViewSet', + 'ChatMessageViewSet', ] from ai.views.ai_api_key import AIApiKeyViewSet from ai.views.ai_model import AIModelViewSet from ai.views.tool import ToolViewSet -from ai.views.knowledge import KnowledgeViewSet \ No newline at end of file +from ai.views.knowledge import KnowledgeViewSet +from ai.views.chat_conversation import ChatConversationViewSet +from ai.views.chat_message import ChatMessageViewSet \ No newline at end of file diff --git a/backend/ai/views/chat_conversation.py b/backend/ai/views/chat_conversation.py new file mode 100644 index 0000000..3a41b5b --- /dev/null +++ b/backend/ai/views/chat_conversation.py @@ -0,0 +1,39 @@ +from rest_framework import serializers + +from ai.models import ChatConversation +from utils.serializers import CustomModelSerializer +from utils.custom_model_viewSet import CustomModelViewSet +from django_filters import rest_framework as filters + + +class ChatConversationSerializer(CustomModelSerializer): + username = serializers.CharField(source='user.username', read_only=True) + + """ + AI 聊天对话 序列化器 + """ + class Meta: + model = ChatConversation + fields = '__all__' + read_only_fields = ['id', 'create_time', 'update_time'] + +class ChatConversationFilter(filters.FilterSet): + + class Meta: + model = ChatConversation + fields = ['id', 'remark', 'creator', 'modifier', 'is_deleted', 'title', 'pinned', 'model', + 'system_message', 'max_tokens', 'max_contexts'] + + +class ChatConversationViewSet(CustomModelViewSet): + """ + AI 聊天对话 视图集 + """ + queryset = ChatConversation.objects.filter(is_deleted=False).order_by('-id') + serializer_class = ChatConversationSerializer + filterset_class = ChatConversationFilter + search_fields = ['name'] # 根据实际字段调整 + ordering_fields = ['create_time', 'id'] + ordering = ['-create_time'] + +# 移入urls中 diff --git a/backend/ai/views/chat_message.py b/backend/ai/views/chat_message.py new file mode 100644 index 0000000..4c4611e --- /dev/null +++ b/backend/ai/views/chat_message.py @@ -0,0 +1,38 @@ +from rest_framework import serializers + +from ai.models import ChatMessage +from utils.serializers import CustomModelSerializer +from utils.custom_model_viewSet import CustomModelViewSet +from django_filters import rest_framework as filters + + +class ChatMessageSerializer(CustomModelSerializer): + username = serializers.CharField(source='user.username', read_only=True) + """ + AI 聊天消息 序列化器 + """ + class Meta: + model = ChatMessage + fields = '__all__' + read_only_fields = ['id', 'create_time', 'update_time'] + + +class ChatMessageFilter(filters.FilterSet): + + class Meta: + model = ChatMessage + fields = ['id', 'remark', 'creator', 'modifier', 'is_deleted', 'conversation_id', + 'model', 'type', 'reply_id', 'content', 'use_context', 'segment_ids'] + + +class ChatMessageViewSet(CustomModelViewSet): + """ + AI 聊天消息 视图集 + """ + queryset = ChatMessage.objects.filter(is_deleted=False).order_by('-id') + serializer_class = ChatMessageSerializer + filterset_class = ChatMessageFilter + search_fields = ['name'] # 根据实际字段调整 + ordering_fields = ['create_time', 'id'] + ordering = ['-create_time'] + diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 988ccec..cf3acb5 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -53,7 +53,7 @@ INSTALLED_APPS = [ 'django_filters', 'corsheaders', 'rest_framework.authtoken', - 'channels', + # 'channels', "system", "ai", ] @@ -104,7 +104,6 @@ DATABASES = { 'USER': os.getenv('DB_USER', 'chenze'), 'PASSWORD': os.getenv('DB_PASSWORD', 'my-secret-pw'), 'HOST': os.getenv('DB_HOST', 'localhost'), - # 'HOST': 'localhost', } } @@ -236,11 +235,11 @@ ASGI_APPLICATION = 'backend.asgi.application' # 简单用内存通道层 -CHANNEL_LAYERS = { - 'default': { - 'BACKEND': 'channels.layers.InMemoryChannelLayer' - } -} +# CHANNEL_LAYERS = { +# 'default': { +# 'BACKEND': 'channels.layers.InMemoryChannelLayer' +# } +# } if os.path.exists(os.path.join(BASE_DIR, 'backend/local_settings.py')): from backend.local_settings import * \ No newline at end of file diff --git a/backend/backend/urls.py b/backend/backend/urls.py index f6e6303..a0710d4 100644 --- a/backend/backend/urls.py +++ b/backend/backend/urls.py @@ -19,8 +19,8 @@ from django.urls import path, include from django.conf import settings urlpatterns = [ - path('api/system/', include('system.urls')), - path('api/ai/', include('ai.urls')), + path('api/admin/system/', include('system.urls')), + path('api/admin/ai/', include('ai.urls')), ] # 演示环境下禁用 admin 路由 diff --git a/backend/system/management/commands/tpl/viewset.py.tpl b/backend/system/management/commands/tpl/viewset.py.tpl index 85a83b8..8ecba6b 100644 --- a/backend/system/management/commands/tpl/viewset.py.tpl +++ b/backend/system/management/commands/tpl/viewset.py.tpl @@ -14,7 +14,7 @@ class ${model_name}Serializer(CustomModelSerializer): read_only_fields = ['id', 'create_time', 'update_time'] -class $model_nameFilter(filters.FilterSet): +class ${model_name}Filter(filters.FilterSet): class Meta: model = $model_name @@ -27,10 +27,12 @@ class ${model_name}ViewSet(CustomModelViewSet): """ queryset = $model_name.objects.filter(is_deleted=False).order_by('-id') serializer_class = ${model_name}Serializer - filterset_class = [$filterset_fields] + filterset_class = ${model_name}Filter search_fields = ['name'] # 根据实际字段调整 ordering_fields = ['create_time', 'id'] ordering = ['-create_time'] # 移入urls中 # router.register(r'${model_name_snake}', views.${model_name}ViewSet) +# 移入 __init__.py +# from ${app_name}.views.${model_name_snake} import ${model_name}ViewSet \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index c32c4a4..4e32c10 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -106,12 +106,32 @@ services: - "45678:5678" depends_on: - backend + - ai_service networks: - dj_admin_network env_file: - ./docker/.env.dev - ./docker/.env.local + ai_service: + build: + context: ./ai_service + dockerfile: Dockerfile + target: dev + volumes: + - ./ai_service:/app + ports: + - "48010:8010" + depends_on: + - db + - redis + networks: + - dj_admin_network + env_file: + - ./docker/.env.dev + - ./docker/.env.local + command: uvicorn main:app --host 0.0.0.0 --port 8010 --reload + networks: dj_admin_network: driver: bridge \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index dda1353..628bf12 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -90,6 +90,24 @@ services: networks: - app_net + ai_service: + build: + context: ./ai_service + dockerfile: Dockerfile # 复用 backend 的 Dockerfile + target: prod + volumes: + - ./ai_service:/app + ports: + - "38010:8010" + depends_on: + - db + - redis + networks: + - dj_admin_network + env_file: + - ./docker/.env.dev + - ./docker/.env.local + command: uvicorn main:app --host 0.0.0.0 --port 8010 --reload frontend: build: @@ -98,6 +116,7 @@ services: target: prod depends_on: - backend + - ai_service ports: - "35678:80" networks: diff --git a/docker/.env.dev b/docker/.env.dev index fa2a22a..8a39c39 100644 --- a/docker/.env.dev +++ b/docker/.env.dev @@ -1,5 +1,7 @@ # web VITE_BACKEND_URL=http://backend:8000 +VITE_AI_URL=http://ai_service:8010 + # oss VITE_OSS_ENABLED=false VITE_OSS_REGION=oss-cn-hangzhou diff --git a/docker/.env.example b/docker/.env.example index ad0159f..1889694 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1,5 +1,6 @@ # web VITE_BACKEND_URL=http://backend:8000 +VITE_AI_URL=http://ai_service:8010 VITE_OSS_ENABLED=false VITE_OSS_REGION=oss-cn-hangzhou @@ -40,3 +41,12 @@ BACKEND_PORT=8000 # Nginx NGINX_PORT=80 + + +# fastapi +# openai +OPENAI_API_KEY=你的API密钥 +# deepseek +DEEPSEEK_API_KEY='你的API密钥' +# 通义千问 +DASHSCOPE_API_KEY='你的API密钥' \ No newline at end of file diff --git a/sql/django_vue.sql b/sql/django_vue.sql index 257a429..b8df31f 100644 --- a/sql/django_vue.sql +++ b/sql/django_vue.sql @@ -11,12 +11,383 @@ Target Server Version : 90300 (9.3.0) File Encoding : 65001 - Date: 07/07/2025 00:04:11 + Date: 18/07/2025 22:06:55 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; +-- ---------------------------- +-- Table structure for ai_api_key +-- ---------------------------- +DROP TABLE IF EXISTS `ai_api_key`; +CREATE TABLE `ai_api_key` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `name` varchar(255) NOT NULL COMMENT '名称', + `platform` varchar(100) NOT NULL COMMENT '平台', + `api_key` varchar(255) NOT NULL COMMENT '密钥', + `url` varchar(255) DEFAULT NULL COMMENT '自定义 API 地址', + `status` smallint NOT NULL COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_api_key +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_chat_conversation +-- ---------------------------- +DROP TABLE IF EXISTS `ai_chat_conversation`; +CREATE TABLE `ai_chat_conversation` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `title` varchar(256) NOT NULL COMMENT '对话标题', + `pinned` tinyint(1) NOT NULL COMMENT '是否置顶', + `pinned_time` datetime(6) DEFAULT NULL COMMENT '置顶时间', + `model` varchar(32) NOT NULL COMMENT '模型标识', + `system_message` varchar(1024) DEFAULT NULL COMMENT '角色设定', + `temperature` double NOT NULL COMMENT '温度参数', + `max_tokens` int NOT NULL COMMENT '单条回复的最大 Token 数量', + `max_contexts` int NOT NULL COMMENT '上下文的最大 Message 数量', + `model_id` bigint DEFAULT NULL, + `user_id` bigint DEFAULT NULL COMMENT '用户编号', + `role_id` bigint DEFAULT NULL COMMENT '聊天角色', + PRIMARY KEY (`id`), + KEY `ai_chat_conversation_user_id_665a1c32_fk_system_users_id` (`user_id`), + KEY `ai_chat_conversation_role_id_131abc00_fk_ai_chat_role_id` (`role_id`), + KEY `ai_chat_conversation_model_id_9c5fae9a_fk_ai_model_id` (`model_id`), + CONSTRAINT `ai_chat_conversation_model_id_9c5fae9a_fk_ai_model_id` FOREIGN KEY (`model_id`) REFERENCES `ai_model` (`id`), + CONSTRAINT `ai_chat_conversation_role_id_131abc00_fk_ai_chat_role_id` FOREIGN KEY (`role_id`) REFERENCES `ai_chat_role` (`id`), + CONSTRAINT `ai_chat_conversation_user_id_665a1c32_fk_system_users_id` FOREIGN KEY (`user_id`) REFERENCES `system_users` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_chat_conversation +-- ---------------------------- +BEGIN; +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (5, NULL, NULL, NULL, '2025-07-17 23:44:51.756138', '2025-07-17 23:44:51.756113', 0, '你好', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (6, NULL, NULL, NULL, '2025-07-17 23:45:14.242294', '2025-07-17 23:45:14.242287', 0, '我是谁', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (8, NULL, NULL, NULL, '2025-07-18 00:22:11.267134', '2025-07-18 00:22:11.267125', 0, '新对话', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (9, NULL, NULL, NULL, '2025-07-18 00:22:18.797899', '2025-07-18 00:22:18.797895', 0, '你好', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (10, NULL, NULL, NULL, '2025-07-18 00:22:43.954976', '2025-07-18 00:22:43.954971', 0, '你是谁', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (11, NULL, NULL, NULL, '2025-07-18 00:27:08.838421', '2025-07-18 00:27:08.838402', 0, '新对话', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (12, NULL, NULL, NULL, '2025-07-18 00:32:17.081943', '2025-07-18 00:32:17.081912', 0, '你是谁', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (13, NULL, NULL, NULL, '2025-07-18 00:33:15.110765', '2025-07-18 00:33:15.110756', 0, '你是', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (14, NULL, NULL, NULL, '2025-07-18 00:39:28.716268', '2025-07-18 00:39:28.716260', 0, '你是', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (15, NULL, NULL, NULL, '2025-07-18 00:41:21.769416', '2025-07-18 00:41:21.769411', 0, '你是', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +INSERT INTO `ai_chat_conversation` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `pinned`, `pinned_time`, `model`, `system_message`, `temperature`, `max_tokens`, `max_contexts`, `model_id`, `user_id`, `role_id`) VALUES (16, NULL, NULL, NULL, '2025-07-18 00:45:04.380332', '2025-07-18 00:45:04.380325', 0, '新对话', 0, NULL, 'deepseek-chat', NULL, 0.7, 2048, 10, NULL, 1, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for ai_chat_message +-- ---------------------------- +DROP TABLE IF EXISTS `ai_chat_message`; +CREATE TABLE `ai_chat_message` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `conversation_id` bigint NOT NULL COMMENT '对话编号', + `model` varchar(32) NOT NULL COMMENT '模型标识', + `type` varchar(16) NOT NULL COMMENT '消息类型', + `reply_id` bigint DEFAULT NULL COMMENT '回复编号', + `content` varchar(2048) NOT NULL COMMENT '消息内容', + `use_context` tinyint(1) NOT NULL COMMENT '是否携带上下文', + `segment_ids` varchar(2048) DEFAULT NULL COMMENT '段落编号数组', + `model_id` bigint DEFAULT NULL, + `user_id` bigint DEFAULT NULL COMMENT '用户编号', + `role_id` bigint DEFAULT NULL COMMENT '聊天角色', + PRIMARY KEY (`id`), + KEY `ai_chat_message_user_id_6decfb1e_fk_system_users_id` (`user_id`), + KEY `ai_chat_message_role_id_c202a7d5_fk_ai_chat_role_id` (`role_id`), + KEY `ai_chat_message_model_id_93e26b23_fk_ai_model_id` (`model_id`), + CONSTRAINT `ai_chat_message_model_id_93e26b23_fk_ai_model_id` FOREIGN KEY (`model_id`) REFERENCES `ai_model` (`id`), + CONSTRAINT `ai_chat_message_role_id_c202a7d5_fk_ai_chat_role_id` FOREIGN KEY (`role_id`) REFERENCES `ai_chat_role` (`id`), + CONSTRAINT `ai_chat_message_user_id_6decfb1e_fk_system_users_id` FOREIGN KEY (`user_id`) REFERENCES `system_users` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_chat_message +-- ---------------------------- +BEGIN; +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (26, NULL, NULL, NULL, '2025-07-17 23:44:51.774922', '2025-07-17 23:44:51.774911', 0, 5, 'deepseek-chat', 'user', NULL, '你好', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (27, NULL, NULL, NULL, '2025-07-17 23:44:55.729615', '2025-07-17 23:44:55.729609', 0, 5, 'deepseek-chat', 'assistant', NULL, '你好!很高兴见到你,有什么可以帮你的吗?😊', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (28, NULL, NULL, NULL, '2025-07-17 23:45:14.252434', '2025-07-17 23:45:14.252431', 0, 6, 'deepseek-chat', 'user', NULL, '我是谁', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (29, NULL, NULL, NULL, '2025-07-17 23:45:21.588905', '2025-07-17 23:45:21.588894', 0, 6, 'deepseek-chat', 'assistant', NULL, '你是独一无二的你!✨ 不过,如果你愿意分享更多关于自己的信息(比如名字、兴趣、经历等),我可以帮你更具体地回答这个问题哦~ 😊 \n\n(或者你是在问哲学层面的“自我定义”?那我们也可以聊聊笛卡尔、佛学或科幻里的身份理论!🔍)', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (32, NULL, NULL, NULL, '2025-07-18 00:22:18.811273', '2025-07-18 00:22:18.811272', 0, 9, 'deepseek-chat', 'user', NULL, '你好', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (33, NULL, NULL, NULL, '2025-07-18 00:22:22.997597', '2025-07-18 00:22:22.997571', 0, 9, 'deepseek-chat', 'assistant', NULL, '你好!有什么可以帮您的吗?😊', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (34, NULL, NULL, NULL, '2025-07-18 00:22:43.964812', '2025-07-18 00:22:43.964810', 0, 10, 'deepseek-chat', 'user', NULL, '你是谁', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (35, NULL, NULL, NULL, '2025-07-18 00:22:50.153996', '2025-07-18 00:22:50.153983', 0, 10, 'deepseek-chat', 'assistant', NULL, '我是DeepSeek Chat,一个由深度求索公司创造的智能AI助手!✨ 我的任务是帮助你解答问题、提供信息、陪你聊天,或者解决各种难题。无论是学习、工作,还是日常生活中的疑问,都可以问我哦!😊 有什么我可以帮你的吗?', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (36, NULL, NULL, NULL, '2025-07-18 00:27:20.011115', '2025-07-18 00:27:20.011111', 0, 11, 'deepseek-chat', 'user', NULL, '你是谁', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (37, NULL, NULL, NULL, '2025-07-18 00:27:26.401983', '2025-07-18 00:27:26.401972', 0, 11, 'deepseek-chat', 'assistant', NULL, '我是DeepSeek Chat,由深度求索公司创造的智能AI助手!😊 我可以帮你回答问题、提供建议、陪你聊天,甚至帮你处理各种文本和文件。如果有任何问题或需要帮助,尽管问我吧!', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (38, NULL, NULL, NULL, '2025-07-18 00:27:29.832141', '2025-07-18 00:27:29.832135', 0, 11, 'deepseek-chat', 'user', NULL, '我是谁', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (39, NULL, NULL, NULL, '2025-07-18 00:27:39.674170', '2025-07-18 00:27:39.674155', 0, 11, 'deepseek-chat', 'assistant', NULL, '你是独一无二的你!✨ \n\n不过,作为一个AI助手,我无法直接知道你的身份(除非你主动告诉我)。你可以是学生、职场人、创作者,或者只是对某个话题好奇的朋友——无论你是谁,我都会尽力为你提供有用的信息或愉快的聊天体验!😊 \n\n如果你想让我“记住”某些信息(比如你的名字或偏好),可以在对话中告诉我,我会在本次聊天中尽量参考哦~', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (40, NULL, NULL, NULL, '2025-07-18 00:32:21.177483', '2025-07-18 00:32:21.177477', 0, 12, 'deepseek-chat', 'user', NULL, '你是谁', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (41, NULL, NULL, NULL, '2025-07-18 00:32:30.351696', '2025-07-18 00:32:30.351692', 0, 12, 'deepseek-chat', 'user', NULL, '我是谁', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (42, NULL, NULL, NULL, '2025-07-18 00:32:37.947545', '2025-07-18 00:32:37.947532', 0, 12, 'deepseek-chat', 'assistant', NULL, '我是你的智能助手,随时为你提供帮助和解答问题!😊 你可以问我任何问题,或者让我帮你完成各种任务,比如查找信息、学习知识、写作建议等。 \n\n至于“你是谁”——这取决于你想成为怎样的人哦!不过在这里,你是一位值得被认真对待的用户,而我的目标就是尽力协助你。有什么我可以为你做的吗?', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (43, NULL, NULL, NULL, '2025-07-18 00:33:17.814681', '2025-07-18 00:33:17.814677', 0, 13, 'deepseek-chat', 'user', NULL, '你是', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (44, NULL, NULL, NULL, '2025-07-18 00:39:31.629116', '2025-07-18 00:39:31.629111', 0, 14, 'deepseek-chat', 'user', NULL, '你是', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (45, NULL, NULL, NULL, '2025-07-18 00:39:39.256897', '2025-07-18 00:39:39.256892', 0, 14, 'deepseek-chat', 'user', NULL, '我是', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (46, NULL, NULL, NULL, '2025-07-18 00:39:43.893360', '2025-07-18 00:39:43.893343', 0, 14, 'deepseek-chat', 'assistant', NULL, '我是你的智能助手,随时为你提供帮助和解答问题!😊 你可以问我任何问题,或者让我帮你完成一些任务。有什么我可以帮你的吗?', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (47, NULL, NULL, NULL, '2025-07-18 00:41:24.586063', '2025-07-18 00:41:24.586059', 0, 15, 'deepseek-chat', 'user', NULL, '你是', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (48, NULL, NULL, NULL, '2025-07-18 00:41:34.010252', '2025-07-18 00:41:34.010249', 0, 15, 'deepseek-chat', 'user', NULL, '我是', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (49, NULL, NULL, NULL, '2025-07-18 00:41:39.287403', '2025-07-18 00:41:39.287384', 0, 15, 'deepseek-chat', 'assistant', NULL, '我是你的智能助手,随时为你提供帮助!😊 你可以问我任何问题,我会尽力解答。有什么我可以帮你的吗?', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (50, NULL, NULL, NULL, '2025-07-18 00:45:07.144313', '2025-07-18 00:45:07.144308', 0, 16, 'deepseek-chat', 'user', NULL, '你是', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (51, NULL, NULL, NULL, '2025-07-18 11:11:13.888781', '2025-07-18 11:11:13.888777', 0, 16, 'deepseek-chat', 'user', NULL, 'nihao ', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (52, NULL, NULL, NULL, '2025-07-18 11:11:20.070788', '2025-07-18 11:11:20.070769', 0, 16, 'deepseek-chat', 'assistant', NULL, '你好!我是你的AI助手,很高兴为你提供帮助。如果你有任何问题或需要协助,随时告诉我哦!😊 \n\n(Note: 你输入的“nihao”是拼音形式,已自动理解为中文问候~)', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (53, NULL, NULL, NULL, '2025-07-18 11:55:24.036652', '2025-07-18 11:55:24.036639', 0, 16, 'deepseek-chat', 'user', NULL, '你好啊', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (54, NULL, NULL, NULL, '2025-07-18 11:55:36.253811', '2025-07-18 11:55:36.253798', 0, 16, 'deepseek-chat', 'assistant', NULL, '你好呀!😊 今天有什么可以帮你的吗?无论是问题解答、闲聊还是需要建议,我都在这里哦~ (开心转圈) \n\n(悄悄说:如果想切换语言或具体需求,随时告诉我!)', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (55, NULL, NULL, NULL, '2025-07-18 13:45:47.780914', '2025-07-18 13:45:47.780902', 0, 14, 'deepseek-chat', 'user', NULL, '哈哈哈哈', 1, NULL, NULL, 1, NULL); +INSERT INTO `ai_chat_message` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `conversation_id`, `model`, `type`, `reply_id`, `content`, `use_context`, `segment_ids`, `model_id`, `user_id`, `role_id`) VALUES (56, NULL, NULL, NULL, '2025-07-18 13:45:54.252865', '2025-07-18 13:45:54.252852', 0, 14, 'deepseek-chat', 'assistant', NULL, '哈哈,看来你心情不错嘛!😄 是不是有什么开心事想分享,还是单纯想笑一笑?我也可以陪你一起乐呵乐呵~(或者需要我讲个冷笑话?🤣) \n\n有什么想聊的,我随时在哦!✨', 1, NULL, NULL, 1, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for ai_chat_role +-- ---------------------------- +DROP TABLE IF EXISTS `ai_chat_role`; +CREATE TABLE `ai_chat_role` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `name` varchar(128) NOT NULL COMMENT '角色名称', + `avatar` varchar(256) NOT NULL COMMENT '头像', + `description` varchar(256) NOT NULL COMMENT '角色描述', + `status` smallint NOT NULL COMMENT '状态', + `sort` int NOT NULL COMMENT '角色排序', + `public_status` tinyint(1) NOT NULL COMMENT '是否公开', + `category` varchar(32) DEFAULT NULL COMMENT '角色类别', + `system_message` varchar(1024) DEFAULT NULL COMMENT '角色上下文', + `model_id` bigint NOT NULL COMMENT '向量模型编号', + `user_id` bigint DEFAULT NULL COMMENT '用户编号', + PRIMARY KEY (`id`), + KEY `ai_chat_role_model_id_f06e9484_fk_ai_model_id` (`model_id`), + KEY `ai_chat_role_user_id_7062a0d8_fk_system_users_id` (`user_id`), + CONSTRAINT `ai_chat_role_model_id_f06e9484_fk_ai_model_id` FOREIGN KEY (`model_id`) REFERENCES `ai_model` (`id`), + CONSTRAINT `ai_chat_role_user_id_7062a0d8_fk_system_users_id` FOREIGN KEY (`user_id`) REFERENCES `system_users` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_chat_role +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_chat_role_knowledge +-- ---------------------------- +DROP TABLE IF EXISTS `ai_chat_role_knowledge`; +CREATE TABLE `ai_chat_role_knowledge` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `chatrole_id` bigint NOT NULL, + `knowledge_id` bigint NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `ai_chat_role_knowledge_chatrole_id_knowledge_id_e11e775f_uniq` (`chatrole_id`,`knowledge_id`), + KEY `ai_chat_role_knowledge_knowledge_id_716d2c2f_fk_ai_knowledge_id` (`knowledge_id`), + CONSTRAINT `ai_chat_role_knowledge_chatrole_id_2aa1fdcd_fk_ai_chat_role_id` FOREIGN KEY (`chatrole_id`) REFERENCES `ai_chat_role` (`id`), + CONSTRAINT `ai_chat_role_knowledge_knowledge_id_716d2c2f_fk_ai_knowledge_id` FOREIGN KEY (`knowledge_id`) REFERENCES `ai_knowledge` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_chat_role_knowledge +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_chat_role_tools +-- ---------------------------- +DROP TABLE IF EXISTS `ai_chat_role_tools`; +CREATE TABLE `ai_chat_role_tools` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `chatrole_id` bigint NOT NULL, + `tool_id` bigint NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `ai_chat_role_tools_chatrole_id_tool_id_6dbe4b38_uniq` (`chatrole_id`,`tool_id`), + KEY `ai_chat_role_tools_tool_id_c76ea0a5_fk_ai_tool_id` (`tool_id`), + CONSTRAINT `ai_chat_role_tools_chatrole_id_fd890b7e_fk_ai_chat_role_id` FOREIGN KEY (`chatrole_id`) REFERENCES `ai_chat_role` (`id`), + CONSTRAINT `ai_chat_role_tools_tool_id_c76ea0a5_fk_ai_tool_id` FOREIGN KEY (`tool_id`) REFERENCES `ai_tool` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_chat_role_tools +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_knowledge +-- ---------------------------- +DROP TABLE IF EXISTS `ai_knowledge`; +CREATE TABLE `ai_knowledge` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `name` varchar(255) NOT NULL COMMENT '知识库名称', + `description` longtext COMMENT '知识库描述', + `embedding_model` varchar(32) NOT NULL COMMENT '向量模型标识', + `top_k` int NOT NULL COMMENT 'topK', + `similarity_threshold` double NOT NULL COMMENT '相似度阈值', + `status` smallint NOT NULL COMMENT '状态', + `embedding_model_id` bigint NOT NULL COMMENT '向量模型编号', + PRIMARY KEY (`id`), + KEY `ai_knowledge_embedding_model_id_60d5e2cd_fk_ai_model_id` (`embedding_model_id`), + CONSTRAINT `ai_knowledge_embedding_model_id_60d5e2cd_fk_ai_model_id` FOREIGN KEY (`embedding_model_id`) REFERENCES `ai_model` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_knowledge +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_knowledge_document +-- ---------------------------- +DROP TABLE IF EXISTS `ai_knowledge_document`; +CREATE TABLE `ai_knowledge_document` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `name` varchar(255) NOT NULL COMMENT '文档名称', + `url` varchar(1024) NOT NULL COMMENT '文件 URL', + `content` longtext NOT NULL COMMENT '内容', + `content_length` int NOT NULL COMMENT '字符数', + `tokens` int NOT NULL COMMENT 'token 数量', + `segment_max_tokens` int NOT NULL COMMENT '分片最大 Token 数', + `retrieval_count` int NOT NULL COMMENT '召回次数', + `status` smallint NOT NULL COMMENT '状态', + `knowledge_id` bigint NOT NULL COMMENT '知识库', + PRIMARY KEY (`id`), + KEY `ai_knowledge_document_knowledge_id_f60c97cc_fk_ai_knowledge_id` (`knowledge_id`), + CONSTRAINT `ai_knowledge_document_knowledge_id_f60c97cc_fk_ai_knowledge_id` FOREIGN KEY (`knowledge_id`) REFERENCES `ai_knowledge` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_knowledge_document +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_knowledge_segment +-- ---------------------------- +DROP TABLE IF EXISTS `ai_knowledge_segment`; +CREATE TABLE `ai_knowledge_segment` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `content` longtext NOT NULL COMMENT '分段内容', + `content_length` int NOT NULL COMMENT '字符数', + `tokens` int NOT NULL COMMENT 'token 数量', + `vector_id` varchar(100) DEFAULT NULL COMMENT '向量库的编号', + `retrieval_count` int NOT NULL COMMENT '召回次数', + `status` smallint NOT NULL COMMENT '状态', + `document_id` bigint NOT NULL COMMENT '文档', + `knowledge_id` bigint NOT NULL COMMENT '知识库', + PRIMARY KEY (`id`), + KEY `ai_knowledge_segment_document_id_cd995627_fk_ai_knowle` (`document_id`), + KEY `ai_knowledge_segment_knowledge_id_0580e7f9_fk_ai_knowledge_id` (`knowledge_id`), + CONSTRAINT `ai_knowledge_segment_document_id_cd995627_fk_ai_knowle` FOREIGN KEY (`document_id`) REFERENCES `ai_knowledge_document` (`id`), + CONSTRAINT `ai_knowledge_segment_knowledge_id_0580e7f9_fk_ai_knowledge_id` FOREIGN KEY (`knowledge_id`) REFERENCES `ai_knowledge` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_knowledge_segment +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_model +-- ---------------------------- +DROP TABLE IF EXISTS `ai_model`; +CREATE TABLE `ai_model` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `name` varchar(64) NOT NULL COMMENT '模型名字', + `sort` int NOT NULL COMMENT '排序', + `status` smallint NOT NULL COMMENT '状态', + `platform` varchar(32) NOT NULL COMMENT '模型平台', + `model` varchar(64) NOT NULL COMMENT '模型标识', + `temperature` double DEFAULT NULL COMMENT '温度参数', + `max_tokens` int DEFAULT NULL COMMENT '单条回复的最大 Token 数量', + `max_contexts` int DEFAULT NULL COMMENT '上下文的最大 Message 数量', + `key_id` bigint NOT NULL COMMENT 'API 秘钥编号', + `model_type` varchar(32) DEFAULT NULL COMMENT '模型类型', + PRIMARY KEY (`id`), + KEY `ai_model_key_id_d9a4647b_fk_ai_api_key_id` (`key_id`), + CONSTRAINT `ai_model_key_id_d9a4647b_fk_ai_api_key_id` FOREIGN KEY (`key_id`) REFERENCES `ai_api_key` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_model +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for ai_tool +-- ---------------------------- +DROP TABLE IF EXISTS `ai_tool`; +CREATE TABLE `ai_tool` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `remark` varchar(256) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) DEFAULT NULL COMMENT '创建人', + `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `is_deleted` tinyint(1) NOT NULL COMMENT '是否软删除', + `name` varchar(128) NOT NULL COMMENT '工具名称', + `description` varchar(256) DEFAULT NULL COMMENT '工具描述', + `status` smallint NOT NULL COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- ---------------------------- +-- Records of ai_tool +-- ---------------------------- +BEGIN; +INSERT INTO `ai_tool` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `description`, `status`) VALUES (1, NULL, 'admin', 'admin', '2025-07-11 03:00:01.307817', '2025-07-11 02:59:52.998735', 0, 'weather_query', '查询指定城市的天气信息', 1); +COMMIT; + -- ---------------------------- -- Table structure for auth_group -- ---------------------------- @@ -67,7 +438,7 @@ CREATE TABLE `auth_permission` ( PRIMARY KEY (`id`), UNIQUE KEY `auth_permission_content_type_id_codename_01ab375a_uniq` (`content_type_id`,`codename`), CONSTRAINT `auth_permission_content_type_id_2f476e4b_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of auth_permission @@ -145,6 +516,42 @@ INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALU INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (70, 'Can change 系统访问记录', 18, 'change_loginlog'); INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (71, 'Can delete 系统访问记录', 18, 'delete_loginlog'); INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (72, 'Can view 系统访问记录', 18, 'view_loginlog'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (73, 'Can add AI API 密钥', 19, 'add_aiapikey'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (74, 'Can change AI API 密钥', 19, 'change_aiapikey'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (75, 'Can delete AI API 密钥', 19, 'delete_aiapikey'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (76, 'Can view AI API 密钥', 19, 'view_aiapikey'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (77, 'Can add AI 模型', 20, 'add_aimodel'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (78, 'Can change AI 模型', 20, 'change_aimodel'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (79, 'Can delete AI 模型', 20, 'delete_aimodel'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (80, 'Can view AI 模型', 20, 'view_aimodel'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (81, 'Can add AI 工具', 21, 'add_tool'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (82, 'Can change AI 工具', 21, 'change_tool'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (83, 'Can delete AI 工具', 21, 'delete_tool'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (84, 'Can view AI 工具', 21, 'view_tool'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (85, 'Can add AI 聊天角色', 22, 'add_chatrole'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (86, 'Can change AI 聊天角色', 22, 'change_chatrole'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (87, 'Can delete AI 聊天角色', 22, 'delete_chatrole'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (88, 'Can view AI 聊天角色', 22, 'view_chatrole'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (89, 'Can add AI 聊天消息', 23, 'add_chatmessage'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (90, 'Can change AI 聊天消息', 23, 'change_chatmessage'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (91, 'Can delete AI 聊天消息', 23, 'delete_chatmessage'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (92, 'Can view AI 聊天消息', 23, 'view_chatmessage'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (93, 'Can add AI 聊天对话', 24, 'add_chatconversation'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (94, 'Can change AI 聊天对话', 24, 'change_chatconversation'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (95, 'Can delete AI 聊天对话', 24, 'delete_chatconversation'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (96, 'Can view AI 聊天对话', 24, 'view_chatconversation'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (97, 'Can add AI 知识库', 25, 'add_knowledge'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (98, 'Can change AI 知识库', 25, 'change_knowledge'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (99, 'Can delete AI 知识库', 25, 'delete_knowledge'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (100, 'Can view AI 知识库', 25, 'view_knowledge'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (101, 'Can add AI 知识库文档', 26, 'add_knowledgedocument'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (102, 'Can change AI 知识库文档', 26, 'change_knowledgedocument'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (103, 'Can delete AI 知识库文档', 26, 'delete_knowledgedocument'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (104, 'Can view AI 知识库文档', 26, 'view_knowledgedocument'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (105, 'Can add AI 知识库分段', 27, 'add_knowledgesegment'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (106, 'Can change AI 知识库分段', 27, 'change_knowledgesegment'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (107, 'Can delete AI 知识库分段', 27, 'delete_knowledgesegment'); +INSERT INTO `auth_permission` (`id`, `name`, `content_type_id`, `codename`) VALUES (108, 'Can view AI 知识库分段', 27, 'view_knowledgesegment'); COMMIT; -- ---------------------------- @@ -205,13 +612,22 @@ CREATE TABLE `django_content_type` ( `model` varchar(100) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `django_content_type_app_label_model_76bd3d3b_uniq` (`app_label`,`model`) -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of django_content_type -- ---------------------------- BEGIN; INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (1, 'admin', 'logentry'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (19, 'ai', 'aiapikey'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (20, 'ai', 'aimodel'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (24, 'ai', 'chatconversation'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (23, 'ai', 'chatmessage'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (22, 'ai', 'chatrole'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (25, 'ai', 'knowledge'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (26, 'ai', 'knowledgedocument'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (27, 'ai', 'knowledgesegment'); +INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (21, 'ai', 'tool'); INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (3, 'auth', 'group'); INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (2, 'auth', 'permission'); INSERT INTO `django_content_type` (`id`, `app_label`, `model`) VALUES (6, 'authtoken', 'token'); @@ -241,7 +657,7 @@ CREATE TABLE `django_migrations` ( `name` varchar(255) NOT NULL, `applied` datetime(6) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=103 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=117 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of django_migrations @@ -270,6 +686,11 @@ INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (99, 'au INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (100, 'authtoken', '0003_tokenproxy', '2025-07-03 08:43:50.819477'); INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (101, 'authtoken', '0004_alter_tokenproxy_options', '2025-07-03 08:43:50.820040'); INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (102, 'sessions', '0001_initial', '2025-07-03 08:43:50.820534'); +INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (110, 'ai', '0001_initial', '2025-07-11 07:44:40.725265'); +INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (111, 'system', '0002_alter_dept_creator_alter_dept_is_deleted_and_more', '2025-07-11 07:44:40.728073'); +INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (112, 'ai', '0002_alter_chatrole_knowledge_alter_chatrole_tools', '2025-07-16 03:18:08.594750'); +INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (113, 'ai', '0003_aimodel_model_type', '2025-07-16 03:18:08.665002'); +INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES (116, 'ai', '0004_alter_chatconversation_model_id_and_more', '2025-07-17 07:07:43.784691'); COMMIT; -- ---------------------------- @@ -347,13 +768,24 @@ CREATE TABLE `system_dict_data` ( PRIMARY KEY (`id`), KEY `system_dict_data_dict_type_id_6db93fa6_fk_system_dict_type_id` (`dict_type_id`), CONSTRAINT `system_dict_data_dict_type_id_6db93fa6_fk_system_dict_type_id` FOREIGN KEY (`dict_type_id`) REFERENCES `system_dict_type` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of system_dict_data -- ---------------------------- BEGIN; -INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (1, NULL, NULL, NULL, '2025-06-30 09:32:31.805645', '2025-06-30 09:32:31.805691', 0, 1, '都撒到', 'sadas', 1, 'primary', '', 1); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (2, NULL, NULL, NULL, '2025-07-15 02:08:22.996739', '2025-07-15 02:08:22.996764', 0, 1, '聊天', '1', 1, '', '', 2); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (3, NULL, NULL, NULL, '2025-07-15 02:08:53.538018', '2025-07-15 02:08:53.538037', 0, 2, '图像', '2', 1, '', '', 2); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (4, NULL, NULL, NULL, '2025-07-15 02:10:16.041575', '2025-07-15 02:10:16.041631', 0, 3, '音频', '3', 1, '', '', 2); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (5, NULL, NULL, NULL, '2025-07-15 02:10:42.061733', '2025-07-15 02:10:42.061767', 0, 4, '视频', '4', 1, '', '', 2); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (6, NULL, NULL, NULL, '2025-07-15 02:10:55.771116', '2025-07-15 02:10:55.771147', 0, 5, '向量', '5', 1, '', '', 2); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (7, NULL, NULL, NULL, '2025-07-15 02:11:06.731014', '2025-07-15 02:11:06.731053', 0, 6, '重排', '6', 1, '', '', 2); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (8, NULL, NULL, NULL, '2025-07-16 02:29:08.437533', '2025-07-16 02:29:08.437570', 0, 0, 'OpenAI 微软', 'AzureOpenAI', 1, '', '', 3); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (9, NULL, NULL, NULL, '2025-07-16 02:29:22.498781', '2025-07-16 02:29:22.498808', 0, 2, 'OpenAI', 'OpenAI', 1, '', '', 3); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (10, NULL, NULL, NULL, '2025-07-16 02:29:34.825738', '2025-07-16 02:29:34.825757', 0, 3, 'Ollama', 'Ollama', 1, '', '', 3); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (11, NULL, NULL, NULL, '2025-07-16 02:29:53.315661', '2025-07-16 02:29:53.315704', 0, 5, '通义千问', 'TongYi', 1, '', '', 3); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (12, NULL, NULL, NULL, '2025-07-16 02:30:08.979412', '2025-07-16 02:30:08.979441', 0, 7, 'DeepSeek', 'DeepSeek', 1, '', '', 3); +INSERT INTO `system_dict_data` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `sort`, `label`, `value`, `status`, `color_type`, `css_class`, `dict_type_id`) VALUES (13, NULL, NULL, NULL, '2025-07-16 02:30:44.780200', '2025-07-16 02:30:44.780246', 0, 9, '字节豆包', 'DouBao', 1, '', '', 3); COMMIT; -- ---------------------------- @@ -374,13 +806,14 @@ CREATE TABLE `system_dict_type` ( `deleted_time` datetime(6) DEFAULT NULL, PRIMARY KEY (`id`), KEY `system_dict_type_type_b3b2d8f5` (`value`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of system_dict_type -- ---------------------------- BEGIN; -INSERT INTO `system_dict_type` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `value`, `status`, `deleted_time`) VALUES (1, NULL, NULL, NULL, '2025-07-01 04:58:37.679182', '2025-06-29 13:32:51.050675', 0, 'jdjkhj', 'sad_ds', 1, NULL); +INSERT INTO `system_dict_type` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `value`, `status`, `deleted_time`) VALUES (2, NULL, NULL, NULL, '2025-07-15 02:04:51.990898', '2025-07-15 02:04:51.990974', 0, 'AI 模型类型', 'ai_model_type', 1, NULL); +INSERT INTO `system_dict_type` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `value`, `status`, `deleted_time`) VALUES (3, NULL, NULL, NULL, '2025-07-16 02:12:33.095597', '2025-07-16 02:12:33.095634', 0, 'AI 模型平台', 'ai_platform', 1, NULL); COMMIT; -- ---------------------------- @@ -400,7 +833,7 @@ CREATE TABLE `system_login_log` ( `user_ip` varchar(50) NOT NULL COMMENT '用户 IP', `user_agent` varchar(512) NOT NULL COMMENT '浏览器 UA', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of system_login_log @@ -424,10 +857,28 @@ INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_t INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (16, NULL, NULL, NULL, '2025-07-04 09:41:07.394602', '2025-07-04 09:41:07.394619', 0, 'chenze', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (17, NULL, NULL, NULL, '2025-07-04 14:46:34.812031', '2025-07-04 14:46:34.812041', 0, 'chenze', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (18, NULL, NULL, NULL, '2025-07-04 14:48:20.347506', '2025-07-04 14:48:20.347516', 0, 'admin', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); -INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (19, NULL, NULL, NULL, '2025-07-05 01:54:03.993248', '2025-07-05 01:54:03.993260', 0, 'chenze', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); -INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (20, NULL, NULL, NULL, '2025-07-05 02:02:58.915096', '2025-07-05 02:02:58.915110', 0, 'admin', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); -INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (21, NULL, NULL, NULL, '2025-07-05 02:03:48.892432', '2025-07-05 02:03:48.892446', 0, 'chenze', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); -INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (22, NULL, NULL, NULL, '2025-07-05 02:03:56.725873', '2025-07-05 02:03:56.725887', 0, 'admin', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (19, NULL, NULL, NULL, '2025-07-07 01:54:21.365157', '2025-07-07 01:54:21.365182', 0, 'admin', 1, '58.253.108.151', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (20, NULL, NULL, NULL, '2025-07-08 06:36:25.339783', '2025-07-08 06:36:25.339808', 0, 'admin', 1, '218.26.179.153', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (21, NULL, NULL, NULL, '2025-07-08 07:19:08.737686', '2025-07-08 07:19:08.737715', 0, 'admin', 1, '61.52.19.38', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (22, NULL, NULL, NULL, '2025-07-09 13:06:01.563924', '2025-07-09 13:06:01.563949', 0, 'admin', 1, '27.18.200.216', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (23, NULL, NULL, NULL, '2025-07-10 06:02:45.214431', '2025-07-10 06:02:45.214459', 0, 'admin', 1, '124.239.167.133', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (24, NULL, NULL, NULL, '2025-07-13 03:32:10.322595', '2025-07-13 03:32:10.322619', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (25, NULL, NULL, NULL, '2025-07-13 03:32:48.534087', '2025-07-13 03:32:48.534111', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (26, NULL, NULL, NULL, '2025-07-13 06:04:33.978627', '2025-07-13 06:04:33.978652', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (27, NULL, NULL, NULL, '2025-07-13 06:45:32.348375', '2025-07-13 06:45:32.348401', 0, 'admin', 1, '58.252.18.17', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (28, NULL, NULL, NULL, '2025-07-13 07:14:15.991829', '2025-07-13 07:14:15.991861', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (29, NULL, NULL, NULL, '2025-07-13 08:02:06.195133', '2025-07-13 08:02:06.195157', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (30, NULL, NULL, NULL, '2025-07-13 11:00:18.291251', '2025-07-13 11:00:18.291286', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (31, NULL, NULL, NULL, '2025-07-14 07:02:26.619850', '2025-07-14 07:02:26.619886', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (32, NULL, NULL, NULL, '2025-07-14 08:56:06.374062', '2025-07-14 08:56:06.374087', 0, 'admin', 1, '222.86.200.62', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (33, NULL, NULL, NULL, '2025-07-14 09:04:22.905904', '2025-07-14 09:04:22.905930', 0, 'chenze', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (34, NULL, NULL, NULL, '2025-07-14 09:43:28.019354', '2025-07-14 09:43:28.019380', 0, 'admin', 1, '61.141.94.108', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (35, NULL, NULL, NULL, '2025-07-14 14:59:40.385678', '2025-07-14 14:59:40.385702', 0, 'chenze', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (36, NULL, NULL, NULL, '2025-07-16 07:47:47.688065', '2025-07-16 07:47:47.688090', 0, 'admin', 1, '27.18.26.39', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (37, NULL, NULL, NULL, '2025-07-16 12:47:45.533242', '2025-07-16 12:47:45.533267', 0, 'admin', 1, '14.105.95.31', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (38, NULL, NULL, NULL, '2025-07-17 02:33:39.972092', '2025-07-17 02:33:39.972117', 0, 'admin', 1, '122.238.20.188', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (39, NULL, NULL, NULL, '2025-07-17 07:55:56.389269', '2025-07-17 07:55:56.389295', 0, 'admin', 1, '223.69.189.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'); +INSERT INTO `system_login_log` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `username`, `result`, `user_ip`, `user_agent`) VALUES (40, NULL, NULL, NULL, '2025-07-18 09:19:39.271509', '2025-07-18 09:19:39.271534', 0, 'admin', 1, '117.65.251.87', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0'); COMMIT; -- ---------------------------- @@ -456,14 +907,14 @@ CREATE TABLE `system_menu` ( KEY `system_menu_pid_id_94c9bb14_fk_system_menu_id` (`pid_id`), CONSTRAINT `system_menu_meta_id_3c0f37de_fk_system_menu_meta_id` FOREIGN KEY (`meta_id`) REFERENCES `system_menu_meta` (`id`), CONSTRAINT `system_menu_pid_id_94c9bb14_fk_system_menu_id` FOREIGN KEY (`pid_id`) REFERENCES `system_menu` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of system_menu -- ---------------------------- BEGIN; INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (1, NULL, NULL, 'admin', '2025-07-01 09:45:35.225930', '2025-06-30 09:35:21.372555', 0, '概览', 1, 'menu', '/workspace', '/dashboard/workspace/index', '', NULL, 1, 0); -INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (2, NULL, NULL, NULL, '2025-06-30 12:37:55.656213', '2025-06-30 12:37:55.656233', 0, 'System', 1, 'catalog', '/system', '', '', NULL, 2, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (2, NULL, NULL, 'admin', '2025-07-11 02:32:24.373705', '2025-06-30 12:37:55.656233', 0, 'System', 1, 'catalog', '/system', '', '', NULL, 2, 0); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (3, NULL, NULL, 'admin', '2025-07-02 03:49:50.551599', '2025-06-30 12:38:52.398094', 0, 'SystemMenu', 1, 'menu', '/system/menu', '/system/menu/list', '', 2, 3, 10); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (4, NULL, NULL, 'admin', '2025-07-01 08:11:00.187470', '2025-06-30 12:57:14.866495', 0, 'SystemMenuCreate', 1, 'button', '', '', 'system:menu:create', 3, 4, 2); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (5, NULL, NULL, 'admin', '2025-07-01 08:12:04.836586', '2025-06-30 12:57:40.728694', 0, 'SystemMenuEdit', 1, 'button', '', '', 'system:menu:edit', 3, 5, 0); @@ -472,8 +923,8 @@ INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (8, NULL, NULL, NULL, '2025-06-30 12:59:18.313868', '2025-06-30 12:59:18.313943', 0, 'SystemDeptCreate', 1, 'button', '', '', 'system:dept:create', 7, 8, 0); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (9, NULL, NULL, NULL, '2025-06-30 12:59:45.455554', '2025-06-30 12:59:45.455621', 0, 'SystemDeptEdit', 1, 'button', '', '', 'system:dept:edit', 7, 9, 0); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (10, NULL, NULL, NULL, '2025-06-30 13:00:27.836789', '2025-06-30 13:00:27.836845', 0, 'SystemDeptDelete', 1, 'button', '', '', 'system:dept:delete', 7, 10, 0); -INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (12, NULL, NULL, 'admin', '2025-07-03 03:12:19.599531', '2025-06-30 14:14:57.815188', 0, 'About', 1, 'menu', '/about', '_core/about/index', '', NULL, 12, 8); -INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (13, NULL, 'admin', 'admin', '2025-07-06 16:01:51.348938', '2025-06-30 14:17:50.344905', 0, 'Project', 1, 'catalog', '/django-vue3-admin', '', '', NULL, 13, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (12, NULL, NULL, 'admin', '2025-07-10 04:09:58.745714', '2025-06-30 14:14:57.815188', 0, 'About', 1, 'menu', '/about', '_core/about/index', '', NULL, 12, 80); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (13, NULL, 'admin', 'admin', '2025-07-10 04:10:06.189493', '2025-06-30 14:17:50.344905', 0, 'Project', 1, 'catalog', '/django-vue3-admin', '', '', NULL, 13, 70); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (14, NULL, 'admin', 'admin', '2025-07-06 16:01:45.924656', '2025-06-30 14:23:46.754306', 0, 'VbenDocument', 1, 'embedded', '/django-vue3-admin/document', 'IFrameView', '', 13, 14, 0); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (15, NULL, 'admin', 'admin', '2025-07-01 08:10:19.878461', '2025-07-01 08:10:19.878496', 0, '查询', 1, 'button', '', '', 'system:menu:query', 3, 15, 1); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (16, NULL, 'admin', 'admin', '2025-07-01 08:17:08.227740', '2025-07-01 08:17:08.227775', 0, '查询', 1, 'button', '', '', 'system:dept:query', 7, 16, 1); @@ -510,6 +961,50 @@ INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (52, NULL, NULL, NULL, '2025-07-02 08:02:58.023348', '2025-07-02 08:02:58.023354', 0, 'loginlogEdit', 1, 'button', '', '', 'system:login_log:edit', 49, 52, 2); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (53, NULL, NULL, NULL, '2025-07-02 08:02:58.024971', '2025-07-02 08:02:58.024976', 0, 'loginlogDelete', 1, 'button', '', '', 'system:login_log:delete', 49, 53, 3); INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (54, NULL, 'admin', 'admin', '2025-07-06 16:02:20.555780', '2025-07-06 16:00:22.966211', 0, 'VbenGithub', 1, 'embedded', '/django-vue3-admin/github', '', '', 13, 54, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (55, NULL, 'admin', 'admin', '2025-07-11 02:32:33.717179', '2025-07-10 03:30:10.283442', 0, 'AI', 1, 'catalog', '/ai', '', '', NULL, 55, 7); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (56, NULL, NULL, 'admin', '2025-07-18 02:33:10.853903', '2025-07-10 03:39:18.821059', 0, 'Aiapikey', 1, 'menu', '/ai/api_key', '/ai/api_key/list', '', 55, 56, 100); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (57, NULL, NULL, NULL, '2025-07-10 03:39:18.825637', '2025-07-10 03:39:18.825643', 0, 'AiapikeyCreate', 1, 'button', '', '', 'ai:ai_api_key:create', 56, 57, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (58, NULL, NULL, NULL, '2025-07-10 03:39:18.832126', '2025-07-10 03:39:18.832131', 0, 'AiapikeyEdit', 1, 'button', '', '', 'ai:ai_api_key:edit', 56, 58, 1); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (59, NULL, NULL, NULL, '2025-07-10 03:39:18.834117', '2025-07-10 03:39:18.834122', 0, 'AiapikeyDelete', 1, 'button', '', '', 'ai:ai_api_key:delete', 56, 59, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (60, NULL, NULL, NULL, '2025-07-10 03:39:18.836444', '2025-07-10 03:39:18.836450', 0, 'AiapikeyQuery', 1, 'button', '', '', 'ai:ai_api_key:query', 56, 60, 3); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (61, NULL, NULL, NULL, '2025-07-10 03:39:18.838099', '2025-07-10 03:39:18.838104', 0, 'AiapikeyQuery', 1, 'button', '', '', 'ai:ai_api_key:import', 56, 61, 4); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (62, NULL, NULL, NULL, '2025-07-10 03:39:18.839823', '2025-07-10 03:39:18.839829', 0, 'AiapikeyQuery', 1, 'button', '', '', 'ai:ai_api_key:export', 56, 62, 5); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (63, NULL, NULL, NULL, '2025-07-11 01:57:27.851283', '2025-07-11 01:57:27.851292', 0, 'Aimodel', 1, 'menu', '/ai/ai_model', '/ai/ai_model/list', '', 55, 63, 100); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (64, NULL, NULL, NULL, '2025-07-11 01:57:27.855799', '2025-07-11 01:57:27.855804', 0, 'AimodelCreate', 1, 'button', '', '', 'ai:ai_model:create', 63, 64, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (65, NULL, NULL, NULL, '2025-07-11 01:57:27.859356', '2025-07-11 01:57:27.859361', 0, 'AimodelEdit', 1, 'button', '', '', 'ai:ai_model:edit', 63, 65, 1); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (66, NULL, NULL, NULL, '2025-07-11 01:57:27.862433', '2025-07-11 01:57:27.862442', 0, 'AimodelDelete', 1, 'button', '', '', 'ai:ai_model:delete', 63, 66, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (67, NULL, NULL, NULL, '2025-07-11 01:57:27.864381', '2025-07-11 01:57:27.864390', 0, 'AimodelQuery', 1, 'button', '', '', 'ai:ai_model:query', 63, 67, 3); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (68, NULL, NULL, NULL, '2025-07-11 01:57:27.866251', '2025-07-11 01:57:27.866257', 0, 'AimodelQuery', 1, 'button', '', '', 'ai:ai_model:import', 63, 68, 4); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (69, NULL, NULL, NULL, '2025-07-11 01:57:27.867682', '2025-07-11 01:57:27.867687', 0, 'AimodelQuery', 1, 'button', '', '', 'ai:ai_model:export', 63, 69, 5); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (70, NULL, NULL, NULL, '2025-07-11 02:53:20.403085', '2025-07-11 02:53:20.403093', 0, 'Tool', 1, 'menu', '/ai/tool', '/ai/tool/list', '', 55, 70, 100); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (71, NULL, NULL, NULL, '2025-07-11 02:53:20.407331', '2025-07-11 02:53:20.407336', 0, 'ToolCreate', 1, 'button', '', '', 'ai:tool:create', 70, 71, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (72, NULL, NULL, NULL, '2025-07-11 02:53:20.411591', '2025-07-11 02:53:20.411599', 0, 'ToolEdit', 1, 'button', '', '', 'ai:tool:edit', 70, 72, 1); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (73, NULL, NULL, NULL, '2025-07-11 02:53:20.413324', '2025-07-11 02:53:20.413331', 0, 'ToolDelete', 1, 'button', '', '', 'ai:tool:delete', 70, 73, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (74, NULL, NULL, NULL, '2025-07-11 02:53:20.415196', '2025-07-11 02:53:20.415204', 0, 'ToolQuery', 1, 'button', '', '', 'ai:tool:query', 70, 74, 3); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (75, NULL, NULL, NULL, '2025-07-11 02:53:20.416916', '2025-07-11 02:53:20.416921', 0, 'ToolQuery', 1, 'button', '', '', 'ai:tool:import', 70, 75, 4); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (76, NULL, NULL, NULL, '2025-07-11 02:53:20.418666', '2025-07-11 02:53:20.418672', 0, 'ToolQuery', 1, 'button', '', '', 'ai:tool:export', 70, 76, 5); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (78, NULL, NULL, NULL, '2025-07-15 01:47:21.284539', '2025-07-15 01:47:21.284552', 0, 'Knowledge', 1, 'menu', '/ai/knowledge', '/ai/knowledge/list', '', 55, 78, 100); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (79, NULL, NULL, NULL, '2025-07-15 01:47:21.287927', '2025-07-15 01:47:21.287938', 0, 'KnowledgeCreate', 1, 'button', '', '', 'ai:knowledge:create', 78, 79, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (80, NULL, NULL, NULL, '2025-07-15 01:47:21.290503', '2025-07-15 01:47:21.290511', 0, 'KnowledgeEdit', 1, 'button', '', '', 'ai:knowledge:edit', 78, 80, 1); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (81, NULL, NULL, NULL, '2025-07-15 01:47:21.292828', '2025-07-15 01:47:21.292834', 0, 'KnowledgeDelete', 1, 'button', '', '', 'ai:knowledge:delete', 78, 81, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (82, NULL, NULL, NULL, '2025-07-15 01:47:21.294333', '2025-07-15 01:47:21.294340', 0, 'KnowledgeQuery', 1, 'button', '', '', 'ai:knowledge:query', 78, 82, 3); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (83, NULL, NULL, NULL, '2025-07-15 01:47:21.296074', '2025-07-15 01:47:21.296080', 0, 'KnowledgeQuery', 1, 'button', '', '', 'ai:knowledge:import', 78, 83, 4); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (84, NULL, NULL, NULL, '2025-07-15 01:47:21.298823', '2025-07-15 01:47:21.298831', 0, 'KnowledgeQuery', 1, 'button', '', '', 'ai:knowledge:export', 78, 84, 5); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (85, NULL, 'admin', 'admin', '2025-07-17 02:59:11.386979', '2025-07-17 02:57:36.901338', 0, 'AI对话', 1, 'menu', '/ai/chat', '/ai/chat/index', '', 55, 85, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (86, NULL, NULL, NULL, '2025-07-18 02:51:28.107268', '2025-07-18 02:51:28.107276', 0, 'Chatconversation', 1, 'menu', '/ai/chat_conversation', '/ai/chat_conversation/list', '', 55, 86, 100); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (87, NULL, NULL, NULL, '2025-07-18 02:51:28.113765', '2025-07-18 02:51:28.113769', 0, 'ChatconversationCreate', 1, 'button', '', '', 'ai:chat_conversation:create', 86, 87, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (88, NULL, NULL, NULL, '2025-07-18 02:51:28.116167', '2025-07-18 02:51:28.116174', 0, 'ChatconversationEdit', 1, 'button', '', '', 'ai:chat_conversation:edit', 86, 88, 1); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (89, NULL, NULL, NULL, '2025-07-18 02:51:28.118153', '2025-07-18 02:51:28.118158', 0, 'ChatconversationDelete', 1, 'button', '', '', 'ai:chat_conversation:delete', 86, 89, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (90, NULL, NULL, NULL, '2025-07-18 02:51:28.120099', '2025-07-18 02:51:28.120108', 0, 'ChatconversationQuery', 1, 'button', '', '', 'ai:chat_conversation:query', 86, 90, 3); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (91, NULL, NULL, NULL, '2025-07-18 02:51:28.123877', '2025-07-18 02:51:28.123886', 0, 'ChatconversationQuery', 1, 'button', '', '', 'ai:chat_conversation:import', 86, 91, 4); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (92, NULL, NULL, NULL, '2025-07-18 02:51:28.125700', '2025-07-18 02:51:28.125707', 0, 'ChatconversationQuery', 1, 'button', '', '', 'ai:chat_conversation:export', 86, 92, 5); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (93, NULL, NULL, 'admin', '2025-07-18 03:41:59.311347', '2025-07-18 03:39:15.967234', 0, 'Chatmessage', 1, 'menu', '/ai/chat_message', '/ai/chat_message/list', '', 55, 93, 100); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (94, NULL, NULL, NULL, '2025-07-18 03:39:15.975162', '2025-07-18 03:39:15.975191', 0, 'ChatmessageCreate', 1, 'button', '', '', 'ai:chat_message:create', 93, 94, 0); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (95, NULL, NULL, NULL, '2025-07-18 03:39:15.981304', '2025-07-18 03:39:15.981333', 0, 'ChatmessageEdit', 1, 'button', '', '', 'ai:chat_message:edit', 93, 95, 1); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (96, NULL, NULL, NULL, '2025-07-18 03:39:15.987279', '2025-07-18 03:39:15.987305', 0, 'ChatmessageDelete', 1, 'button', '', '', 'ai:chat_message:delete', 93, 96, 2); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (97, NULL, NULL, NULL, '2025-07-18 03:39:15.993846', '2025-07-18 03:39:15.993875', 0, 'ChatmessageQuery', 1, 'button', '', '', 'ai:chat_message:query', 93, 97, 3); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (98, NULL, NULL, NULL, '2025-07-18 03:39:16.000070', '2025-07-18 03:39:16.000096', 0, 'ChatmessageQuery', 1, 'button', '', '', 'ai:chat_message:import', 93, 98, 4); +INSERT INTO `system_menu` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `type`, `path`, `component`, `auth_code`, `pid_id`, `meta_id`, `sort`) VALUES (99, NULL, NULL, NULL, '2025-07-18 03:39:16.005517', '2025-07-18 03:39:16.005544', 0, 'ChatmessageQuery', 1, 'button', '', '', 'ai:chat_message:export', 93, 99, 5); COMMIT; -- ---------------------------- @@ -536,14 +1031,14 @@ CREATE TABLE `system_menu_meta` ( `hide_children_in_menu` tinyint(1) NOT NULL COMMENT '隐藏子菜单', `hide_in_menu` tinyint(1) NOT NULL COMMENT '隐藏菜单', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of system_menu_meta -- ---------------------------- BEGIN; INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (1, NULL, NULL, NULL, '2025-07-01 09:45:35.200879', '2025-06-30 09:35:21.346111', 0, 'page.dashboard.title', 'carbon:workspace', 0, 0, '', '', '', '', '', 0, 0); -INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (2, NULL, NULL, NULL, '2025-06-30 12:37:55.632644', '2025-06-30 12:37:55.632666', 0, 'system.title', 'carbon:settings', 0, 0, 'new', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (2, NULL, NULL, NULL, '2025-07-11 02:32:24.369609', '2025-06-30 12:37:55.632666', 0, 'system.title', 'carbon:settings', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (3, NULL, NULL, NULL, '2025-07-02 03:49:50.547348', '2025-06-30 12:38:52.374691', 0, 'system.menu.title', 'carbon:menu', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (4, NULL, NULL, NULL, '2025-07-01 08:11:00.165353', '2025-06-30 12:57:14.842379', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (5, NULL, NULL, NULL, '2025-07-01 08:12:04.811256', '2025-06-30 12:57:40.703715', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); @@ -553,8 +1048,8 @@ INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_t INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (9, NULL, NULL, NULL, '2025-06-30 12:59:45.429985', '2025-06-30 12:59:45.430037', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (10, NULL, NULL, NULL, '2025-06-30 13:00:27.814988', '2025-06-30 13:00:27.815021', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (11, NULL, NULL, NULL, '2025-06-30 13:00:28.085386', '2025-06-30 13:00:28.085434', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); -INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (12, NULL, NULL, NULL, '2025-07-03 03:12:19.592343', '2025-06-30 14:14:57.789248', 0, 'demos.vben.about', 'lucide:copyright', 0, 0, '', '', '', '', '', 0, 0); -INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (13, NULL, NULL, NULL, '2025-07-06 16:01:51.343973', '2025-06-30 14:17:50.320137', 0, 'demos.vben.title', 'carbon:data-center', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (12, NULL, NULL, NULL, '2025-07-10 04:09:58.741264', '2025-06-30 14:14:57.789248', 0, 'demos.vben.about', 'lucide:copyright', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (13, NULL, NULL, NULL, '2025-07-10 04:10:06.185808', '2025-06-30 14:17:50.320137', 0, 'demos.vben.title', 'carbon:data-center', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (14, NULL, NULL, NULL, '2025-07-06 16:01:45.915788', '2025-06-30 14:23:46.727573', 0, 'demos.vben.document', 'carbon:book', 0, 0, '', '', '', 'https://docs.ywwuzi.cn/', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (15, NULL, NULL, NULL, '2025-07-01 08:10:19.854182', '2025-07-01 08:10:19.854206', 0, '查询', '', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (16, NULL, NULL, NULL, '2025-07-01 08:17:08.205093', '2025-07-01 08:17:08.205154', 0, '查询', '', 0, 0, '', '', '', '', '', 0, 0); @@ -591,6 +1086,51 @@ INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_t INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (52, NULL, NULL, NULL, '2025-07-02 08:02:58.021897', '2025-07-02 08:02:58.021901', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (53, NULL, NULL, NULL, '2025-07-02 08:02:58.024225', '2025-07-02 08:02:58.024229', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (54, NULL, NULL, NULL, '2025-07-06 16:02:20.548920', '2025-07-06 16:00:22.954337', 0, 'Github', 'mdi:github', 0, 0, '', '', '', '', 'https://github.com/XIE7654/django-vue3-admin', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (55, NULL, NULL, NULL, '2025-07-11 02:32:33.713614', '2025-07-10 03:30:10.278933', 0, 'ai.title', 'carbon:paint-brush', 0, 0, 'new', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (56, NULL, NULL, NULL, '2025-07-18 02:33:10.844515', '2025-07-10 03:39:18.817197', 0, 'ai.api_key.title', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (57, NULL, NULL, NULL, '2025-07-10 03:39:18.823606', '2025-07-10 03:39:18.823616', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (58, NULL, NULL, NULL, '2025-07-10 03:39:18.828374', '2025-07-10 03:39:18.828379', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (59, NULL, NULL, NULL, '2025-07-10 03:39:18.833216', '2025-07-10 03:39:18.833221', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (60, NULL, NULL, NULL, '2025-07-10 03:39:18.835521', '2025-07-10 03:39:18.835532', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (61, NULL, NULL, NULL, '2025-07-10 03:39:18.837225', '2025-07-10 03:39:18.837230', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (62, NULL, NULL, NULL, '2025-07-10 03:39:18.839006', '2025-07-10 03:39:18.839011', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (63, NULL, NULL, NULL, '2025-07-11 01:57:27.845804', '2025-07-11 01:57:27.845814', 0, 'ai.ai_model.title', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (64, NULL, NULL, NULL, '2025-07-11 01:57:27.854026', '2025-07-11 01:57:27.854030', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (65, NULL, NULL, NULL, '2025-07-11 01:57:27.857594', '2025-07-11 01:57:27.857598', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (66, NULL, NULL, NULL, '2025-07-11 01:57:27.861280', '2025-07-11 01:57:27.861291', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (67, NULL, NULL, NULL, '2025-07-11 01:57:27.863309', '2025-07-11 01:57:27.863315', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (68, NULL, NULL, NULL, '2025-07-11 01:57:27.865232', '2025-07-11 01:57:27.865238', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (69, NULL, NULL, NULL, '2025-07-11 01:57:27.866966', '2025-07-11 01:57:27.866972', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (70, NULL, NULL, NULL, '2025-07-11 02:53:20.398301', '2025-07-11 02:53:20.398315', 0, 'ai.tool.title', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (71, NULL, NULL, NULL, '2025-07-11 02:53:20.405509', '2025-07-11 02:53:20.405516', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (72, NULL, NULL, NULL, '2025-07-11 02:53:20.410175', '2025-07-11 02:53:20.410180', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (73, NULL, NULL, NULL, '2025-07-11 02:53:20.412480', '2025-07-11 02:53:20.412486', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (74, NULL, NULL, NULL, '2025-07-11 02:53:20.414089', '2025-07-11 02:53:20.414094', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (75, NULL, NULL, NULL, '2025-07-11 02:53:20.416161', '2025-07-11 02:53:20.416166', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (76, NULL, NULL, NULL, '2025-07-11 02:53:20.417594', '2025-07-11 02:53:20.417598', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (77, NULL, NULL, NULL, '2025-07-11 08:46:59.490742', '2025-07-11 08:46:59.490773', 0, 'ai chat', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (78, NULL, NULL, NULL, '2025-07-15 01:47:21.274488', '2025-07-15 01:47:21.274505', 0, 'ai.knowledge.title', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (79, NULL, NULL, NULL, '2025-07-15 01:47:21.286782', '2025-07-15 01:47:21.286794', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (80, NULL, NULL, NULL, '2025-07-15 01:47:21.289159', '2025-07-15 01:47:21.289167', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (81, NULL, NULL, NULL, '2025-07-15 01:47:21.291876', '2025-07-15 01:47:21.291885', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (82, NULL, NULL, NULL, '2025-07-15 01:47:21.293546', '2025-07-15 01:47:21.293551', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (83, NULL, NULL, NULL, '2025-07-15 01:47:21.295133', '2025-07-15 01:47:21.295142', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (84, NULL, NULL, NULL, '2025-07-15 01:47:21.297417', '2025-07-15 01:47:21.297424', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (85, NULL, NULL, NULL, '2025-07-17 02:59:11.382648', '2025-07-17 02:57:36.895879', 0, 'ai.chat.title', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (86, NULL, NULL, NULL, '2025-07-18 02:51:28.102098', '2025-07-18 02:51:28.102110', 0, 'ai.chat_conversation.title', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (87, NULL, NULL, NULL, '2025-07-18 02:51:28.111131', '2025-07-18 02:51:28.111137', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (88, NULL, NULL, NULL, '2025-07-18 02:51:28.115047', '2025-07-18 02:51:28.115055', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (89, NULL, NULL, NULL, '2025-07-18 02:51:28.117163', '2025-07-18 02:51:28.117168', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (90, NULL, NULL, NULL, '2025-07-18 02:51:28.119252', '2025-07-18 02:51:28.119262', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (91, NULL, NULL, NULL, '2025-07-18 02:51:28.123068', '2025-07-18 02:51:28.123074', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (92, NULL, NULL, NULL, '2025-07-18 02:51:28.124912', '2025-07-18 02:51:28.124917', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (93, NULL, NULL, NULL, '2025-07-18 03:41:59.303918', '2025-07-18 03:39:15.959130', 0, 'ai.chat_message.title', '', 0, 0, '', '', '', '', '', 0, 1); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (94, NULL, NULL, NULL, '2025-07-18 03:39:15.970862', '2025-07-18 03:39:15.970899', 0, 'common.create', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (95, NULL, NULL, NULL, '2025-07-18 03:39:15.977961', '2025-07-18 03:39:15.977991', 0, 'common.edit', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (96, NULL, NULL, NULL, '2025-07-18 03:39:15.984598', '2025-07-18 03:39:15.984630', 0, 'common.delete', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (97, NULL, NULL, NULL, '2025-07-18 03:39:15.990627', '2025-07-18 03:39:15.990654', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (98, NULL, NULL, NULL, '2025-07-18 03:39:15.996695', '2025-07-18 03:39:15.996725', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); +INSERT INTO `system_menu_meta` (`id`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `title`, `icon`, `sort`, `affix_tab`, `badge`, `badge_type`, `badge_variants`, `iframe_src`, `link`, `hide_children_in_menu`, `hide_in_menu`) VALUES (99, NULL, NULL, NULL, '2025-07-18 03:39:16.002524', '2025-07-18 03:39:16.002552', 0, 'common.query', '', 0, 0, '', '', '', '', '', 0, 0); COMMIT; -- ---------------------------- @@ -646,7 +1186,7 @@ CREATE TABLE `system_role` ( -- ---------------------------- BEGIN; INSERT INTO `system_role` (`id`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `sort`, `remark`, `code`) VALUES (2, NULL, 'admin', '2025-07-03 09:05:32.917555', '2025-06-30 13:43:33.222244', 0, '普通角色', 1, 0, '', 'common'); -INSERT INTO `system_role` (`id`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `sort`, `remark`, `code`) VALUES (3, 'admin', 'admin', '2025-07-03 02:58:07.056753', '2025-06-30 14:01:56.403744', 0, '超级管理员', 1, 0, '', 'super_admin'); +INSERT INTO `system_role` (`id`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `name`, `status`, `sort`, `remark`, `code`) VALUES (3, 'admin', 'admin', '2025-07-18 13:20:50.920641', '2025-06-30 14:01:56.403744', 0, '超级管理员', 1, 0, '', 'superAdmin'); COMMIT; -- ---------------------------- @@ -668,7 +1208,7 @@ CREATE TABLE `system_role_permission` ( KEY `system_role_permission_role_id_ca5e9412_fk_system_role_id` (`role_id`), CONSTRAINT `system_role_permission_menu_id_bf701eaf_fk_system_menu_id` FOREIGN KEY (`menu_id`) REFERENCES `system_menu` (`id`), CONSTRAINT `system_role_permission_role_id_ca5e9412_fk_system_role_id` FOREIGN KEY (`role_id`) REFERENCES `system_role` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=133 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- ---------------------------- -- Records of system_role_permission @@ -740,6 +1280,51 @@ INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `up INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (85, NULL, NULL, NULL, '2025-07-03 09:05:32.928000', 0, '2025-07-03 09:05:32.928012', 36, 2); INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (86, NULL, NULL, NULL, '2025-07-03 09:05:32.928024', 0, '2025-07-03 09:05:32.928036', 37, 2); INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (87, NULL, NULL, NULL, '2025-07-03 09:05:32.928047', 0, '2025-07-03 09:05:32.928060', 38, 2); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (88, NULL, NULL, NULL, '2025-07-18 13:20:50.934154', 0, '2025-07-18 13:20:50.934209', 54, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (89, NULL, NULL, NULL, '2025-07-18 13:20:50.934224', 0, '2025-07-18 13:20:50.934238', 55, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (90, NULL, NULL, NULL, '2025-07-18 13:20:50.934251', 0, '2025-07-18 13:20:50.934265', 56, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (91, NULL, NULL, NULL, '2025-07-18 13:20:50.934277', 0, '2025-07-18 13:20:50.934291', 57, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (92, NULL, NULL, NULL, '2025-07-18 13:20:50.934304', 0, '2025-07-18 13:20:50.934318', 58, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (93, NULL, NULL, NULL, '2025-07-18 13:20:50.934331', 0, '2025-07-18 13:20:50.934345', 59, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (94, NULL, NULL, NULL, '2025-07-18 13:20:50.934357', 0, '2025-07-18 13:20:50.934371', 60, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (95, NULL, NULL, NULL, '2025-07-18 13:20:50.934383', 0, '2025-07-18 13:20:50.934398', 61, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (96, NULL, NULL, NULL, '2025-07-18 13:20:50.934410', 0, '2025-07-18 13:20:50.934423', 62, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (97, NULL, NULL, NULL, '2025-07-18 13:20:50.934437', 0, '2025-07-18 13:20:50.934451', 63, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (98, NULL, NULL, NULL, '2025-07-18 13:20:50.934463', 0, '2025-07-18 13:20:50.934477', 64, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (99, NULL, NULL, NULL, '2025-07-18 13:20:50.934489', 0, '2025-07-18 13:20:50.934504', 65, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (100, NULL, NULL, NULL, '2025-07-18 13:20:50.934517', 0, '2025-07-18 13:20:50.934530', 66, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (101, NULL, NULL, NULL, '2025-07-18 13:20:50.934543', 0, '2025-07-18 13:20:50.934557', 67, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (102, NULL, NULL, NULL, '2025-07-18 13:20:50.934588', 0, '2025-07-18 13:20:50.934605', 68, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (103, NULL, NULL, NULL, '2025-07-18 13:20:50.934618', 0, '2025-07-18 13:20:50.934632', 69, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (104, NULL, NULL, NULL, '2025-07-18 13:20:50.934646', 0, '2025-07-18 13:20:50.934660', 70, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (105, NULL, NULL, NULL, '2025-07-18 13:20:50.934674', 0, '2025-07-18 13:20:50.934689', 71, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (106, NULL, NULL, NULL, '2025-07-18 13:20:50.934701', 0, '2025-07-18 13:20:50.934716', 72, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (107, NULL, NULL, NULL, '2025-07-18 13:20:50.934730', 0, '2025-07-18 13:20:50.934745', 73, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (108, NULL, NULL, NULL, '2025-07-18 13:20:50.934757', 0, '2025-07-18 13:20:50.934772', 74, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (109, NULL, NULL, NULL, '2025-07-18 13:20:50.934784', 0, '2025-07-18 13:20:50.934798', 75, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (110, NULL, NULL, NULL, '2025-07-18 13:20:50.934811', 0, '2025-07-18 13:20:50.934824', 76, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (111, NULL, NULL, NULL, '2025-07-18 13:20:50.934836', 0, '2025-07-18 13:20:50.934849', 78, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (112, NULL, NULL, NULL, '2025-07-18 13:20:50.934862', 0, '2025-07-18 13:20:50.934875', 79, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (113, NULL, NULL, NULL, '2025-07-18 13:20:50.934888', 0, '2025-07-18 13:20:50.934901', 80, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (114, NULL, NULL, NULL, '2025-07-18 13:20:50.934913', 0, '2025-07-18 13:20:50.934927', 81, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (115, NULL, NULL, NULL, '2025-07-18 13:20:50.934940', 0, '2025-07-18 13:20:50.934953', 82, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (116, NULL, NULL, NULL, '2025-07-18 13:20:50.934965', 0, '2025-07-18 13:20:50.934978', 83, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (117, NULL, NULL, NULL, '2025-07-18 13:20:50.934991', 0, '2025-07-18 13:20:50.935004', 84, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (118, NULL, NULL, NULL, '2025-07-18 13:20:50.935019', 0, '2025-07-18 13:20:50.935033', 85, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (119, NULL, NULL, NULL, '2025-07-18 13:20:50.935045', 0, '2025-07-18 13:20:50.935058', 86, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (120, NULL, NULL, NULL, '2025-07-18 13:20:50.935071', 0, '2025-07-18 13:20:50.935084', 87, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (121, NULL, NULL, NULL, '2025-07-18 13:20:50.935097', 0, '2025-07-18 13:20:50.935112', 88, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (122, NULL, NULL, NULL, '2025-07-18 13:20:50.935124', 0, '2025-07-18 13:20:50.935137', 89, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (123, NULL, NULL, NULL, '2025-07-18 13:20:50.935150', 0, '2025-07-18 13:20:50.935162', 90, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (124, NULL, NULL, NULL, '2025-07-18 13:20:50.935175', 0, '2025-07-18 13:20:50.935189', 91, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (125, NULL, NULL, NULL, '2025-07-18 13:20:50.935201', 0, '2025-07-18 13:20:50.935214', 92, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (126, NULL, NULL, NULL, '2025-07-18 13:20:50.935226', 0, '2025-07-18 13:20:50.935239', 93, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (127, NULL, NULL, NULL, '2025-07-18 13:20:50.935252', 0, '2025-07-18 13:20:50.935265', 94, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (128, NULL, NULL, NULL, '2025-07-18 13:20:50.935277', 0, '2025-07-18 13:20:50.935290', 95, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (129, NULL, NULL, NULL, '2025-07-18 13:20:50.935303', 0, '2025-07-18 13:20:50.935316', 96, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (130, NULL, NULL, NULL, '2025-07-18 13:20:50.935328', 0, '2025-07-18 13:20:50.935341', 97, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (131, NULL, NULL, NULL, '2025-07-18 13:20:50.935353', 0, '2025-07-18 13:20:50.935366', 98, 3); +INSERT INTO `system_role_permission` (`id`, `remark`, `creator`, `modifier`, `update_time`, `is_deleted`, `create_time`, `menu_id`, `role_id`) VALUES (132, NULL, NULL, NULL, '2025-07-18 13:20:50.935378', 0, '2025-07-18 13:20:50.935391', 99, 3); COMMIT; -- ---------------------------- @@ -748,16 +1333,16 @@ COMMIT; DROP TABLE IF EXISTS `system_users`; CREATE TABLE `system_users` ( `id` bigint NOT NULL AUTO_INCREMENT, - `password` varchar(128) NOT NULL, - `last_login` datetime(6) DEFAULT NULL, - `is_superuser` tinyint(1) NOT NULL, - `username` varchar(150) NOT NULL, - `first_name` varchar(150) NOT NULL, - `last_name` varchar(150) NOT NULL, - `email` varchar(254) NOT NULL, - `is_staff` tinyint(1) NOT NULL, - `is_active` tinyint(1) NOT NULL, - `date_joined` datetime(6) NOT NULL, + `password` varchar(128) NOT NULL COMMENT 'password', + `last_login` datetime(6) DEFAULT NULL COMMENT 'last login', + `is_superuser` tinyint(1) NOT NULL COMMENT 'superuser status', + `username` varchar(150) NOT NULL COMMENT 'username', + `first_name` varchar(150) NOT NULL COMMENT 'first name', + `last_name` varchar(150) NOT NULL COMMENT 'last name', + `email` varchar(254) NOT NULL COMMENT 'email address', + `is_staff` tinyint(1) NOT NULL COMMENT 'staff status', + `is_active` tinyint(1) NOT NULL COMMENT 'active', + `date_joined` datetime(6) NOT NULL COMMENT 'date joined', `remark` varchar(256) DEFAULT NULL COMMENT '备注', `creator` varchar(64) DEFAULT NULL COMMENT '创建人', `modifier` varchar(64) DEFAULT NULL COMMENT '修改人', @@ -782,7 +1367,7 @@ CREATE TABLE `system_users` ( -- Records of system_users -- ---------------------------- BEGIN; -INSERT INTO `system_users` (`id`, `password`, `last_login`, `is_superuser`, `username`, `first_name`, `last_name`, `email`, `is_staff`, `is_active`, `date_joined`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `mobile`, `nickname`, `gender`, `language`, `city`, `province`, `country`, `avatar_url`, `status`, `login_ip`) VALUES (1, 'pbkdf2_sha256$1000000$b8gwLD046kZQIz1VMiUnmN$8/HRWXvV2MawPTME6SBo2bmA+pXYMN375l91lFdIIZE=', '2025-07-05 02:03:56.705767', 1, 'admin', '', '', '765462425@qq.com', 1, 1, '2025-06-29 13:09:47.780431', NULL, NULL, 'admin', '2025-07-04 14:48:13.446261', '2025-06-29 13:09:47.892332', 0, '18888888888', NULL, 0, NULL, NULL, NULL, NULL, NULL, 1, '127.0.0.1'); +INSERT INTO `system_users` (`id`, `password`, `last_login`, `is_superuser`, `username`, `first_name`, `last_name`, `email`, `is_staff`, `is_active`, `date_joined`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `mobile`, `nickname`, `gender`, `language`, `city`, `province`, `country`, `avatar_url`, `status`, `login_ip`) VALUES (1, 'pbkdf2_sha256$1000000$b8gwLD046kZQIz1VMiUnmN$8/HRWXvV2MawPTME6SBo2bmA+pXYMN375l91lFdIIZE=', '2025-07-18 05:44:57.070873', 1, 'admin', '', '', '765462425@qq.com', 1, 1, '2025-06-29 13:09:47.780431', NULL, NULL, 'admin', '2025-07-04 14:48:13.446261', '2025-06-29 13:09:47.892332', 0, '18888888888', NULL, 0, NULL, NULL, NULL, NULL, NULL, 1, '127.0.0.1'); INSERT INTO `system_users` (`id`, `password`, `last_login`, `is_superuser`, `username`, `first_name`, `last_name`, `email`, `is_staff`, `is_active`, `date_joined`, `remark`, `creator`, `modifier`, `update_time`, `create_time`, `is_deleted`, `mobile`, `nickname`, `gender`, `language`, `city`, `province`, `country`, `avatar_url`, `status`, `login_ip`) VALUES (2, 'pbkdf2_sha256$1000000$MWNyUoBTr4K24ySzXNbQup$eB+xVm6dCqwSVBQV5hIrURgMe2NGFgaeXpsociexCcI=', '2025-07-05 02:03:48.872113', 0, 'chenze', '', '', '765462425@qq.com', 0, 1, '2025-07-01 06:25:50.946515', NULL, 'admin', 'admin', '2025-07-05 02:04:38.567613', '2025-07-01 06:25:50.947136', 0, '18677777776', NULL, 0, NULL, NULL, NULL, NULL, NULL, 1, '127.0.0.1'); COMMIT; diff --git a/web/Dockerfile b/web/Dockerfile index e22d97c..b275b3f 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -11,10 +11,8 @@ RUN corepack enable && corepack prepare pnpm@10.10.0 --activate COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ -# RUN pnpm install --frozen-lockfile - # 拷贝项目 COPY . . diff --git a/web/apps/web-antd/.env.development b/web/apps/web-antd/.env.development index 71cc73d..2378d6d 100644 --- a/web/apps/web-antd/.env.development +++ b/web/apps/web-antd/.env.development @@ -4,7 +4,8 @@ VITE_PORT=5678 VITE_BASE=/ # 接口地址 -VITE_GLOB_API_URL=/api +VITE_GLOB_API_URL=/api/admin + VITE_BACKEND_URL=http://localhost:8000 # 是否开启 Nitro Mock服务,true 为开启,false 为关闭 diff --git a/web/apps/web-antd/src/api/ai/chat.ts b/web/apps/web-antd/src/api/ai/chat.ts new file mode 100644 index 0000000..c48364a --- /dev/null +++ b/web/apps/web-antd/src/api/ai/chat.ts @@ -0,0 +1,59 @@ +import { fetchWithAuth } from '#/utils/fetch-with-auth'; + +export async function getConversations() { + const res = await fetchWithAuth('/api/ai/v1/conversations'); + return await res.json(); +} + +export async function createConversation() { + const response = await fetchWithAuth('/api/ai/v1/conversations', { + method: 'POST', + }); + if (!response.ok) { + throw new Error('创建对话失败'); + } + return await response.json(); +} + +export async function getMessages(conversationId: number) { + const res = await fetchWithAuth( + `/api/ai/v1/messages?conversation_id=${conversationId}`, + ); + return await res.json(); +} + +// 你原有的fetchAIStream方法保留 +export interface FetchAIStreamParams { + content: string; + conversation_id?: null | number; +} + +export async function fetchAIStream({ + content, + conversation_id, +}: FetchAIStreamParams) { + const res = await fetchWithAuth('/api/ai/v1/stream', { + method: 'POST', + body: JSON.stringify({ content, conversation_id }), + }); + if (!res.body) throw new Error('No stream body'); + const reader = res.body.getReader(); + const decoder = new TextDecoder('utf8'); + let buffer = ''; + return { + async *[Symbol.asyncIterator]() { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += decoder.decode(value, { stream: true }); + const parts = buffer.split('\n\n'); + buffer = parts.pop() || ''; + for (const part of parts) { + if (part.startsWith('data: ')) { + yield part.replace('data: ', ''); + } + } + } + }, + }; +} diff --git a/web/apps/web-antd/src/api/request.ts b/web/apps/web-antd/src/api/request.ts index 288dddd..2bb489e 100644 --- a/web/apps/web-antd/src/api/request.ts +++ b/web/apps/web-antd/src/api/request.ts @@ -16,6 +16,7 @@ import { useAccessStore } from '@vben/stores'; import { message } from 'ant-design-vue'; import { useAuthStore } from '#/store'; +import { formatToken } from '#/utils/auth'; import { refreshTokenApi } from './core'; @@ -56,10 +57,6 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) { return newToken; } - function formatToken(token: null | string) { - return token ? `Bearer ${token}` : null; - } - // 请求头处理 client.addRequestInterceptor({ fulfilled: async (config) => { diff --git a/web/apps/web-antd/src/locales/langs/en-US/ai.json b/web/apps/web-antd/src/locales/langs/en-US/ai.json index 2505bb1..b5a7415 100644 --- a/web/apps/web-antd/src/locales/langs/en-US/ai.json +++ b/web/apps/web-antd/src/locales/langs/en-US/ai.json @@ -1,6 +1,6 @@ { "title": "AI Management", - "ai_api_key": { + "api_key": { "title": "KEY Management", "name": "KEY Management" }, @@ -15,5 +15,17 @@ "knowledge": { "title": "KNOWLEDGE Management", "name": "KNOWLEDGE Management" + }, + "chat": { + "title": "AI CHAT", + "name": "AI CHAT" + }, + "chat_conversation": { + "title": "CHAT Management", + "name": "CHAT Management" + }, + "chat_message": { + "title": "MESSAGE Management", + "name": "MESSAGE Management" } } diff --git a/web/apps/web-antd/src/locales/langs/zh-CN/ai.json b/web/apps/web-antd/src/locales/langs/zh-CN/ai.json index 47116d7..47ad5b1 100644 --- a/web/apps/web-antd/src/locales/langs/zh-CN/ai.json +++ b/web/apps/web-antd/src/locales/langs/zh-CN/ai.json @@ -1,6 +1,6 @@ { "title": "AI大模型", - "ai_api_key": { + "api_key": { "title": "API 密钥", "name": "API 密钥" }, @@ -15,5 +15,17 @@ "knowledge": { "title": "知识库管理", "name": "知识库管理" + }, + "chat": { + "title": "AI对话", + "name": "AI对话" + }, + "chat_conversation": { + "title": "对话列表", + "name": "对话列表" + }, + "chat_message": { + "title": "消息列表", + "name": "消息列表" } } diff --git a/web/apps/web-antd/src/models/ai/ai_api_key.ts b/web/apps/web-antd/src/models/ai/ai_api_key.ts index e65a14a..8432aea 100644 --- a/web/apps/web-antd/src/models/ai/ai_api_key.ts +++ b/web/apps/web-antd/src/models/ai/ai_api_key.ts @@ -20,6 +20,6 @@ export namespace AiAIApiKeyApi { export class AiAIApiKeyModel extends BaseModel { constructor() { - super('/ai/ai_api_key/'); + super('/ai/api_key/'); } } diff --git a/web/apps/web-antd/src/models/ai/chat_conversation.ts b/web/apps/web-antd/src/models/ai/chat_conversation.ts new file mode 100644 index 0000000..36deb8e --- /dev/null +++ b/web/apps/web-antd/src/models/ai/chat_conversation.ts @@ -0,0 +1,30 @@ +import { BaseModel } from '#/models/base'; + +export namespace AiChatConversationApi { + export interface AiChatConversation { + id: number; + remark: string; + creator: string; + modifier: string; + update_time: string; + create_time: string; + is_deleted: boolean; + title: string; + pinned: boolean; + pinned_time: string; + user: number; + role: number; + model_id: number; + model: string; + system_message: string; + temperature: any; + max_tokens: number; + max_contexts: number; + } +} + +export class AiChatConversationModel extends BaseModel { + constructor() { + super('/ai/chat_conversation/'); + } +} diff --git a/web/apps/web-antd/src/models/ai/chat_message.ts b/web/apps/web-antd/src/models/ai/chat_message.ts new file mode 100644 index 0000000..6f5eb1b --- /dev/null +++ b/web/apps/web-antd/src/models/ai/chat_message.ts @@ -0,0 +1,29 @@ +import { BaseModel } from '#/models/base'; + +export namespace AiChatMessageApi { + export interface AiChatMessage { + id: number; + remark: string; + creator: string; + modifier: string; + update_time: string; + create_time: string; + is_deleted: boolean; + conversation_id: number; + user: number; + role: number; + model: string; + model_id: number; + type: string; + reply_id: number; + content: string; + use_context: boolean; + segment_ids: string; + } +} + +export class AiChatMessageModel extends BaseModel { + constructor() { + super('/ai/chat_message/'); + } +} diff --git a/web/apps/web-antd/src/utils/auth.ts b/web/apps/web-antd/src/utils/auth.ts new file mode 100644 index 0000000..3342d48 --- /dev/null +++ b/web/apps/web-antd/src/utils/auth.ts @@ -0,0 +1,3 @@ +export function formatToken(token: null | string) { + return token ? `Bearer ${token}` : null; +} diff --git a/web/apps/web-antd/src/utils/fetch-with-auth.ts b/web/apps/web-antd/src/utils/fetch-with-auth.ts new file mode 100644 index 0000000..1a1543b --- /dev/null +++ b/web/apps/web-antd/src/utils/fetch-with-auth.ts @@ -0,0 +1,11 @@ +import { formatToken } from '#/utils/auth'; +import { useAccessStore } from '@vben/stores'; + +export function fetchWithAuth(input: RequestInfo, init: RequestInit = {}) { + const accessStore = useAccessStore(); + const token = accessStore.accessToken; + const headers = new Headers(init.headers || {}); + headers.append('Content-Type', 'application/json'); + headers.append('Authorization', formatToken(token) as string); + return fetch(input, { ...init, headers }); +} diff --git a/web/apps/web-antd/src/views/ai/ai_api_key/data.ts b/web/apps/web-antd/src/views/ai/api_key/data.ts similarity index 99% rename from web/apps/web-antd/src/views/ai/ai_api_key/data.ts rename to web/apps/web-antd/src/views/ai/api_key/data.ts index dcfb537..8ee82a6 100644 --- a/web/apps/web-antd/src/views/ai/ai_api_key/data.ts +++ b/web/apps/web-antd/src/views/ai/api_key/data.ts @@ -151,7 +151,7 @@ export function useColumns( cellRender: { attrs: { nameField: 'name', - nameTitle: $t('ai.ai_api_key.name'), + nameTitle: $t('ai.api_key.name'), onClick: onActionClick, }, name: 'CellOperation', diff --git a/web/apps/web-antd/src/views/ai/ai_api_key/list.vue b/web/apps/web-antd/src/views/ai/api_key/list.vue similarity index 97% rename from web/apps/web-antd/src/views/ai/ai_api_key/list.vue rename to web/apps/web-antd/src/views/ai/api_key/list.vue index 2f1bc73..d9932a7 100644 --- a/web/apps/web-antd/src/views/ai/ai_api_key/list.vue +++ b/web/apps/web-antd/src/views/ai/api_key/list.vue @@ -133,7 +133,7 @@ function refreshGrid() { v-permission="'ai:ai_api_key:create'" > - {{ $t('ui.actionTitle.create', [$t('ai.ai_api_key.name')]) }} + {{ $t('ui.actionTitle.create') }} diff --git a/web/apps/web-antd/src/views/ai/ai_api_key/modules/form.vue b/web/apps/web-antd/src/views/ai/api_key/modules/form.vue similarity index 93% rename from web/apps/web-antd/src/views/ai/ai_api_key/modules/form.vue rename to web/apps/web-antd/src/views/ai/api_key/modules/form.vue index a32ec36..359ead3 100644 --- a/web/apps/web-antd/src/views/ai/ai_api_key/modules/form.vue +++ b/web/apps/web-antd/src/views/ai/api_key/modules/form.vue @@ -20,8 +20,8 @@ const formModel = new AiAIApiKeyModel(); const formData = ref(); const getTitle = computed(() => { return formData.value?.id - ? $t('ui.actionTitle.edit', [$t('ai.ai_api_key.name')]) - : $t('ui.actionTitle.create', [$t('ai.ai_api_key.name')]); + ? $t('ui.actionTitle.edit', [$t('ai.api_key.name')]) + : $t('ui.actionTitle.create', [$t('ai.api_key.name')]); }); const [Form, formApi] = useVbenForm({ diff --git a/web/apps/web-antd/src/views/ai/chat/index.vue b/web/apps/web-antd/src/views/ai/chat/index.vue new file mode 100644 index 0000000..a65de00 --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat/index.vue @@ -0,0 +1,495 @@ + + + + + diff --git a/web/apps/web-antd/src/views/ai/chat_conversation/data.ts b/web/apps/web-antd/src/views/ai/chat_conversation/data.ts new file mode 100644 index 0000000..f29d697 --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat_conversation/data.ts @@ -0,0 +1,189 @@ +import type { VxeTableGridOptions } from '@vben/plugins/vxe-table'; + +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn } from '#/adapter/vxe-table'; +import type { AiChatConversationApi } from '#/models/ai/chat_conversation'; + +import { z } from '#/adapter/form'; +import { $t } from '#/locales'; +// import { format_datetime } from '#/utils/date'; +// import { op } from '#/utils/permission'; + +/** + * 获取编辑表单的字段配置 + */ +export function useSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'title', + label: '对话标题', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['对话标题'])) + .max(100, $t('ui.formRules.maxLength', ['对话标题', 100])), + }, + { + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + options: [ + { label: '开启', value: 1 }, + { label: '关闭', value: 0 }, + ], + optionType: 'button', + }, + defaultValue: 1, + fieldName: 'pinned', + label: '是否置顶', + }, + { + component: 'Input', + fieldName: 'pinned_time', + label: '置顶时间', + }, + { + component: 'Input', + fieldName: 'user', + label: '用户', + }, + { + component: 'Input', + fieldName: 'role', + label: '聊天角色', + }, + { + component: 'Input', + fieldName: 'model_id', + label: '向量模型编号', + }, + { + component: 'Input', + fieldName: 'model', + label: '模型标识', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['模型标识'])) + .max(100, $t('ui.formRules.maxLength', ['模型标识', 100])), + }, + { + component: 'Input', + fieldName: 'system_message', + label: '角色设定', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['角色设定'])) + .max(100, $t('ui.formRules.maxLength', ['角色设定', 100])), + }, + { + component: 'Input', + fieldName: 'temperature', + label: '温度参数', + }, + { + component: 'InputNumber', + fieldName: 'max_tokens', + label: '单条回复的最大 Token 数量', + }, + { + component: 'InputNumber', + fieldName: 'max_contexts', + label: '上下文的最大 Message 数量', + }, + { + component: 'Input', + fieldName: 'remark', + label: '备注', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['备注'])) + .max(100, $t('ui.formRules.maxLength', ['备注', 100])), + }, + ]; +} + +/** + * 获取编辑表单的字段配置 + */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'title', + label: '对话标题', + }, + { + component: 'Input', + fieldName: 'user', + label: '用户', + }, + { + component: 'Input', + fieldName: 'model', + label: '模型标识', + }, + ]; +} + +/** + * 获取表格列配置 + * @description 使用函数的形式返回列数据而不是直接export一个Array常量,是为了响应语言切换时重新翻译表头 + * @param onActionClick 表格操作按钮点击事件 + */ +export function useColumns( + onActionClick?: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: 'ID', + }, + { + field: 'title', + title: '标题', + }, + { + field: 'username', + title: '用户', + }, + { + field: 'role', + title: '聊天角色', + }, + { + field: 'model_id', + title: '向量模型编号', + }, + { + field: 'model', + title: '模型标识', + }, + { + field: 'system_message', + title: '角色设定', + }, + { + align: 'center', + cellRender: { + attrs: { + nameField: 'name', + nameTitle: $t('ai.chat_conversation.name'), + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'view', + text: '查看消息', + }, + // op('ai:chat_conversation:edit', 'edit'), + // op('ai:chat_conversation:delete', 'delete'), + ], + }, + field: 'action', + fixed: 'right', + title: '操作', + width: 120, + }, + ]; +} diff --git a/web/apps/web-antd/src/views/ai/chat_conversation/list.vue b/web/apps/web-antd/src/views/ai/chat_conversation/list.vue new file mode 100644 index 0000000..3f87a63 --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat_conversation/list.vue @@ -0,0 +1,134 @@ + + + diff --git a/web/apps/web-antd/src/views/ai/chat_conversation/modules/form.vue b/web/apps/web-antd/src/views/ai/chat_conversation/modules/form.vue new file mode 100644 index 0000000..9ee5dec --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat_conversation/modules/form.vue @@ -0,0 +1,79 @@ + + + + diff --git a/web/apps/web-antd/src/views/ai/chat_message/data.ts b/web/apps/web-antd/src/views/ai/chat_message/data.ts new file mode 100644 index 0000000..dc5b699 --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat_message/data.ts @@ -0,0 +1,178 @@ +import type { VxeTableGridOptions } from '@vben/plugins/vxe-table'; + +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn } from '#/adapter/vxe-table'; +import type { AiChatMessageApi } from '#/models/ai/chat_message'; + +import { z } from '#/adapter/form'; +import { $t } from '#/locales'; +import { format_datetime } from '#/utils/date'; + +/** + * 获取编辑表单的字段配置 + */ +export function useSchema(): VbenFormSchema[] { + return [ + { + component: 'InputNumber', + fieldName: 'conversation_id', + label: '对话编号', + }, + { + component: 'Input', + fieldName: 'user', + label: '用户', + }, + { + component: 'Input', + fieldName: 'role', + label: '聊天角色', + }, + { + component: 'Input', + fieldName: 'model', + label: '模型标识', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['模型标识'])) + .max(100, $t('ui.formRules.maxLength', ['模型标识', 100])), + }, + { + component: 'Input', + fieldName: 'model_id', + label: '向量模型编号', + }, + { + component: 'Input', + fieldName: 'type', + label: '消息类型', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['消息类型'])) + .max(100, $t('ui.formRules.maxLength', ['消息类型', 100])), + }, + { + component: 'InputNumber', + fieldName: 'reply_id', + label: '回复编号', + }, + { + component: 'Input', + fieldName: 'content', + label: '消息内容', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['消息内容'])) + .max(100, $t('ui.formRules.maxLength', ['消息内容', 100])), + }, + { + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + options: [ + { label: '开启', value: 1 }, + { label: '关闭', value: 0 }, + ], + optionType: 'button', + }, + defaultValue: 1, + fieldName: 'use_context', + label: '是否携带上下文', + }, + { + component: 'Input', + fieldName: 'segment_ids', + label: '段落编号数组', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['段落编号数组'])) + .max(100, $t('ui.formRules.maxLength', ['段落编号数组', 100])), + }, + { + component: 'Input', + fieldName: 'remark', + label: '备注', + rules: z + .string() + .min(1, $t('ui.formRules.required', ['备注'])) + .max(100, $t('ui.formRules.maxLength', ['备注', 100])), + }, + ]; +} + +/** + * 获取编辑表单的字段配置 + */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'user', + label: '用户', + }, + ]; +} + +/** + * 获取表格列配置 + * @description 使用函数的形式返回列数据而不是直接export一个Array常量,是为了响应语言切换时重新翻译表头 + * @param onActionClick 表格操作按钮点击事件 + */ +export function useColumns( + onActionClick?: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: 'ID', + }, + { + field: 'conversation_id', + title: '对话编号', + }, + { + field: 'username', + title: '用户', + }, + { + field: 'role', + title: '聊天角色', + }, + { + field: 'model', + title: '模型标识', + width: 150, + }, + { + field: 'model_id', + title: '向量模型编号', + }, + { + field: 'type', + title: '消息类型', + }, + { + field: 'reply_id', + title: '回复编号', + }, + { + field: 'content', + title: '消息内容', + width: 200, + }, + { + field: 'use_context', + title: '是否携带上下文', + }, + { + field: 'segment_ids', + title: '段落编号数组', + }, + { + field: 'create_time', + title: '创建时间', + width: 150, + formatter: ({ cellValue }) => format_datetime(cellValue), + }, + ]; +} diff --git a/web/apps/web-antd/src/views/ai/chat_message/list.vue b/web/apps/web-antd/src/views/ai/chat_message/list.vue new file mode 100644 index 0000000..c66e016 --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat_message/list.vue @@ -0,0 +1,127 @@ + + + diff --git a/web/apps/web-antd/src/views/ai/chat_message/modules/form.vue b/web/apps/web-antd/src/views/ai/chat_message/modules/form.vue new file mode 100644 index 0000000..79b47b1 --- /dev/null +++ b/web/apps/web-antd/src/views/ai/chat_message/modules/form.vue @@ -0,0 +1,79 @@ + + + + diff --git a/web/apps/web-antd/vite.config.mts b/web/apps/web-antd/vite.config.mts index b62f598..c774877 100644 --- a/web/apps/web-antd/vite.config.mts +++ b/web/apps/web-antd/vite.config.mts @@ -9,6 +9,7 @@ export default defineConfig(async ({ mode }) => { const env = loadEnv(mode, process.cwd()); // 这样获取,提供默认值 const backendUrl = env.VITE_BACKEND_URL || 'http://localhost:8000'; + const aiUrl = env.VITE_AI_URL || 'http://localhost:8010'; // 判断是否为构建模式 const isBuild = mode === 'production'; @@ -22,14 +23,13 @@ export default defineConfig(async ({ mode }) => { host: '0.0.0.0', // 保证 docker 内外都能访问 port: 5678, proxy: { - '/api': { - target: backendUrl, + '/api/ai': { + target: aiUrl, changeOrigin: true, }, - '/ws': { + '/api/admin': { target: backendUrl, changeOrigin: true, - ws: true, // 启用WebSocket代理 }, }, }, diff --git a/web/nginx.conf b/web/nginx.conf index aa2d88b..ff2d818 100644 --- a/web/nginx.conf +++ b/web/nginx.conf @@ -37,7 +37,7 @@ http { } # 代理后端 API - location /api/ { + location /api/admin/ { proxy_pass http://backend:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -57,7 +57,26 @@ http { access_log /var/log/nginx/assets_access.log; error_log /var/log/nginx/assets_error.log; } - + location /api/ai/ { + proxy_pass http://ai_service:8010; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + client_max_body_size 100m; + client_body_buffer_size 128k; + proxy_connect_timeout 180; + proxy_send_timeout 180; + proxy_read_timeout 180; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + #proxy_cache_bypass $http_upgrade; + #proxy_cache_key $uri$request_body; #增加此行 + #proxy_cache_methods GET POST; #增加此行 + #add_header Access-Control-Allow-Headers X-API-Token; + access_log /var/log/nginx/assets_access.log; + error_log /var/log/nginx/assets_error.log; + } # 前端 history 路由 location / { try_files $uri $uri/ /index.html;