/**
Source Server Version: 8.0.31
Source Database: backendsys
Date: 2023/05/23 17:09:22
*/

DROP TABLE IF EXISTS `ai_chat`;
CREATE TABLE `ai_chat` (
    PRIMARY KEY (`id`),
    `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
    `history_code` VARCHAR(36) NOT NULL COMMENT '对话历史记录ID',
    `model` VARCHAR(255) COMMENT '模型 (HUNYUAN-混元, DEEPSEEK_API, OLLAMA)',
    `model_version` VARCHAR(255) COMMENT '模型版本 (deepseek-chat, deepseek-reasoner, deepseek-r1:1.5b)',
    `role` VARCHAR(255) COMMENT '对话角色 ("user", "assistant")',
    `content_type` VARCHAR(255) COMMENT '对话内容类型 (LOADING-加载中, SEARCH-搜索, REPLY-回复, REPLY-回复, REPLY_ABORT-回复中止, THINK-思考, THINK_ABORT-思考中止)',
    `content` TEXT NOT NULL COMMENT '对话内容',
    `duration` BIGINT COMMENT '耗时',
    `user_id` BIGINT COMMENT '用户ID',
    `robot_code` VARCHAR(255) COMMENT '机器人CODE',
    `del_flag` TINYINT(1) DEFAULT '-1' COMMENT '删除标志 (-1未删除, 1删除)',
    `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    INDEX `idx_history_code` (`history_code`),
    INDEX `idx_user_id` (`user_id`),
    INDEX `idx_robot_code` (`robot_code`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='AI助手表';

