AI对话页面增加显示AI思考中

This commit is contained in:
GeekMaster
2025-05-05 16:38:50 +08:00
parent 2c6abbe7e4
commit 73f5a44e0a
21 changed files with 713 additions and 1010 deletions

View File

@@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- 主机: localhost
-- 生成日期: 2025-04-17 02:48:52
-- 生成日期: 2025-05-05 08:00:54
-- 服务器版本: 8.0.33
-- PHP 版本: 8.3.6
@@ -36,7 +36,7 @@ CREATE TABLE `chatgpt_admin_users` (
`password` char(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码',
`salt` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码盐',
`status` tinyint(1) NOT NULL COMMENT '当前状态',
`last_login_at` int NOT NULL COMMENT '最后登录时间',
`last_login_at` bigint NOT NULL COMMENT '最后登录时间',
`last_login_ip` char(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '最后登录 IP',
`created_at` datetime NOT NULL COMMENT '创建时间',
`updated_at` datetime NOT NULL COMMENT '更新时间'
@@ -47,7 +47,7 @@ CREATE TABLE `chatgpt_admin_users` (
--
INSERT INTO `chatgpt_admin_users` (`id`, `username`, `password`, `salt`, `status`, `last_login_at`, `last_login_ip`, `created_at`, `updated_at`) VALUES
(1, 'admin', '6d17e80c87d209efb84ca4b2e0824f549d09fac8b2e1cc698de5bb5e1d75dfd0', 'mmrql75o', 1, 1744788584, '::1', '2024-03-11 16:30:20', '2025-04-16 15:29:45');
(1, 'admin', '6d17e80c87d209efb84ca4b2e0824f549d09fac8b2e1cc698de5bb5e1d75dfd0', 'mmrql75o', 1, 1746431827, '::1', '2024-03-11 16:30:20', '2025-05-05 15:57:08');
-- --------------------------------------------------------
@@ -61,7 +61,7 @@ CREATE TABLE `chatgpt_api_keys` (
`name` varchar(30) DEFAULT NULL COMMENT '名称',
`value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'API KEY value',
`type` varchar(10) NOT NULL DEFAULT 'chat' COMMENT '用途chat=>聊天img=>图片)',
`last_used_at` int NOT NULL COMMENT '最后使用时间',
`last_used_at` bigint NOT NULL COMMENT '最后使用时间',
`api_url` varchar(255) DEFAULT NULL COMMENT 'API 地址',
`enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用',
`proxy_url` varchar(100) DEFAULT NULL COMMENT '代理地址',
@@ -85,6 +85,17 @@ CREATE TABLE `chatgpt_app_types` (
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='应用分类表';
--
-- 转存表中的数据 `chatgpt_app_types`
--
INSERT INTO `chatgpt_app_types` (`id`, `name`, `icon`, `sort_num`, `enabled`, `created_at`) VALUES
(3, '通用工具', 'http://172.22.11.200:5678/static/upload/2024/9/1726307371871693.png', 1, 1, '2024-09-13 11:13:15'),
(4, '角色扮演', 'http://172.22.11.200:5678/static/upload/2024/9/1726307263906218.png', 1, 1, '2024-09-14 09:28:17'),
(5, '学习', 'http://172.22.11.200:5678/static/upload/2024/9/1726307456321179.jpg', 2, 1, '2024-09-14 09:30:18'),
(6, '编程', 'http://172.22.11.200:5678/static/upload/2024/9/1726307462748787.jpg', 3, 1, '2024-09-14 09:34:06'),
(7, '测试分类', '', 4, 1, '2024-09-14 17:54:17');
-- --------------------------------------------------------
--
@@ -94,15 +105,15 @@ CREATE TABLE `chatgpt_app_types` (
DROP TABLE IF EXISTS `chatgpt_chat_history`;
CREATE TABLE `chatgpt_chat_history` (
`id` bigint NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`chat_id` char(40) NOT NULL COMMENT '会话 ID',
`type` varchar(10) NOT NULL COMMENT '类型prompt|reply',
`icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色图标',
`role_id` int NOT NULL COMMENT '角色 ID',
`role_id` bigint NOT NULL COMMENT '角色 ID',
`model` varchar(30) DEFAULT NULL COMMENT '模型名称',
`content` text NOT NULL COMMENT '聊天内容',
`tokens` smallint NOT NULL COMMENT '耗费 token 数量',
`total_tokens` int NOT NULL COMMENT '消耗总Token长度',
`total_tokens` bigint NOT NULL COMMENT '消耗总Token长度',
`use_context` tinyint(1) NOT NULL COMMENT '是否允许作为上下文语料',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
@@ -119,10 +130,10 @@ DROP TABLE IF EXISTS `chatgpt_chat_items`;
CREATE TABLE `chatgpt_chat_items` (
`id` int NOT NULL,
`chat_id` char(40) NOT NULL COMMENT '会话 ID',
`user_id` int NOT NULL COMMENT '用户 ID',
`role_id` int NOT NULL COMMENT '角色 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`role_id` bigint NOT NULL COMMENT '角色 ID',
`title` varchar(100) NOT NULL COMMENT '会话标题',
`model_id` int NOT NULL DEFAULT '0' COMMENT '模型 ID',
`model_id` bigint NOT NULL DEFAULT '0' COMMENT '模型 ID',
`model` varchar(30) DEFAULT NULL COMMENT '模型名称',
`created_at` datetime NOT NULL COMMENT '创建时间',
`updated_at` datetime NOT NULL COMMENT '更新时间',
@@ -138,6 +149,8 @@ CREATE TABLE `chatgpt_chat_items` (
DROP TABLE IF EXISTS `chatgpt_chat_models`;
CREATE TABLE `chatgpt_chat_models` (
`id` int NOT NULL,
`description` varchar(1024) NOT NULL DEFAULT '' COMMENT '模型类型描述',
`category` varchar(1024) NOT NULL DEFAULT '' COMMENT '模型类别',
`type` varchar(10) NOT NULL DEFAULT 'chat' COMMENT '模型类型chat,img',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模型名称',
`value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模型值',
@@ -145,10 +158,10 @@ CREATE TABLE `chatgpt_chat_models` (
`enabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用模型',
`power` smallint NOT NULL COMMENT '消耗算力点数',
`temperature` float(3,1) NOT NULL DEFAULT '1.0' COMMENT '模型创意度',
`max_tokens` int NOT NULL DEFAULT '1024' COMMENT '最大响应长度',
`max_context` int NOT NULL DEFAULT '4096' COMMENT '最大上下文长度',
`max_tokens` bigint NOT NULL DEFAULT '1024' COMMENT '最大响应长度',
`max_context` bigint NOT NULL DEFAULT '4096' COMMENT '最大上下文长度',
`open` tinyint(1) NOT NULL COMMENT '是否开放模型',
`key_id` int NOT NULL COMMENT '绑定API KEY ID',
`key_id` bigint NOT NULL COMMENT '绑定API KEY ID',
`options` text NOT NULL COMMENT '模型自定义选项',
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL
@@ -158,27 +171,28 @@ CREATE TABLE `chatgpt_chat_models` (
-- 转存表中的数据 `chatgpt_chat_models`
--
INSERT INTO `chatgpt_chat_models` (`id`, `type`, `name`, `value`, `sort_num`, `enabled`, `power`, `temperature`, `max_tokens`, `max_context`, `open`, `key_id`, `options`, `created_at`, `updated_at`) VALUES
(1, 'chat', 'gpt-4o-mini', 'gpt-4o-mini', 1, 1, 1, 1.0, 1024, 16384, 1, 1, '', '2023-08-23 12:06:36', '2025-02-23 11:57:03'),
(15, 'chat', 'GPT-4O(联网版本)', 'gpt-4o-all', 4, 1, 30, 1.0, 4096, 32768, 1, 57, '', '2024-01-15 11:32:52', '2025-01-06 14:01:08'),
(36, 'chat', 'GPT-4O', 'gpt-4o', 3, 1, 15, 1.0, 4096, 16384, 1, 0, 'null', '2024-05-14 09:25:15', '2025-04-02 20:22:15'),
(39, 'chat', 'Claude35-snonet', 'claude-3-5-sonnet-20240620', 5, 1, 2, 1.0, 4000, 200000, 1, 0, '', '2024-05-29 15:04:19', '2025-01-06 14:01:08'),
(41, 'chat', 'Suno对话模型', 'suno-v3.5', 7, 1, 10, 1.0, 1024, 8192, 1, 57, '', '2024-06-06 11:40:46', '2025-01-06 14:01:08'),
(42, 'chat', 'DeekSeek', 'deepseek-chat', 8, 1, 1, 1.0, 4096, 32768, 1, 57, '', '2024-06-27 16:13:01', '2025-01-06 14:11:51'),
(44, 'chat', 'Claude3-opus', 'claude-3-opus-20240229', 6, 1, 5, 1.0, 4000, 128000, 1, 44, '', '2024-07-22 11:24:30', '2025-01-06 14:01:08'),
(46, 'chat', 'GPT-4O-绘图', 'gpt-4o-image', 2, 1, 1, 1.0, 2048, 32000, 1, 6, '', '2024-07-22 13:53:41', '2025-03-29 13:02:14'),
(48, 'chat', '彩票助手', 'gpt-4-gizmo-g-wmSivBgxo', 9, 1, 1, 0.9, 1024, 8192, 1, 57, '', '2024-09-05 14:17:14', '2025-01-06 14:01:08'),
(49, 'chat', 'O1-mini', 'o1-mini', 10, 1, 2, 0.9, 1024, 8192, 1, 44, '', '2024-09-13 18:07:50', '2025-01-06 14:01:08'),
(50, 'chat', 'O1-preview', 'o1-preview', 11, 1, 5, 0.9, 1024, 8192, 1, 44, '', '2024-09-13 18:11:08', '2025-01-06 14:01:08'),
(51, 'chat', 'O1-mini-all', 'o1-mini-all', 12, 1, 1, 0.9, 1024, 8192, 1, 57, '', '2024-09-29 11:40:52', '2025-01-06 14:01:08'),
(52, 'chat', '通义千问', 'qwen-plus', 14, 1, 1, 0.9, 1024, 8192, 1, 80, '', '2024-11-19 08:38:14', '2025-01-06 14:01:08'),
(53, 'chat', 'OpenAI 高级语音', 'advanced-voice', 15, 1, 10, 0.9, 1024, 8192, 1, 44, '', '2024-12-20 10:34:45', '2025-01-06 14:01:08'),
(54, 'chat', 'Qwen2.5-14B-Instruct', 'Qwen2.5-14B-Instruct', 16, 1, 1, 0.9, 1024, 8192, 1, 81, '', '2024-12-25 14:53:17', '2025-01-06 14:01:08'),
(55, 'chat', 'Qwen2.5-7B-Instruct', 'Qwen2.5-7B-Instruct', 17, 1, 1, 0.9, 1024, 8192, 1, 81, '', '2024-12-25 15:15:49', '2025-01-06 14:01:08'),
(56, 'img', 'flux-1-schnell', 'flux-1-schnell', 18, 1, 1, 0.9, 1024, 8192, 1, 3, '', '2024-12-25 15:30:27', '2025-02-23 12:02:40'),
(57, 'img', 'dall-e-3', 'dall-e-3', 19, 1, 1, 0.9, 1024, 8192, 1, 57, '', '2024-12-25 16:54:06', '2025-01-06 14:01:08'),
(58, 'img', 'SD-3-medium', 'stable-diffusion-3-medium', 20, 1, 1, 0.9, 1024, 8192, 1, 3, 'null', '2024-12-27 10:03:28', '2025-04-02 20:20:36'),
(59, 'chat', 'O1-preview-all', 'O1-preview-all', 13, 1, 10, 0.9, 1024, 32000, 1, 57, '', '2025-01-06 14:01:04', '2025-01-06 14:01:08');
INSERT INTO `chatgpt_chat_models` (`id`, `description`, `category`, `type`, `name`, `value`, `sort_num`, `enabled`, `power`, `temperature`, `max_tokens`, `max_context`, `open`, `key_id`, `options`, `created_at`, `updated_at`) VALUES
(1, '', '', 'chat', 'gpt-4o-mini', 'gpt-4o-mini', 1, 1, 1, 1.0, 1024, 16384, 1, 1, '', '2023-08-23 12:06:36', '2025-02-23 11:57:03'),
(15, '', '', 'chat', 'GPT-4O(联网版本)', 'gpt-4o-all', 4, 1, 30, 1.0, 4096, 32768, 1, 57, '', '2024-01-15 11:32:52', '2025-01-06 14:01:08'),
(36, '', '', 'chat', 'GPT-4O', 'gpt-4o', 3, 1, 15, 1.0, 4096, 16384, 1, 0, 'null', '2024-05-14 09:25:15', '2025-04-02 20:22:15'),
(39, '', '', 'chat', 'Claude35-snonet', 'claude-3-5-sonnet-20240620', 5, 1, 2, 1.0, 4000, 200000, 1, 0, '', '2024-05-29 15:04:19', '2025-01-06 14:01:08'),
(41, '', '', 'chat', 'Suno对话模型', 'suno-v3.5', 7, 1, 10, 1.0, 1024, 8192, 1, 57, '', '2024-06-06 11:40:46', '2025-01-06 14:01:08'),
(42, '', '', 'chat', 'DeekSeek', 'deepseek-chat', 8, 1, 1, 1.0, 4096, 32768, 1, 57, '', '2024-06-27 16:13:01', '2025-01-06 14:11:51'),
(44, '', '', 'chat', 'Claude3-opus', 'claude-3-opus-20240229', 6, 1, 5, 1.0, 4000, 128000, 1, 44, '', '2024-07-22 11:24:30', '2025-01-06 14:01:08'),
(46, '', '', 'chat', 'GPT-4O-绘图', 'gpt-4o-image', 2, 1, 1, 1.0, 2048, 32000, 1, 6, '', '2024-07-22 13:53:41', '2025-03-29 13:02:14'),
(48, '', '', 'chat', '彩票助手', 'gpt-4-gizmo-g-wmSivBgxo', 9, 1, 1, 0.9, 1024, 8192, 1, 57, '', '2024-09-05 14:17:14', '2025-01-06 14:01:08'),
(49, '', '', 'chat', 'O1-mini', 'o1-mini', 10, 1, 2, 0.9, 1024, 8192, 1, 44, '', '2024-09-13 18:07:50', '2025-01-06 14:01:08'),
(50, '', '', 'chat', 'O1-preview', 'o1-preview', 11, 1, 5, 0.9, 1024, 8192, 1, 44, '', '2024-09-13 18:11:08', '2025-01-06 14:01:08'),
(51, '', '', 'chat', 'O1-mini-all', 'o1-mini-all', 12, 1, 1, 0.9, 1024, 8192, 1, 57, '', '2024-09-29 11:40:52', '2025-01-06 14:01:08'),
(52, '', '', 'chat', '通义千问', 'qwen-plus', 14, 1, 1, 0.9, 1024, 8192, 1, 80, '', '2024-11-19 08:38:14', '2025-01-06 14:01:08'),
(53, '', '', 'chat', 'OpenAI 高级语音', 'advanced-voice', 15, 1, 10, 0.9, 1024, 8192, 1, 44, '', '2024-12-20 10:34:45', '2025-01-06 14:01:08'),
(54, '', '', 'chat', 'Qwen2.5-14B-Instruct', 'Qwen2.5-14B-Instruct', 16, 1, 1, 0.9, 1024, 8192, 1, 81, '', '2024-12-25 14:53:17', '2025-01-06 14:01:08'),
(55, '', '', 'chat', 'Qwen2.5-7B-Instruct', 'Qwen2.5-7B-Instruct', 17, 1, 1, 0.9, 1024, 8192, 1, 81, '', '2024-12-25 15:15:49', '2025-01-06 14:01:08'),
(56, '', '', 'img', 'flux-1-schnell', 'flux-1-schnell', 18, 1, 1, 0.9, 1024, 8192, 1, 3, '', '2024-12-25 15:30:27', '2025-02-23 12:02:40'),
(57, '', '', 'img', 'dall-e-3', 'dall-e-3', 19, 1, 1, 0.9, 1024, 8192, 1, 9, 'null', '2024-12-25 16:54:06', '2025-04-22 15:41:16'),
(58, '', '', 'img', 'SD-3-medium', 'stable-diffusion-3-medium', 20, 1, 1, 0.9, 1024, 8192, 1, 3, 'null', '2024-12-27 10:03:28', '2025-04-02 20:20:36'),
(59, '', '', 'chat', 'O1-preview-all', 'O1-preview-all', 13, 1, 10, 0.9, 1024, 32000, 1, 57, '', '2025-01-06 14:01:04', '2025-01-06 14:01:08'),
(60, '', '', 'tts', 'tts', 'tts-1', 0, 1, 1, 0.9, 1024, 8192, 1, 8, '{\"voice\":\"echo\"}', '2025-04-17 11:58:30', '2025-04-17 12:00:26');
-- --------------------------------------------------------
@@ -190,14 +204,14 @@ DROP TABLE IF EXISTS `chatgpt_chat_roles`;
CREATE TABLE `chatgpt_chat_roles` (
`id` int NOT NULL,
`name` varchar(30) NOT NULL COMMENT '角色名称',
`tid` int NOT NULL COMMENT '分类ID',
`tid` bigint NOT NULL COMMENT '分类ID',
`marker` varchar(30) NOT NULL COMMENT '角色标识',
`context_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色语料 json',
`hello_msg` varchar(255) NOT NULL COMMENT '打招呼信息',
`icon` varchar(255) NOT NULL COMMENT '角色图标',
`enable` tinyint(1) NOT NULL COMMENT '是否被启用',
`sort_num` smallint NOT NULL DEFAULT '0' COMMENT '角色排序',
`model_id` int NOT NULL DEFAULT '0' COMMENT '绑定模型ID',
`model_id` bigint NOT NULL DEFAULT '0' COMMENT '绑定模型ID',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='聊天角色表';
@@ -246,7 +260,7 @@ CREATE TABLE `chatgpt_configs` (
INSERT INTO `chatgpt_configs` (`id`, `marker`, `config_json`) VALUES
(1, 'system', '{\"title\":\"GeekAI 创作助手\",\"slogan\":\"我辈之人先干为敬让每一个人都能用好AI\",\"admin_title\":\"GeekAI 控制台\",\"logo\":\"/images/logo.png\",\"bar_logo\":\"/images/bar_logo.png\",\"init_power\":100,\"daily_power\":1,\"invite_power\":200,\"vip_month_power\":1000,\"register_ways\":[\"username\",\"email\",\"mobile\"],\"enabled_register\":true,\"order_pay_timeout\":600,\"vip_info_text\":\"月度会员,年度会员每月赠送 1000 点算力,赠送算力当月有效当月没有消费完的算力不结余到下个月。 点卡充值的算力长期有效。\",\"mj_power\":20,\"mj_action_power\":5,\"sd_power\":5,\"dall_power\":10,\"suno_power\":10,\"luma_power\":120,\"keling_powers\":{\"kling-v1-5_pro_10\":840,\"kling-v1-5_pro_5\":420,\"kling-v1-5_std_10\":480,\"kling-v1-5_std_5\":240,\"kling-v1-6_pro_10\":840,\"kling-v1-6_pro_5\":420,\"kling-v1-6_std_10\":480,\"kling-v1-6_std_5\":240,\"kling-v1_pro_10\":840,\"kling-v1_pro_5\":420,\"kling-v1_std_10\":240,\"kling-v1_std_5\":120},\"advance_voice_power\":100,\"prompt_power\":1,\"wechat_card_url\":\"/images/wx.png\",\"enable_context\":true,\"context_deep\":10,\"sd_neg_prompt\":\"nsfw, paintings,low quality,easynegative,ng_deepnegative ,lowres,bad anatomy,bad hands,bad feet\",\"mj_mode\":\"fast\",\"index_navs\":[1,5,13,19,9,12,6,20,8,10],\"copyright\":\"极客学长\",\"icp\":\"粤ICP备19122051号\",\"mark_map_text\":\"# GeekAI 演示站\\n\\n- 完整的开源系统,前端应用和后台管理系统皆可开箱即用。\\n- 基于 Websocket 实现,完美的打字机体验。\\n- 内置了各种预训练好的角色应用,轻松满足你的各种聊天和应用需求。\\n- 支持 OPenAIAzure文心一言讯飞星火清华 ChatGLM等多个大语言模型。\\n- 支持 MidJourney / Stable Diffusion AI 绘画集成,开箱即用。\\n- 支持使用个人微信二维码作为充值收费的支付渠道,无需企业支付通道。\\n- 已集成支付宝支付功能,微信支付,支持多种会员套餐和点卡购买功能。\\n- 集成插件 API 功能,可结合大语言模型的 function 功能开发各种强大的插件。\",\"enabled_verify\":false,\"email_white_list\":[\"qq.com\",\"163.com\",\"gmail.com\",\"hotmail.com\",\"126.com\",\"outlook.com\",\"foxmail.com\",\"yahoo.com\"],\"translate_model_id\":36,\"max_file_size\":10}'),
(3, 'notice', '{\"sd_neg_prompt\":\"\",\"mj_mode\":\"\",\"index_navs\":null,\"copyright\":\"\",\"icp\":\"\",\"mark_map_text\":\"\",\"enabled_verify\":false,\"email_white_list\":null,\"translate_model_id\":0,\"max_file_size\":0,\"content\":\"## v4.2.2 更新日志\\n- 功能优化:开启图形验证码功能的时候现检查是否配置了 API 服务,防止开启之后没法登录的 Bug。\\n- 功能优化:支持原生的 DeepSeek 推理模型 API聊天 API KEY 支持设置完整的 API 路径,比如 https://api.geekai.pro/v1/chat/completions\\n- 功能优化:支持 GPT-4o 图片编辑功能。\\n- 功能新增:对话页面支持 AI 输出语音播报TTS。\\n- 功能优化:替换瀑布流组件,优化用户体验。\\n- 功能优化:生成思维导图时候自动缓存上一次的结果。\\n- 功能优化:优化 MJ 绘图页面,增加 MJ-V7 模型支持。\\n- 功能优化:后台管理增加生成一键登录链接地址功能\\n\\n注意当前站点仅为开源项目 \\u003ca style=\\\"color: #F56C6C\\\" href=\\\"https://github.com/yangjian102621/geekai\\\" target=\\\"_blank\\\"\\u003eGeekAI-Plus\\u003c/a\\u003e 的演示项目,本项目单纯就是给大家体验项目功能使用。\\n\\u003cstrong style=\\\"color: #F56C6C\\\"\\u003e体验额度用完之后请不要在当前站点进行任何充值操作\\u003c/strong\\u003e\\n\\u003cstrong style=\\\"color: #F56C6C\\\"\\u003e体验额度用完之后请不要在当前站点进行任何充值操作\\u003c/strong\\u003e\\n\\u003cstrong style=\\\"color: #F56C6C\\\"\\u003e体验额度用完之后请不要在当前站点进行任何充值操作\\u003c/strong\\u003e\\n 如果觉得好用你就花几分钟自己部署一套没有API KEY 的同学可以去下面几个推荐的中转站购买:\\n1、\\u003ca href=\\\"https://api.geekai.pro\\\" target=\\\"_blank\\\"\\n style=\\\"font-size: 20px;color:#F56C6C\\\"\\u003ehttps://api.geekai.pro\\u003c/a\\u003e\\n2、\\u003ca href=\\\"https://api.geekai.me\\\" target=\\\"_blank\\\"\\n style=\\\"font-size: 20px;color:#F56C6C\\\"\\u003ehttps://api.geekai.me\\u003c/a\\u003e\\n支持MidJourneyGPTClaudeGoogle Gemmi以及国内各个厂家的大模型现在有超级优惠价格远低于 OpenAI 官方。关于中转 API 的优势和劣势请参考 [中转API技术原理](https://docs.geekai.me/config/chat/#%E4%B8%AD%E8%BD%ACapi%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86)。GPT-3.5GPT-4DALL-E3 绘图......你都可以随意使用,无需魔法。\\n接入教程 \\u003ca href=\\\"https://docs.geekai.me\\\" target=\\\"_blank\\\"\\n style=\\\"font-size: 20px;color:#F56C6C\\\"\\u003ehttps://docs.geekai.me\\u003c/a\\u003e\\n本项目源码地址\\u003ca href=\\\"https://github.com/yangjian102621/geekai\\\" target=\\\"_blank\\\"\\u003ehttps://github.com/yangjian102621/geekai\\u003c/a\\u003e\",\"updated\":true}');
(3, 'notice', '{\"sd_neg_prompt\":\"\",\"mj_mode\":\"\",\"index_navs\":null,\"copyright\":\"\",\"icp\":\"\",\"mark_map_text\":\"\",\"enabled_verify\":false,\"email_white_list\":null,\"translate_model_id\":0,\"max_file_size\":0,\"content\":\"## v4.2.3 更新日志\\n- 功能优化:增加模型分组与模型描述,采用卡片展示模式改进模型选择功能体验\\n- 功能优化:化思维导图下载图片的清晰度以及解决拖动、缩放操作后下载图片内容不全问题\\n- Bug 修复:修复 MJ 画图页面已画出的图,点复制指令无效问题\\n- 功能优化MJ 画图的分辨率支持自定义,优先使用 prompt 中--ar 参数\\n- Bug 修复:修复 MJ 绘画 U1-V1,拼写错误\\n- 功能优化:支持自动迁移数据表结构,无需在手动执行 SQL 了\\n- 功能优化:移除首页的文字动画效果\\n- 功能优化:在聊天页面增加对话列表展开和隐藏功能\\n\\n注意当前站点仅为开源项目 \\u003ca style=\\\"color: #F56C6C\\\" href=\\\"https://github.com/yangjian102621/geekai\\\" target=\\\"_blank\\\"\\u003eGeekAI-Plus\\u003c/a\\u003e 的演示项目,本项目单纯就是给大家体验项目功能使用。\\n\\u003cstrong style=\\\"color: #F56C6C\\\"\\u003e体验额度用完之后请不要在当前站点进行任何充值操作\\u003c/strong\\u003e\\n\\u003cstrong style=\\\"color: #F56C6C\\\"\\u003e体验额度用完之后请不要在当前站点进行任何充值操作\\u003c/strong\\u003e\\n\\u003cstrong style=\\\"color: #F56C6C\\\"\\u003e体验额度用完之后请不要在当前站点进行任何充值操作\\u003c/strong\\u003e\\n 如果觉得好用你就花几分钟自己部署一套没有API KEY 的同学可以去下面几个推荐的中转站购买:\\n1、\\u003ca href=\\\"https://api.geekai.pro\\\" target=\\\"_blank\\\"\\n style=\\\"font-size: 20px;color:#F56C6C\\\"\\u003ehttps://api.geekai.pro\\u003c/a\\u003e\\n2、\\u003ca href=\\\"https://api.geekai.me\\\" target=\\\"_blank\\\"\\n style=\\\"font-size: 20px;color:#F56C6C\\\"\\u003ehttps://api.geekai.me\\u003c/a\\u003e\\n支持MidJourneyGPTClaudeGoogle Gemmi以及国内各个厂家的大模型现在有超级优惠价格远低于 OpenAI 官方。关于中转 API 的优势和劣势请参考 [中转API技术原理](https://docs.geekai.me/config/chat/#%E4%B8%AD%E8%BD%ACapi%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86)。GPT-3.5GPT-4DALL-E3 绘图......你都可以随意使用,无需魔法。\\n接入教程 \\u003ca href=\\\"https://docs.geekai.me\\\" target=\\\"_blank\\\"\\n style=\\\"font-size: 20px;color:#F56C6C\\\"\\u003ehttps://docs.geekai.me\\u003c/a\\u003e\\n本项目源码地址\\u003ca href=\\\"https://github.com/yangjian102621/geekai\\\" target=\\\"_blank\\\"\\u003ehttps://github.com/yangjian102621/geekai\\u003c/a\\u003e\",\"updated\":true}');
-- --------------------------------------------------------
@@ -257,7 +271,7 @@ INSERT INTO `chatgpt_configs` (`id`, `marker`, `config_json`) VALUES
DROP TABLE IF EXISTS `chatgpt_dall_jobs`;
CREATE TABLE `chatgpt_dall_jobs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`prompt` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词',
`task_info` text NOT NULL COMMENT '任务详情',
`img_url` varchar(255) NOT NULL COMMENT '图片地址',
@@ -278,7 +292,7 @@ CREATE TABLE `chatgpt_dall_jobs` (
DROP TABLE IF EXISTS `chatgpt_files`;
CREATE TABLE `chatgpt_files` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件名',
`obj_key` varchar(100) DEFAULT NULL COMMENT '文件标识',
`url` varchar(255) NOT NULL COMMENT '文件地址',
@@ -310,9 +324,9 @@ CREATE TABLE `chatgpt_functions` (
--
INSERT INTO `chatgpt_functions` (`id`, `name`, `label`, `description`, `parameters`, `token`, `action`, `enabled`) VALUES
(1, 'weibo', '微博热搜', '新浪微博热搜榜,微博当日热搜榜单', '{\"type\":\"object\",\"properties\":{}}', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVkIjowLCJ1c2VyX2lkIjowfQ.tLAGkF8XWh_G-oQzevpIodsswtPByBLoAZDz_eWuBgw', 'http://localhost:5678/api/function/weibo', 1),
(2, 'zaobao', '今日早报', '每日早报,获取当天新闻事件列表', '{\"type\":\"object\",\"properties\":{}}', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVkIjowLCJ1c2VyX2lkIjowfQ.tLAGkF8XWh_G-oQzevpIodsswtPByBLoAZDz_eWuBgw', 'http://localhost:5678/api/function/zaobao', 1),
(3, 'dalle3', 'DALLE3', 'AI 绘画工具,根据输入的绘图描述用 AI 工具进行绘画', '{\"type\":\"object\",\"required\":[\"prompt\"],\"properties\":{\"prompt\":{\"type\":\"string\",\"description\":\"绘画提示词\"}}}', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVkIjowLCJ1c2VyX2lkIjowfQ.tLAGkF8XWh_G-oQzevpIodsswtPByBLoAZDz_eWuBgw', 'http://localhost:5678/api/function/dalle3', 1);
(1, 'weibo', '微博热搜', '新浪微博热搜榜,微博当日热搜榜单', '{\"type\":\"object\",\"properties\":{}}', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVkIjowLCJ1c2VyX2lkIjowfQ.ehLClXcjo-Ytr5y6pY9mSE3zN_2ViIXAIpTJxI9S1Mo', 'http://localhost:5678/api/function/weibo', 1),
(2, 'zaobao', '今日早报', '每日早报,获取当天新闻事件列表', '{\"type\":\"object\",\"properties\":{}}', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVkIjowLCJ1c2VyX2lkIjowfQ.ehLClXcjo-Ytr5y6pY9mSE3zN_2ViIXAIpTJxI9S1Mo', 'http://localhost:5678/api/function/zaobao', 1),
(3, 'dalle3', 'DALLE3', 'AI 绘画工具,根据输入的绘图描述用 AI 工具进行绘画', '{\"type\":\"object\",\"required\":[\"prompt\"],\"properties\":{\"prompt\":{\"type\":\"string\",\"description\":\"绘画提示词\"}}}', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVkIjowLCJ1c2VyX2lkIjowfQ.ehLClXcjo-Ytr5y6pY9mSE3zN_2ViIXAIpTJxI9S1Mo', 'http://localhost:5678/api/function/dalle3', 1);
-- --------------------------------------------------------
@@ -323,9 +337,9 @@ INSERT INTO `chatgpt_functions` (`id`, `name`, `label`, `description`, `paramete
DROP TABLE IF EXISTS `chatgpt_invite_codes`;
CREATE TABLE `chatgpt_invite_codes` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`code` char(8) NOT NULL COMMENT '邀请码',
`hits` int NOT NULL COMMENT '点击次数',
`hits` bigint NOT NULL COMMENT '点击次数',
`reg_num` smallint NOT NULL COMMENT '注册数量',
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户邀请码';
@@ -339,8 +353,8 @@ CREATE TABLE `chatgpt_invite_codes` (
DROP TABLE IF EXISTS `chatgpt_invite_logs`;
CREATE TABLE `chatgpt_invite_logs` (
`id` int NOT NULL,
`inviter_id` int NOT NULL COMMENT '邀请人ID',
`user_id` int NOT NULL COMMENT '注册用户ID',
`inviter_id` bigint NOT NULL COMMENT '邀请人ID',
`user_id` bigint NOT NULL COMMENT '注册用户ID',
`username` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户名',
`invite_code` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '邀请码',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '备注',
@@ -392,7 +406,7 @@ INSERT INTO `chatgpt_menus` (`id`, `name`, `icon`, `url`, `sort_num`, `enabled`)
DROP TABLE IF EXISTS `chatgpt_mj_jobs`;
CREATE TABLE `chatgpt_mj_jobs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`task_id` varchar(20) DEFAULT NULL COMMENT '任务 ID',
`task_info` text NOT NULL COMMENT '任务详情',
`type` varchar(20) DEFAULT 'image' COMMENT '任务类别',
@@ -420,16 +434,16 @@ CREATE TABLE `chatgpt_mj_jobs` (
DROP TABLE IF EXISTS `chatgpt_orders`;
CREATE TABLE `chatgpt_orders` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户ID',
`product_id` int NOT NULL COMMENT '产品ID',
`username` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户',
`user_id` bigint NOT NULL COMMENT '用户ID',
`product_id` bigint NOT NULL COMMENT '产品ID',
`username` varchar(30) NOT NULL COMMENT '用户',
`order_no` varchar(30) NOT NULL COMMENT '订单ID',
`trade_no` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '支付平台交易流水号',
`subject` varchar(100) NOT NULL COMMENT '订单产品',
`amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单金额',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '订单状态0待支付1已扫码2支付成功',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '备注',
`pay_time` int DEFAULT NULL COMMENT '支付时间',
`pay_time` bigint DEFAULT NULL COMMENT '支付时间',
`pay_way` varchar(20) NOT NULL COMMENT '支付方式',
`pay_type` varchar(30) NOT NULL COMMENT '支付类型',
`created_at` datetime NOT NULL,
@@ -446,11 +460,11 @@ CREATE TABLE `chatgpt_orders` (
DROP TABLE IF EXISTS `chatgpt_power_logs`;
CREATE TABLE `chatgpt_power_logs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`username` varchar(30) NOT NULL COMMENT '用户名',
`type` tinyint(1) NOT NULL COMMENT '类型1充值2消费3退费',
`amount` smallint NOT NULL COMMENT '算力数值',
`balance` int NOT NULL COMMENT '余额',
`balance` bigint NOT NULL COMMENT '余额',
`model` varchar(30) NOT NULL COMMENT '模型',
`remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '备注',
`mark` tinyint(1) NOT NULL COMMENT '资金类型0支出1收入',
@@ -470,9 +484,9 @@ CREATE TABLE `chatgpt_products` (
`price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
`discount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '优惠金额',
`days` smallint NOT NULL DEFAULT '0' COMMENT '延长天数',
`power` int NOT NULL DEFAULT '0' COMMENT '增加算力值',
`power` bigint NOT NULL DEFAULT '0' COMMENT '增加算力值',
`enabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启动',
`sales` int NOT NULL DEFAULT '0' COMMENT '销量',
`sales` bigint NOT NULL DEFAULT '0' COMMENT '销量',
`sort_num` tinyint NOT NULL DEFAULT '0' COMMENT '排序',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
@@ -497,13 +511,13 @@ INSERT INTO `chatgpt_products` (`id`, `name`, `price`, `discount`, `days`, `powe
DROP TABLE IF EXISTS `chatgpt_redeems`;
CREATE TABLE `chatgpt_redeems` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`name` varchar(30) NOT NULL COMMENT '兑换码名称',
`power` int NOT NULL COMMENT '算力',
`power` bigint NOT NULL COMMENT '算力',
`code` varchar(100) NOT NULL COMMENT '兑换码',
`enabled` tinyint(1) NOT NULL COMMENT '是否启用',
`created_at` datetime NOT NULL,
`redeemed_at` int NOT NULL COMMENT '兑换时间'
`redeemed_at` bigint NOT NULL COMMENT '兑换时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='兑换码';
-- --------------------------------------------------------
@@ -515,7 +529,7 @@ CREATE TABLE `chatgpt_redeems` (
DROP TABLE IF EXISTS `chatgpt_sd_jobs`;
CREATE TABLE `chatgpt_sd_jobs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'txt2img' COMMENT '任务类别',
`task_id` char(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务 ID',
`task_info` text NOT NULL COMMENT '任务详情',
@@ -538,7 +552,7 @@ CREATE TABLE `chatgpt_sd_jobs` (
DROP TABLE IF EXISTS `chatgpt_suno_jobs`;
CREATE TABLE `chatgpt_suno_jobs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`channel` varchar(100) NOT NULL COMMENT '渠道',
`title` varchar(100) DEFAULT NULL COMMENT '歌曲标题',
`type` tinyint(1) DEFAULT '0' COMMENT '任务类型,1:灵感创作,2:自定义创作',
@@ -560,7 +574,7 @@ CREATE TABLE `chatgpt_suno_jobs` (
`err_msg` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '错误信息',
`raw_data` text COMMENT '原始数据',
`power` smallint NOT NULL DEFAULT '0' COMMENT '消耗算力',
`play_times` int DEFAULT NULL COMMENT '播放次数',
`play_times` bigint DEFAULT NULL COMMENT '播放次数',
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='MidJourney 任务表';
@@ -580,29 +594,30 @@ CREATE TABLE `chatgpt_users` (
`password` char(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码',
`avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '头像',
`salt` char(12) NOT NULL COMMENT '密码盐',
`power` int NOT NULL DEFAULT '0' COMMENT '剩余算力',
`expired_time` int NOT NULL COMMENT '用户过期时间',
`power` bigint NOT NULL DEFAULT '0' COMMENT '剩余算力',
`expired_time` bigint NOT NULL COMMENT '用户过期时间',
`status` tinyint(1) NOT NULL COMMENT '当前状态',
`chat_config_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '聊天配置json',
`chat_roles_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '聊天角色 json',
`chat_models_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'AI模型 json',
`last_login_at` int NOT NULL COMMENT '最后登录时间',
`last_login_at` bigint NOT NULL COMMENT '最后登录时间',
`vip` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否会员',
`last_login_ip` char(16) NOT NULL COMMENT '最后登录 IP',
`openid` varchar(100) DEFAULT NULL COMMENT '第三方登录账号ID',
`platform` varchar(30) DEFAULT NULL COMMENT '登录平台',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
`updated_at` datetime NOT NULL,
`chat_config` text NOT NULL COMMENT '聊天配置json'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户表';
--
-- 转存表中的数据 `chatgpt_users`
--
INSERT INTO `chatgpt_users` (`id`, `username`, `mobile`, `email`, `nickname`, `password`, `avatar`, `salt`, `power`, `expired_time`, `status`, `chat_config_json`, `chat_roles_json`, `chat_models_json`, `last_login_at`, `vip`, `last_login_ip`, `openid`, `platform`, `created_at`, `updated_at`) VALUES
(4, '18888888888', '18575670126', '', '极客学长', 'ccc3fb7ab61b8b5d096a4a166ae21d121fc38c71bbd1be6173d9ab973214a63b', 'http://nk.img.r9it.com/gpt/1743224552271576.jpeg', 'ueedue5l', 12132, 0, 1, '{\"api_keys\":{\"Azure\":\"\",\"ChatGLM\":\"\",\"OpenAI\":\"\"}}', '[\"gpt\",\"programmer\",\"teacher\",\"psychiatrist\",\"lu_xun\",\"english_trainer\",\"translator\",\"red_book\",\"dou_yin\",\"weekly_report\",\"girl_friend\",\"steve_jobs\",\"elon_musk\",\"kong_zi\",\"draw_prompt_expert\",\"draw_prompt\",\"prompt_engineer\"]', '[1]', 1744791408, 1, '::1', '', NULL, '2023-06-12 16:47:17', '2025-04-16 16:16:48'),
(48, 'wx@3659838859', '', '', '极客学长', 'cf6bbe381b23812d2b9fd423abe74003cecdd3b93809896eb573536ba6c500b3', 'https://thirdwx.qlogo.cn/mmopen/vi_32/uyxRMqZcEkb7fHouKXbNzxrnrvAttBKkwNlZ7yFibibRGiahdmsrZ3A1NKf8Fw5qJNJn4TXRmygersgEbibaSGd9Sg/132', '5rsy4iwg', 98, 0, 1, '', '[\"gpt\",\"teacher\"]', '', 1736228927, 0, '172.22.11.200', 'oCs0t62472W19z2LOEKI1rWyCTTA', '', '2025-01-07 13:43:06', '2025-01-07 13:48:48'),
(49, 'wx@9502480897', '', '', 'AI探索君', 'd99fa8ba7da1455693b40e11d894a067416e758af2a75d7a3df4721b76cdbc8c', 'https://thirdwx.qlogo.cn/mmopen/vi_32/Zpcln1FZjcKxqtIyCsOTLGn16s7uIvwWfdkdsW6gbZg4r9sibMbic4jvrHmV7ux9nseTB5kBSnu1HSXr7zB8rTXg/132', 'fjclgsli', 99, 0, 1, '', '[\"gpt\"]', '', 0, 0, '', 'oCs0t64FaOLfiTbHZpOqk3aUp_94', '', '2025-01-07 14:05:31', '2025-01-07 14:05:31');
INSERT INTO `chatgpt_users` (`id`, `username`, `mobile`, `email`, `nickname`, `password`, `avatar`, `salt`, `power`, `expired_time`, `status`, `chat_config_json`, `chat_roles_json`, `chat_models_json`, `last_login_at`, `vip`, `last_login_ip`, `openid`, `platform`, `created_at`, `updated_at`, `chat_config`) VALUES
(4, '18888888888', '18575670126', '', '极客学长', 'ccc3fb7ab61b8b5d096a4a166ae21d121fc38c71bbd1be6173d9ab973214a63b', '/images/avatar/user.png', 'ueedue5l', 12137, 0, 1, '{\"api_keys\":{\"Azure\":\"\",\"ChatGLM\":\"\",\"OpenAI\":\"\"}}', '[\"gpt\",\"programmer\",\"teacher\",\"psychiatrist\",\"lu_xun\",\"english_trainer\",\"translator\",\"red_book\",\"dou_yin\",\"weekly_report\",\"girl_friend\",\"steve_jobs\",\"elon_musk\",\"kong_zi\",\"draw_prompt_expert\",\"draw_prompt\",\"prompt_engineer\"]', '[1]', 1746417142, 1, '::1', '', NULL, '2023-06-12 16:47:17', '2025-05-05 11:52:22', ''),
(48, 'wx@3659838859', '', '', '极客学长', 'cf6bbe381b23812d2b9fd423abe74003cecdd3b93809896eb573536ba6c500b3', 'https://thirdwx.qlogo.cn/mmopen/vi_32/uyxRMqZcEkb7fHouKXbNzxrnrvAttBKkwNlZ7yFibibRGiahdmsrZ3A1NKf8Fw5qJNJn4TXRmygersgEbibaSGd9Sg/132', '5rsy4iwg', 98, 0, 1, '', '[\"gpt\",\"teacher\"]', '', 1736228927, 0, '172.22.11.200', 'oCs0t62472W19z2LOEKI1rWyCTTA', '', '2025-01-07 13:43:06', '2025-01-07 13:48:48', ''),
(49, 'wx@9502480897', '', '', 'AI探索君', 'd99fa8ba7da1455693b40e11d894a067416e758af2a75d7a3df4721b76cdbc8c', 'https://thirdwx.qlogo.cn/mmopen/vi_32/Zpcln1FZjcKxqtIyCsOTLGn16s7uIvwWfdkdsW6gbZg4r9sibMbic4jvrHmV7ux9nseTB5kBSnu1HSXr7zB8rTXg/132', 'fjclgsli', 99, 0, 1, '', '[\"gpt\"]', '', 0, 0, '', 'oCs0t64FaOLfiTbHZpOqk3aUp_94', '', '2025-01-07 14:05:31', '2025-01-07 14:05:31', '');
-- --------------------------------------------------------
@@ -613,7 +628,7 @@ INSERT INTO `chatgpt_users` (`id`, `username`, `mobile`, `email`, `nickname`, `p
DROP TABLE IF EXISTS `chatgpt_user_login_logs`;
CREATE TABLE `chatgpt_user_login_logs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`username` varchar(30) NOT NULL COMMENT '用户名',
`login_ip` char(16) NOT NULL COMMENT '登录IP',
`login_address` varchar(30) NOT NULL COMMENT '登录地址',
@@ -630,7 +645,7 @@ CREATE TABLE `chatgpt_user_login_logs` (
DROP TABLE IF EXISTS `chatgpt_video_jobs`;
CREATE TABLE `chatgpt_video_jobs` (
`id` int NOT NULL,
`user_id` int NOT NULL COMMENT '用户 ID',
`user_id` bigint NOT NULL COMMENT '用户 ID',
`channel` varchar(100) NOT NULL COMMENT '渠道',
`task_id` varchar(100) NOT NULL COMMENT '任务 ID',
`task_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '原始任务信息',
@@ -657,7 +672,8 @@ CREATE TABLE `chatgpt_video_jobs` (
--
ALTER TABLE `chatgpt_admin_users`
ADD PRIMARY KEY (`id`) USING BTREE,
ADD UNIQUE KEY `username` (`username`) USING BTREE;
ADD UNIQUE KEY `username` (`username`) USING BTREE,
ADD UNIQUE KEY `idx_chatgpt_admin_users_username` (`username`);
--
-- 表的索引 `chatgpt_api_keys`
@@ -676,14 +692,16 @@ ALTER TABLE `chatgpt_app_types`
--
ALTER TABLE `chatgpt_chat_history`
ADD PRIMARY KEY (`id`),
ADD KEY `chat_id` (`chat_id`);
ADD KEY `chat_id` (`chat_id`),
ADD KEY `idx_chatgpt_chat_history_chat_id` (`chat_id`);
--
-- 表的索引 `chatgpt_chat_items`
--
ALTER TABLE `chatgpt_chat_items`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `chat_id` (`chat_id`);
ADD UNIQUE KEY `chat_id` (`chat_id`),
ADD UNIQUE KEY `idx_chatgpt_chat_items_chat_id` (`chat_id`);
--
-- 表的索引 `chatgpt_chat_models`
@@ -696,14 +714,16 @@ ALTER TABLE `chatgpt_chat_models`
--
ALTER TABLE `chatgpt_chat_roles`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `marker` (`marker`);
ADD UNIQUE KEY `marker` (`marker`),
ADD UNIQUE KEY `idx_chatgpt_chat_roles_marker` (`marker`);
--
-- 表的索引 `chatgpt_configs`
--
ALTER TABLE `chatgpt_configs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `marker` (`marker`);
ADD UNIQUE KEY `marker` (`marker`),
ADD UNIQUE KEY `idx_chatgpt_configs_key` (`marker`);
--
-- 表的索引 `chatgpt_dall_jobs`
@@ -722,14 +742,16 @@ ALTER TABLE `chatgpt_files`
--
ALTER TABLE `chatgpt_functions`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
ADD UNIQUE KEY `name` (`name`),
ADD UNIQUE KEY `idx_chatgpt_functions_name` (`name`);
--
-- 表的索引 `chatgpt_invite_codes`
--
ALTER TABLE `chatgpt_invite_codes`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `code` (`code`);
ADD UNIQUE KEY `code` (`code`),
ADD UNIQUE KEY `idx_chatgpt_invite_codes_code` (`code`);
--
-- 表的索引 `chatgpt_invite_logs`
@@ -749,14 +771,17 @@ ALTER TABLE `chatgpt_menus`
ALTER TABLE `chatgpt_mj_jobs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `task_id` (`task_id`),
ADD KEY `message_id` (`message_id`);
ADD UNIQUE KEY `idx_chatgpt_mj_jobs_task_id` (`task_id`),
ADD KEY `message_id` (`message_id`),
ADD KEY `idx_chatgpt_mj_jobs_message_id` (`message_id`);
--
-- 表的索引 `chatgpt_orders`
--
ALTER TABLE `chatgpt_orders`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `order_no` (`order_no`);
ADD UNIQUE KEY `order_no` (`order_no`),
ADD UNIQUE KEY `idx_chatgpt_orders_order_no` (`order_no`);
--
-- 表的索引 `chatgpt_power_logs`
@@ -775,14 +800,16 @@ ALTER TABLE `chatgpt_products`
--
ALTER TABLE `chatgpt_redeems`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `code` (`code`);
ADD UNIQUE KEY `code` (`code`),
ADD UNIQUE KEY `idx_chatgpt_redeems_code` (`code`);
--
-- 表的索引 `chatgpt_sd_jobs`
--
ALTER TABLE `chatgpt_sd_jobs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `task_id` (`task_id`);
ADD UNIQUE KEY `task_id` (`task_id`),
ADD UNIQUE KEY `idx_chatgpt_sd_jobs_task_id` (`task_id`);
--
-- 表的索引 `chatgpt_suno_jobs`
@@ -795,7 +822,8 @@ ALTER TABLE `chatgpt_suno_jobs`
--
ALTER TABLE `chatgpt_users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
ADD UNIQUE KEY `username` (`username`),
ADD UNIQUE KEY `idx_chatgpt_users_username` (`username`);
--
-- 表的索引 `chatgpt_user_login_logs`
@@ -829,7 +857,7 @@ ALTER TABLE `chatgpt_api_keys`
-- 使用表AUTO_INCREMENT `chatgpt_app_types`
--
ALTER TABLE `chatgpt_app_types`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- 使用表AUTO_INCREMENT `chatgpt_chat_history`
@@ -847,7 +875,7 @@ ALTER TABLE `chatgpt_chat_items`
-- 使用表AUTO_INCREMENT `chatgpt_chat_models`
--
ALTER TABLE `chatgpt_chat_models`
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=60;
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=61;
--
-- 使用表AUTO_INCREMENT `chatgpt_chat_roles`

5
docker/.gitignore vendored
View File

@@ -1,5 +0,0 @@
data/mysql/data
data/leveldb
logs
static/*
redis/redis

View File

@@ -1,104 +0,0 @@
Listen = "0.0.0.0:5678"
ProxyURL = ""
MysqlDns = "root:mhSCk0NheGhmtsha@tcp(geekai-mysql:3306)/geekai_plus?charset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=True&loc=Local"
StaticDir = "./static"
StaticUrl = "/static"
TikaHost = "http://geekai-tika:9998"
[Session]
SecretKey = "azyehq3ivunjhbntz78isj00i4hz2mt9xtddysfucxakadq4qbfrt0b7q3lnvg80"
MaxAge = 86400
[AdminSession]
SecretKey = "wr1uzwz2meai4z9j0e0tsyf6x523ui6zpnyaim4x2x37meakv13349llqpipyk40"
MaxAge = 8640000
[Redis]
Host = "geekai-redis"
Port = 6379
Password = "mhSCk0NheGhmtsha"
DB = 0
[ApiConfig]
ApiURL = "https://sapi.geekai.me"
AppId = ""
Token = ""
[SMS]
Active = "Ali"
[SMS.Ali]
AccessKey = ""
AccessSecret = ""
Product = "Dysmsapi"
Domain = "dysmsapi.aliyuncs.com"
Sign = ""
CodeTempId = ""
[SMS.Bao]
Username = ""
Password = ""
Domain = "api.smsbao.com"
Sign = "【极客学长】"
CodeTemplate = "您的验证码是{code}。5分钟有效若非本人操作请忽略本短信。"
[OSS]
Active = "Local"
[OSS.Local]
BasePath = "./static/upload"
BaseURL = "/static/upload"
[OSS.Minio]
Endpoint = ""
AccessKey = ""
AccessSecret = ""
Bucket = "geekai"
SubDir = ""
UseSSL = false
Domain = ""
[OSS.QiNiu]
Zone = "z2"
AccessKey = ""
AccessSecret = ""
Bucket = ""
SubDir = ""
Domain = ""
[OSS.AliYun]
Endpoint = "oss-cn-hangzhou.aliyuncs.com"
AccessKey = ""
AccessSecret = ""
Bucket = "geekai"
SubDir = ""
Domain = ""
# 支付宝商户支付
[AlipayConfig]
Enabled = false # 启用支付宝支付通道
SandBox = false # 是否启用沙盒模式
UserId = "2088721020750581" # 商户ID
AppId = "9021000131658023" # App Id
PrivateKey = "certs/alipay/privateKey.txt" # 应用私钥
PublicKey = "certs/alipay/appPublicCert.crt" # 应用公钥证书
AlipayPublicKey = "certs/alipay/alipayPublicCert.crt" # 支付宝公钥证书
RootCert = "certs/alipay/alipayRootCert.crt" # 支付宝根证书
# 虎皮椒支付
[HuPiPayConfig]
Enabled = false
AppId = ""
AppSecret = ""
ApiURL = "https://api.xunhupay.com"
# 微信商户支付
[WechatPayConfig]
Enabled = false
AppId = "" # 商户应用ID
MchId = "" # 商户号
SerialNo = "" # API 证书序列号
PrivateKey = "certs/alipay/privateKey.txt" # API 证书私钥文件路径,跟支付宝一样,把私钥文件拷贝到对应的路径,证书路径要映射到容器内
ApiV3Key = "" # APIV3 私钥,这个是你自己在微信支付平台设置的
# 易支付
[GeekPayConfig]
Enabled = true
AppId = "" # 商户ID
PrivateKey = "" # 商户私钥
ApiURL = "https://pay.geekai.cn"
Methods = ["alipay", "wxpay", "qqpay", "jdpay", "douyin", "paypal"] # 支持的支付方式

View File

@@ -1,17 +0,0 @@
mj:
task-store:
type: in_memory
timeout: 30d
translate-way: null
api-secret: "sk-geekmaster" # API 密钥,要跟 chatgpt-plus 应用 config.toml 配置对应上,否则 API 调用会失败
ng-discord: # 这里必须配置反代,否则无法访问 Discord API
server: "" # Discord API 反代
cdn: "" # Discord 图片 CDN 反代
wss: "" # Discord 网关反代
accounts: # MJ 账号,配置配置多个
- guild-id: ""
channel-id: ""
user-token: ""
user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"

View File

@@ -1,44 +0,0 @@
#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
[mysqld]
#
# * Basic Settings
#
#user = mysql
# pid-file = /var/run/mysqld/mysqld.pid
# socket = /var/run/mysqld/mysqld.sock
# port = 3306
# datadir = /var/lib/mysql
# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
mysqlx-bind-address = 0.0.0.0
performance_schema_max_table_instances=400
# 缓存
table_definition_cache=400
# 关闭监控
performance_schema=off
# 打开表的缓存
table_open_cache=64
# InnoDB缓冲池大小调整操作的块大小
innodb_buffer_pool_chunk_size=64M
# InnoDB 存储引擎的表数据和索引数据的最大内存缓冲区大小
innodb_buffer_pool_size=64M

View File

@@ -1,46 +0,0 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'websocket' upgrade;
}
server {
# listen 443 ssl;
listen 8080;
# server_name www.chatgpt.com; #替换成你自己的域名
# ssl_certificate xxx.pem; # 替换成自己的 SSL 证书
# ssl_certificate_key xxx.key;
# ssl_session_timeout 5m;
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_prefer_server_ciphers on;
# 日志地址
access_log /var/log/access.log;
error_log /var/log/error.log;
index index.html;
root /var/www/app/dist; # 这里改成前端静态页面的地址
location / {
try_files $uri $uri/ /index.html;
# 后端 API 的转发
location /api/ {
proxy_http_version 1.1;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 12s;
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 Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://geekai-api:5678;
}
# 静态资源转发
location /static/ {
proxy_pass http://geekai-api:5678;
}
}
}

View File

@@ -1,58 +0,0 @@
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
client_max_body_size 100M;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_min_length 1k;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

View File

@@ -1,66 +0,0 @@
### web
server.port=8080
server.servlet.context-path=/xxl-job-admin
### actuator
management.server.servlet.context-path=/actuator
management.health.mail.enabled=false
### resources
spring.mvc.servlet.load-on-startup=0
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/
### freemarker
spring.freemarker.templateLoaderPath=classpath:/templates/
spring.freemarker.suffix=.ftl
spring.freemarker.charset=UTF-8
spring.freemarker.request-context-attribute=request
spring.freemarker.settings.number_format=0.##########
### mybatis
mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml
#mybatis.type-aliases-package=com.xxl.job.admin.core.model
### xxl-job, datasource
spring.datasource.url=jdbc:mysql://geekai-mysql:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=12345678
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
### datasource-pool
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=30
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=HikariCP
spring.datasource.hikari.max-lifetime=900000
spring.datasource.hikari.connection-timeout=10000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.hikari.validation-timeout=1000
### xxl-job, email
spring.mail.host=smtp.qq.com
spring.mail.port=25
spring.mail.username=xxx@qq.com
spring.mail.from=xxx@qq.com
spring.mail.password=xxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
### xxl-job, access token
xxl.job.accessToken=GeekMaster
### xxl-job, i18n (default is zh_CN, and you can choose "zh_CN", "zh_TC" and "en")
xxl.job.i18n=zh_CN
## xxl-job, triggerpool max size
xxl.job.triggerpool.fast.max=200
xxl.job.triggerpool.slow.max=100
### xxl-job, log retention days
xxl.job.logretentiondays=3

View File

@@ -1,83 +0,0 @@
version: '3'
services:
# mysql
geekai-mysql:
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/mysql:8.0.33
container_name: geekai-mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
- MYSQL_ROOT_PASSWORD=mhSCk0NheGhmtsha
ports:
- '3307:3306'
volumes:
- ./conf/mysql/my.cnf:/etc/mysql/my.cnf
- ./data/mysql/data:/var/lib/mysql
- ./logs/mysql:/var/log/mysql
- ./data/mysql/init.d:/docker-entrypoint-initdb.d/
healthcheck:
test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
interval: 5s
timeout: 10s
retries: 10
# redis
geekai-redis:
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/redis:6.0.6
restart: always
container_name: geekai-redis
command: redis-server --requirepass mhSCk0NheGhmtsha
volumes:
- ./data/redis:/data
ports:
- '6380:6379'
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 3s
timeout: 10s
retries: 5
geekai-tika:
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/tika:latest
container_name: geekai-tika
restart: always
ports:
- '9999:9998'
# 后端 API 程序
geekai-api:
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/geekai-plus-api:v4.2.1-amd64
container_name: geekai-api
restart: always
depends_on:
geekai-mysql:
condition: service_healthy
geekai-redis:
condition: service_healthy
environment:
- DEBUG=false
- LOG_LEVEL=info
- CONFIG_FILE=config.toml
ports:
- '5678:5678'
volumes:
- /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
- ./conf/config.toml:/var/www/app/config.toml
- ./logs/app:/var/www/app/logs
- ./static:/var/www/app/static
- ./data:/var/www/app/data
# 前端应用
geekai-web:
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/geekai-plus-web:v4.2.1-amd64
container_name: geekai-web
restart: always
depends_on:
- geekai-api
ports:
- '8080:8080'
volumes:
- ./logs/nginx:/var/log/nginx
- ./conf/nginx/conf.d:/etc/nginx/conf.d
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./conf/nginx/ssl:/etc/nginx/ssl

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -7,7 +7,14 @@
</div>
<div class="chat-item">
<div class="content-wrapper" v-html="md.render(processContent(data.content))"></div>
<div
class="content-wrapper"
v-html="md.render(processContent(data.content))"
v-if="data.content"
></div>
<div class="content-wrapper flex justify-start items-center" v-else>
<span class="mr-2">AI 思考中</span> <Thinking :duration="1.5" />
</div>
<div class="bar flex text-gray-500" v-if="data.created_at">
<span class="bar-item text-sm">{{ dateFormat(data.created_at) }}</span>
<!-- <span class="bar-item">tokens: {{ data.tokens }}</span> -->
@@ -65,7 +72,14 @@
</div>
<div class="chat-item">
<div class="content-wrapper">
<div class="content" v-html="md.render(processContent(data.content))"></div>
<div
class="content"
v-html="md.render(processContent(data.content))"
v-if="data.content"
></div>
<div class="content flex justify-start items-center" v-else>
<span class="mr-2">AI 思考中</span> <Thinking :duration="1.5" />
</div>
</div>
<div class="bar text-gray-500" v-if="data.created_at">
<span class="bar-item text-sm"> {{ dateFormat(data.created_at) }}</span>
@@ -124,6 +138,7 @@ import MarkdownIt from 'markdown-it'
import emoji from 'markdown-it-emoji'
import mathjaxPlugin from 'markdown-it-mathjax3'
import { ref } from 'vue'
import Thinking from './Thinking.vue'
// eslint-disable-next-line no-undef,no-unused-vars
const props = defineProps({
data: {

View File

@@ -0,0 +1,77 @@
<template>
<div class="loading-container" :style="containerStyle">
<div
v-for="i in 3"
:key="i"
class="dot"
:style="[dotStyle, { animationDelay: `${(i - 1) * 0.2}s` }]"
></div>
</div>
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
// 点的大小(px)
size: {
type: Number,
default: 8,
},
// 点之间的间距(px)
spacing: {
type: Number,
default: 4,
},
// 动画持续时间(秒)
duration: {
type: Number,
default: 1.4,
},
})
// 计算样式
const containerStyle = computed(() => ({
height: `${props.size * 2}px`,
}))
const dotStyle = computed(() => ({
width: `${props.size}px`,
height: `${props.size}px`,
margin: `0 ${props.spacing}px`,
background: `var(--el-text-color-regular)`,
animationDuration: `${props.duration}s`,
}))
</script>
<style scoped>
.loading-container {
display: flex;
align-items: center;
justify-content: center;
}
.dot {
border-radius: 50%;
display: inline-block;
animation: loading ease-in-out infinite;
}
@keyframes loading {
0% {
opacity: 0.2;
transform: scale(0.8);
}
20% {
opacity: 1;
transform: scale(1.2);
}
40% {
opacity: 0.2;
transform: scale(0.8);
}
100% {
opacity: 0.2;
transform: scale(0.8);
}
}
</style>

View File

@@ -1,24 +1,31 @@
<template>
<div class="mobile-message-reply">
<div class="chat-icon">
<van-image :src="icon"/>
<van-image :src="icon" />
</div>
<div class="chat-item">
<div class="triangle"></div>
<div class="content-box" ref="contentRef">
<div :data-clipboard-text="orgContent" class="content content-mobile" v-html="content"></div>
<div
:data-clipboard-text="orgContent"
class="content content-mobile"
v-html="content"
v-if="content"
></div>
<div class="content content-mobile flex justify-start items-center" v-else>
<span class="mr-2">AI 思考中</span> <Thinking :duration="1.5" />
</div>
</div>
</div>
</div>
</template>
<script setup>
import {nextTick, onMounted, ref} from "vue"
import {showImagePreview} from "vant";
import { onMounted, ref } from 'vue'
import { showImagePreview } from 'vant'
import Thinking from '../Thinking.vue'
const props = defineProps({
content: {
type: String,
@@ -31,8 +38,8 @@ const props = defineProps({
icon: {
type: String,
default: '/images/gpt-icon.png',
}
});
},
})
const contentRef = ref(null)
onMounted(() => {
@@ -43,7 +50,7 @@ onMounted(() => {
}
imgs[i].addEventListener('click', (e) => {
e.stopPropagation()
showImagePreview([imgs[i].src]);
showImagePreview([imgs[i].src])
})
}
})
@@ -221,4 +228,4 @@ onMounted(() => {
}
}
</style>
</style>

View File

@@ -708,15 +708,12 @@ onMounted(() => {
const chatRole = getRoleById(roleId.value)
if (isNewMsg.value && data.type !== 'end') {
const prePrompt = chatData.value[chatData.value.length - 1]?.content
chatData.value.push({
type: 'reply',
id: randString(32),
icon: chatRole['icon'],
prompt: prePrompt,
content: data.body,
})
isNewMsg.value = false
lineBuffer.value = data.body
const reply = chatData.value[chatData.value.length - 1]
if (reply) {
reply['content'] = lineBuffer.value
}
} else if (data.type === 'end') {
// 消息接收完毕
// 追加当前会话到会话列表
@@ -1079,6 +1076,16 @@ const sendMessage = function () {
model: getModelValue(modelID.value),
created_at: new Date().getTime() / 1000,
})
// 添加空回复消息
const _role = getRoleById(roleId.value)
chatData.value.push({
chat_id: chatId,
role_id: roleId.value,
type: 'reply',
id: randString(32),
icon: _role['icon'],
content: '',
})
nextTick(() => {
document

View File

@@ -2,7 +2,12 @@
<div class="container list" v-loading="loading">
<div class="handle-box">
<el-select v-model="query.type" placeholder="类型" class="handle-input">
<el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
<el-option
v-for="item in types"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-button :icon="Search" @click="fetchData">搜索</el-button>
@@ -40,7 +45,7 @@
<el-table-column label="最后使用时间">
<template #default="scope">
<span v-if="scope.row['last_used_at']">{{ scope.row["last_used_at"] }}</span>
<span v-if="scope.row['last_used_at']">{{ scope.row['last_used_at'] }}</span>
<el-tag v-else>未使用</el-tag>
</template>
</el-table-column>
@@ -73,7 +78,13 @@
</el-col>
<el-col :span="12">
<el-select v-model="preset" placeholder="请选择预设" @change="changePreset">
<el-option v-for="item in presets" :value="item" :label="item.label" :key="item.value">{{ item.label }} </el-option>
<el-option
v-for="item in presets"
:value="item"
:label="item.label"
:key="item.value"
>{{ item.label }}
</el-option>
</el-select>
</el-col>
</el-row>
@@ -81,14 +92,24 @@
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="item.type" placeholder="请选择类型">
<el-option v-for="item in types" :value="item.value" :label="item.label" :key="item.value">{{ item.label }} </el-option>
<el-option
v-for="item in types"
:value="item.value"
:label="item.label"
:key="item.value"
>{{ item.label }}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="API KEY" prop="value">
<el-input v-model="item.value" autocomplete="off" />
</el-form-item>
<el-form-item label="API URL" prop="api_url">
<el-input v-model="item.api_url" autocomplete="off" placeholder="只填 BASE URL 即可https://api.openai.com 或者 wss://api.openai.com" />
<el-input
v-model="item.api_url"
autocomplete="off"
placeholder="只填 BASE URL https://api.openai.com 或者完整 URL 如https://api.openai.com/v1/chat/completions"
/>
</el-form-item>
<!-- <el-form-item label="代理地址:" prop="proxy_url">-->
@@ -112,162 +133,162 @@
</template>
<script setup>
import { onMounted, onUnmounted, reactive, ref } from "vue";
import { httpGet, httpPost } from "@/utils/http";
import { ElMessage } from "element-plus";
import { dateFormat, removeArrayItem, substr } from "@/utils/libs";
import { DocumentCopy, Plus, ShoppingCart, Search } from "@element-plus/icons-vue";
import ClipboardJS from "clipboard";
import { httpGet, httpPost } from '@/utils/http'
import { dateFormat, removeArrayItem, substr } from '@/utils/libs'
import { DocumentCopy, Plus, Search, ShoppingCart } from '@element-plus/icons-vue'
import ClipboardJS from 'clipboard'
import { ElMessage } from 'element-plus'
import { onMounted, onUnmounted, reactive, ref } from 'vue'
// 变量定义
const items = ref([]);
const query = ref({ type: "" });
const item = ref({});
const showDialog = ref(false);
const items = ref([])
const query = ref({ type: '' })
const item = ref({})
const showDialog = ref(false)
const rules = reactive({
name: [{ required: true, message: "请输入名称", trigger: "change" }],
type: [{ required: true, message: "请选择用途", trigger: "change" }],
value: [{ required: true, message: "请输入 API KEY 值", trigger: "change" }],
});
name: [{ required: true, message: '请输入名称', trigger: 'change' }],
type: [{ required: true, message: '请选择用途', trigger: 'change' }],
value: [{ required: true, message: '请输入 API KEY 值', trigger: 'change' }],
})
const loading = ref(true);
const formRef = ref(null);
const title = ref("");
const loading = ref(true)
const formRef = ref(null)
const title = ref('')
const types = ref([
{ label: "对话", value: "chat" },
{ label: "Midjourney", value: "mj" },
{ label: "Stable-Diffusion", value: "sd" },
{ label: "DALL-E", value: "dalle" },
{ label: "Suno文生歌", value: "suno" },
{ label: "Luma视频", value: "luma" },
{ label: "可灵视频", value: "keling" },
{ label: "Realtime API", value: "realtime" },
{ label: "语音合成", value: "tts" },
{ label: "其他", value: "other" },
]);
const isEdit = ref(false);
const clipboard = ref(null);
{ label: '对话', value: 'chat' },
{ label: 'Midjourney', value: 'mj' },
{ label: 'Stable-Diffusion', value: 'sd' },
{ label: 'DALL-E', value: 'dalle' },
{ label: 'Suno文生歌', value: 'suno' },
{ label: 'Luma视频', value: 'luma' },
{ label: '可灵视频', value: 'keling' },
{ label: 'Realtime API', value: 'realtime' },
{ label: '语音合成', value: 'tts' },
{ label: '其他', value: 'other' },
])
const isEdit = ref(false)
const clipboard = ref(null)
const presets = ref([
{ label: "GiteeAI", value: "https://ai.gitee.com" },
{ label: "中转01", value: "https://api.geekai.pro" },
{ label: "中转03", value: "https://api.geekai.me" },
{ label: "OpenAI", value: "https://api.openai.com" },
]);
const preset = ref(null);
{ label: 'GiteeAI', value: 'https://ai.gitee.com' },
{ label: '中转01', value: 'https://api.geekai.pro' },
{ label: '中转03', value: 'https://api.geekai.me' },
{ label: 'OpenAI', value: 'https://api.openai.com' },
])
const preset = ref(null)
onMounted(() => {
clipboard.value = new ClipboardJS(".copy-key");
clipboard.value.on("success", () => {
ElMessage.success("复制成功!");
});
clipboard.value = new ClipboardJS('.copy-key')
clipboard.value.on('success', () => {
ElMessage.success('复制成功!')
})
clipboard.value.on("error", () => {
ElMessage.error("复制失败!");
});
clipboard.value.on('error', () => {
ElMessage.error('复制失败!')
})
fetchData();
});
fetchData()
})
onUnmounted(() => {
clipboard.value.destroy();
});
clipboard.value.destroy()
})
const getTypeName = (type) => {
for (let v of types.value) {
if (v.value === type) {
return v.label;
return v.label
}
}
return "";
};
return ''
}
// 获取数据
const fetchData = () => {
httpGet("/api/admin/apikey/list", query.value)
httpGet('/api/admin/apikey/list', query.value)
.then((res) => {
if (res.data) {
// 初始化数据
const arr = res.data;
const arr = res.data
for (let i = 0; i < arr.length; i++) {
arr[i].last_used_at = dateFormat(arr[i].last_used_at);
arr[i].last_used_at = dateFormat(arr[i].last_used_at)
}
items.value = arr;
items.value = arr
}
loading.value = false;
loading.value = false
})
.catch(() => {
ElMessage.error("获取数据失败");
});
};
ElMessage.error('获取数据失败')
})
}
const add = function () {
showDialog.value = true;
title.value = "新增 API KEY";
isEdit.value = false;
showDialog.value = true
title.value = '新增 API KEY'
isEdit.value = false
item.value = {
enabled: true,
api_url: "",
};
};
api_url: '',
}
}
const edit = function (row) {
showDialog.value = true;
title.value = "修改 API KEY";
item.value = row;
isEdit.value = true;
};
showDialog.value = true
title.value = '修改 API KEY'
item.value = row
isEdit.value = true
}
const save = function () {
formRef.value.validate((valid) => {
if (valid) {
showDialog.value = false;
httpPost("/api/admin/apikey/save", item.value)
showDialog.value = false
httpPost('/api/admin/apikey/save', item.value)
.then((res) => {
ElMessage.success("操作成功!");
if (!item.value["id"]) {
const newItem = res.data;
newItem.last_used_at = dateFormat(newItem.last_used_at);
items.value.push(newItem);
ElMessage.success('操作成功!')
if (!item.value['id']) {
const newItem = res.data
newItem.last_used_at = dateFormat(newItem.last_used_at)
items.value.push(newItem)
}
})
.catch((e) => {
ElMessage.error("操作失败," + e.message);
});
ElMessage.error('操作失败,' + e.message)
})
} else {
return false;
return false
}
});
};
})
}
const remove = function (row) {
httpGet("/api/admin/apikey/remove?id=" + row.id)
httpGet('/api/admin/apikey/remove?id=' + row.id)
.then(() => {
ElMessage.success("删除成功!");
ElMessage.success('删除成功!')
items.value = removeArrayItem(items.value, row, (v1, v2) => {
return v1.id === v2.id;
});
return v1.id === v2.id
})
})
.catch((e) => {
ElMessage.error("删除失败:" + e.message);
});
};
ElMessage.error('删除失败:' + e.message)
})
}
const set = (filed, row) => {
httpPost("/api/admin/apikey/set", { id: row.id, filed: filed, value: row[filed] })
httpPost('/api/admin/apikey/set', { id: row.id, filed: filed, value: row[filed] })
.then(() => {
ElMessage.success("操作成功!");
ElMessage.success('操作成功!')
})
.catch((e) => {
ElMessage.error("操作失败:" + e.message);
});
};
ElMessage.error('操作失败:' + e.message)
})
}
const changePreset = (row) => {
item.value.api_url = row.value;
item.value.api_url = row.value
if (!item.value.name) {
item.value.name = row.label;
item.value.name = row.label
}
};
}
</script>
<style lang="stylus" scoped>

View File

@@ -10,7 +10,14 @@
<h1 class="header">登录 {{ title }}</h1>
<div class="content">
<el-input v-model="username" placeholder="请输入用户名" size="large" autocomplete="off" autofocus @keyup.enter="login">
<el-input
v-model="username"
placeholder="请输入用户名"
size="large"
autocomplete="off"
autofocus
@keyup.enter="login"
>
<template #prefix>
<el-icon>
<UserFilled />
@@ -18,7 +25,14 @@
</template>
</el-input>
<el-input v-model="password" placeholder="请输入密码" size="large" show-password autocomplete="off" @keyup.enter="login">
<el-input
v-model="password"
placeholder="请输入密码"
size="large"
show-password
autocomplete="off"
@keyup.enter="login"
>
<template #prefix>
<el-icon>
<Lock />
@@ -27,7 +41,9 @@
</el-input>
<el-row class="btn-row">
<el-button class="login-btn" size="large" type="primary" @click="login">登录</el-button>
<el-button class="login-btn" size="large" type="primary" @click="login"
>登录</el-button
>
</el-row>
</div>
</div>
@@ -40,57 +56,57 @@
</template>
<script setup>
import { ref } from "vue";
import { Lock, UserFilled } from "@element-plus/icons-vue";
import { httpPost } from "@/utils/http";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import FooterBar from "@/components/FooterBar.vue";
import { setAdminToken } from "@/store/session";
import { checkAdminSession, getSystemInfo } from "@/store/cache";
import Captcha from "@/components/Captcha.vue";
import Captcha from '@/components/Captcha.vue'
import FooterBar from '@/components/FooterBar.vue'
import { checkAdminSession, getSystemInfo } from '@/store/cache'
import { setAdminToken } from '@/store/session'
import { httpPost } from '@/utils/http'
import { Lock, UserFilled } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter();
const title = ref("Geek-AI Console");
const username = ref(process.env.VUE_APP_ADMIN_USER);
const password = ref(process.env.VUE_APP_ADMIN_PASS);
const logo = ref("");
const enableVerify = ref(false);
const captchaRef = ref(null);
const router = useRouter()
const title = ref('Geek-AI Console')
const username = ref(process.env.VUE_APP_ADMIN_USER)
const password = ref(process.env.VUE_APP_ADMIN_PASS)
const logo = ref('')
const enableVerify = ref(false)
const captchaRef = ref(null)
checkAdminSession()
.then(() => {
router.push("/admin");
router.push('/admin')
})
.catch(() => {});
.catch(() => {})
// 加载系统配置
getSystemInfo()
.then((res) => {
title.value = res.data.admin_title;
logo.value = res.data.logo;
enableVerify.value = res.data["enabled_verify"];
title.value = res.data.admin_title
logo.value = res.data.logo
enableVerify.value = res.data['enabled_verify']
})
.catch((e) => {
ElMessage.error("加载系统配置失败: " + e.message);
});
ElMessage.error('加载系统配置失败: ' + e.message)
})
const login = function () {
if (username.value === "") {
return ElMessage.error("请输入用户名");
if (username.value === '') {
return ElMessage.error('请输入用户名')
}
if (password.value === "") {
return ElMessage.error("请输入密码");
if (password.value === '') {
return ElMessage.error('请输入密码')
}
if (enableVerify.value) {
captchaRef.value.loadCaptcha();
captchaRef.value.loadCaptcha()
} else {
doLogin({});
doLogin({})
}
};
}
const doLogin = function (verifyData) {
httpPost("/api/admin/login", {
httpPost('/api/admin/login', {
username: username.value.trim(),
password: password.value.trim(),
key: verifyData.key,
@@ -98,13 +114,13 @@ const doLogin = function (verifyData) {
x: verifyData.x,
})
.then((res) => {
setAdminToken(res.data.token);
router.push("/admin");
setAdminToken(res.data.token)
router.push('/admin')
})
.catch((e) => {
ElMessage.error("登录失败," + e.message);
});
};
ElMessage.error('登录失败,' + e.message)
})
}
</script>
<style lang="stylus" scoped>
@@ -114,7 +130,9 @@ const doLogin = function (verifyData) {
right 0
top 0
bottom 0
background-color #091519
background #8d4bbb
// background-image url("~@/assets/img/transparent-bg.png")
// background-repeat:repeat;
background-image url("~@/assets/img/admin-login-bg.jpg")
background-size cover
background-position center
@@ -145,7 +163,7 @@ const doLogin = function (verifyData) {
padding 40px;
color #ffffff
border-radius 10px;
background rgba(0, 0, 0, 0.3)
background rgba(0, 0, 0, 0.4)
.logo {
text-align center

View File

@@ -20,14 +20,33 @@
</template>
</van-nav-bar>
<van-share-sheet v-model:show="showShare" title="立即分享给好友" :options="shareOptions" @select="shareChat" />
<van-share-sheet
v-model:show="showShare"
title="立即分享给好友"
:options="shareOptions"
@select="shareChat"
/>
<div class="chat-list-wrapper">
<div id="message-list-box" :style="{ height: winHeight + 'px' }" class="message-list-box">
<van-list v-model:error="error" :finished="finished" error-text="请求失败点击重新加载" @load="onLoad">
<van-list
v-model:error="error"
:finished="finished"
error-text="请求失败点击重新加载"
@load="onLoad"
>
<van-cell v-for="item in chatData" :key="item" :border="false" class="message-line">
<chat-prompt v-if="item.type === 'prompt'" :content="item.content" :icon="item.icon" />
<chat-reply v-else-if="item.type === 'reply'" :content="item.content" :icon="item.icon" :org-content="item.orgContent" />
<chat-prompt
v-if="item.type === 'prompt'"
:content="item.content"
:icon="item.icon"
/>
<chat-reply
v-else-if="item.type === 'reply'"
:content="item.content"
:icon="item.icon"
:org-content="item.orgContent"
/>
</van-cell>
</van-list>
</div>
@@ -61,7 +80,9 @@
</div>
</div>
<button id="copy-link-btn" style="display: none" :data-clipboard-text="url">复制链接地址</button>
<button id="copy-link-btn" style="display: none" :data-clipboard-text="url">
复制链接地址
</button>
<!-- <van-overlay :show="showMic" z-index="100">-->
<!-- <div class="mic-wrapper">-->
@@ -78,10 +99,14 @@
</div>
<van-popup v-model:show="showPicker" position="bottom" class="popup">
<van-picker :columns="columns" v-model="selectedValues"
title="选择模型和角色"
@change="onChange"
@cancel="showPicker = false" @confirm="newChat">
<van-picker
:columns="columns"
v-model="selectedValues"
title="选择模型和角色"
@change="onChange"
@cancel="showPicker = false"
@confirm="newChat"
>
<template #option="item">
<div class="picker-option">
<van-image v-if="item.icon" :src="item.icon" fit="cover" round />
@@ -93,439 +118,359 @@
</template>
<script setup>
import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
import { showImagePreview, showNotify, showToast } from "vant";
import { useRouter } from "vue-router";
import { processContent, randString, renderInputText, UUID } from "@/utils/libs";
import { httpGet } from "@/utils/http";
import hl from "highlight.js";
import "highlight.js/styles/a11y-dark.css";
import ChatPrompt from "@/components/mobile/ChatPrompt.vue";
import ChatReply from "@/components/mobile/ChatReply.vue";
import { checkSession, getClientId } from "@/store/cache";
import Clipboard from "clipboard";
import { showMessageError } from "@/utils/dialog";
import { useSharedStore } from "@/store/sharedata";
import emoji from "markdown-it-emoji";
import mathjaxPlugin from "markdown-it-mathjax3";
import MarkdownIt from "markdown-it";
const winHeight = ref(0);
const navBarRef = ref(null);
const bottomBarRef = ref(null);
const router = useRouter();
import ChatPrompt from '@/components/mobile/ChatPrompt.vue'
import ChatReply from '@/components/mobile/ChatReply.vue'
import { checkSession, getClientId } from '@/store/cache'
import { useSharedStore } from '@/store/sharedata'
import { showMessageError } from '@/utils/dialog'
import { httpGet } from '@/utils/http'
import { processContent, randString, renderInputText, UUID } from '@/utils/libs'
import Clipboard from 'clipboard'
import hl from 'highlight.js'
import 'highlight.js/styles/a11y-dark.css'
import MarkdownIt from 'markdown-it'
import emoji from 'markdown-it-emoji'
import mathjaxPlugin from 'markdown-it-mathjax3'
import { showImagePreview, showNotify, showToast } from 'vant'
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
const winHeight = ref(0)
const navBarRef = ref(null)
const bottomBarRef = ref(null)
const router = useRouter()
const roles = ref([]);
const roleId = ref(parseInt(router.currentRoute.value.query["role_id"]));
const role = ref({});
const models = ref([]);
const modelId = ref(parseInt(router.currentRoute.value.query["model_id"]));
const modelValue = ref("");
const title = ref(router.currentRoute.value.query["title"]);
const chatId = ref(router.currentRoute.value.query["chat_id"]);
const loginUser = ref(null);
const roles = ref([])
const roleId = ref(parseInt(router.currentRoute.value.query['role_id']))
const role = ref({})
const models = ref([])
const modelId = ref(parseInt(router.currentRoute.value.query['model_id']))
const modelValue = ref('')
const title = ref(router.currentRoute.value.query['title'])
const chatId = ref(router.currentRoute.value.query['chat_id'])
const loginUser = ref(null)
// const showMic = ref(false)
const showPicker = ref(false);
const columns = ref([roles.value, models.value]);
const selectedValues = ref([roleId.value, modelId.value]);
const showPicker = ref(false)
const columns = ref([roles.value, models.value])
const selectedValues = ref([roleId.value, modelId.value])
checkSession()
.then((user) => {
loginUser.value = user;
loginUser.value = user
})
.catch(() => {
router.push("/login");
});
router.push('/login')
})
const loadModels = () => {
// 加载模型
httpGet("/api/model/list")
httpGet('/api/model/list')
.then((res) => {
models.value = res.data;
models.value = res.data
if (!modelId.value) {
modelId.value = models.value[0].id;
modelId.value = models.value[0].id
}
for (let i = 0; i < models.value.length; i++) {
models.value[i].text = models.value[i].name;
models.value[i].mValue = models.value[i].value;
models.value[i].value = models.value[i].id;
models.value[i].text = models.value[i].name
models.value[i].mValue = models.value[i].value
models.value[i].value = models.value[i].id
}
modelValue.value = getModelName(modelId.value);
modelValue.value = getModelName(modelId.value)
// 加载角色列表
httpGet(`/api/app/list/user`, { id: roleId.value })
.then((res) => {
roles.value = res.data;
roles.value = res.data
if (!roleId.value) {
roleId.value = roles.value[0]["id"];
roleId.value = roles.value[0]['id']
}
// build data for role picker
for (let i = 0; i < roles.value.length; i++) {
roles.value[i].text = roles.value[i].name;
roles.value[i].value = roles.value[i].id;
roles.value[i].helloMsg = roles.value[i].hello_msg;
roles.value[i].text = roles.value[i].name
roles.value[i].value = roles.value[i].id
roles.value[i].helloMsg = roles.value[i].hello_msg
}
role.value = getRoleById(roleId.value);
columns.value = [roles.value, models.value];
selectedValues.value = [roleId.value, modelId.value];
loadChatHistory();
role.value = getRoleById(roleId.value)
columns.value = [roles.value, models.value]
selectedValues.value = [roleId.value, modelId.value]
loadChatHistory()
})
.catch((e) => {
showNotify({ type: "danger", message: "获取聊天角色失败: " + e.messages });
});
showNotify({ type: 'danger', message: '获取聊天角色失败: ' + e.messages })
})
})
.catch((e) => {
showNotify({ type: "danger", message: "加载模型失败: " + e.message });
});
};
showNotify({ type: 'danger', message: '加载模型失败: ' + e.message })
})
}
if (chatId.value) {
httpGet(`/api/chat/detail?chat_id=${chatId.value}`)
.then((res) => {
title.value = res.data.title;
modelId.value = res.data.model_id;
roleId.value = res.data.role_id;
loadModels();
title.value = res.data.title
modelId.value = res.data.model_id
roleId.value = res.data.role_id
loadModels()
})
.catch(() => {
loadModels();
});
loadModels()
})
} else {
title.value = "新建对话";
chatId.value = UUID();
loadModels();
title.value = '新建对话'
chatId.value = UUID()
loadModels()
}
const chatData = ref([]);
const loading = ref(false);
const finished = ref(false);
const error = ref(false);
const store = useSharedStore();
const url = ref(location.protocol + "//" + location.host + "/mobile/chat/export?chat_id=" + chatId.value);
const chatData = ref([])
const loading = ref(false)
const finished = ref(false)
const error = ref(false)
const store = useSharedStore()
const url = ref(
location.protocol + '//' + location.host + '/mobile/chat/export?chat_id=' + chatId.value
)
const md = new MarkdownIt({
breaks: true,
html: true,
linkify: true,
typographer: true,
highlight: function (str, lang) {
const codeIndex = parseInt(Date.now()) + Math.floor(Math.random() * 10000000);
const codeIndex = parseInt(Date.now()) + Math.floor(Math.random() * 10000000)
// 显示复制代码按钮
const copyBtn = `<span class="copy-code-mobile" data-clipboard-action="copy" data-clipboard-target="#copy-target-${codeIndex}">复制</span>
<textarea style="position: absolute;top: -9999px;left: -9999px;z-index: -9999;" id="copy-target-${codeIndex}">${str.replace(
/<\/textarea>/g,
"&lt;/textarea>"
)}</textarea>`;
'&lt;/textarea>'
)}</textarea>`
if (lang && hl.getLanguage(lang)) {
const langHtml = `<span class="lang-name">${lang}</span>`;
const langHtml = `<span class="lang-name">${lang}</span>`
// 处理代码高亮
const preCode = hl.highlight(lang, str, true).value;
const preCode = hl.highlight(lang, str, true).value
// 将代码包裹在 pre 中
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn} ${langHtml}</pre>`;
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn} ${langHtml}</pre>`
}
// 处理代码高亮
const preCode = md.utils.escapeHtml(str);
const preCode = md.utils.escapeHtml(str)
// 将代码包裹在 pre 中
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn}</pre>`;
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn}</pre>`
},
});
md.use(mathjaxPlugin);
md.use(emoji);
})
md.use(mathjaxPlugin)
md.use(emoji)
onMounted(() => {
winHeight.value = window.innerHeight - navBarRef.value.$el.offsetHeight - bottomBarRef.value.$el.offsetHeight - 70;
winHeight.value =
window.innerHeight - navBarRef.value.$el.offsetHeight - bottomBarRef.value.$el.offsetHeight - 70
const clipboard = new Clipboard(".content-mobile,.copy-code-mobile,#copy-link-btn");
clipboard.on("success", (e) => {
e.clearSelection();
showNotify({ type: "success", message: "复制成功", duration: 1000 });
});
clipboard.on("error", () => {
showNotify({ type: "danger", message: "复制失败", duration: 2000 });
});
const clipboard = new Clipboard('.content-mobile,.copy-code-mobile,#copy-link-btn')
clipboard.on('success', (e) => {
e.clearSelection()
showNotify({ type: 'success', message: '复制成功', duration: 1000 })
})
clipboard.on('error', () => {
showNotify({ type: 'danger', message: '复制失败', duration: 2000 })
})
store.addMessageHandler("chat", (data) => {
if (data.channel !== "chat" || data.clientId !== getClientId()) {
return;
store.addMessageHandler('chat', (data) => {
if (data.channel !== 'chat' || data.clientId !== getClientId()) {
return
}
if (data.type === "error") {
showMessageError(data.body);
return;
if (data.type === 'error') {
showMessageError(data.body)
return
}
if (isNewMsg.value) {
chatData.value.push({
type: "reply",
id: randString(32),
icon: role.value.icon,
content: data.body,
});
if (!title.value) {
title.value = previousText.value;
title.value = previousText.value
}
lineBuffer.value = data.body;
isNewMsg.value = false;
} else if (data.type === "end") {
lineBuffer.value = data.body
isNewMsg.value = false
const reply = chatData.value[chatData.value.length - 1]
if (reply) {
reply['content'] = lineBuffer.value
}
} else if (data.type === 'end') {
// 消息接收完毕
enableInput();
lineBuffer.value = ""; // 清空缓冲
isNewMsg.value = true;
enableInput()
lineBuffer.value = '' // 清空缓冲
isNewMsg.value = true
} else {
lineBuffer.value += data.body;
const reply = chatData.value[chatData.value.length - 1];
reply["orgContent"] = lineBuffer.value;
reply["content"] = md.render(processContent(lineBuffer.value));
lineBuffer.value += data.body
const reply = chatData.value[chatData.value.length - 1]
reply['orgContent'] = lineBuffer.value
reply['content'] = md.render(processContent(lineBuffer.value))
nextTick(() => {
hl.configure({ ignoreUnescapedHTML: true });
const lines = document.querySelectorAll(".message-line");
const blocks = lines[lines.length - 1].querySelectorAll("pre code");
hl.configure({ ignoreUnescapedHTML: true })
const lines = document.querySelectorAll('.message-line')
const blocks = lines[lines.length - 1].querySelectorAll('pre code')
blocks.forEach((block) => {
hl.highlightElement(block);
});
scrollListBox();
hl.highlightElement(block)
})
scrollListBox()
const items = document.querySelectorAll(".message-line");
const imgs = items[items.length - 1].querySelectorAll("img");
const items = document.querySelectorAll('.message-line')
const imgs = items[items.length - 1].querySelectorAll('img')
for (let i = 0; i < imgs.length; i++) {
if (!imgs[i].src) {
continue;
continue
}
imgs[i].addEventListener("click", (e) => {
e.stopPropagation();
showImagePreview([imgs[i].src]);
});
imgs[i].addEventListener('click', (e) => {
e.stopPropagation()
showImagePreview([imgs[i].src])
})
}
});
})
}
});
});
})
})
onUnmounted(() => {
store.removeMessageHandler("chat");
});
store.removeMessageHandler('chat')
})
const newChat = (item) => {
showPicker.value = false;
const options = item.selectedOptions;
roleId.value = options[0].value;
modelId.value = options[1].value;
modelValue.value = getModelName(modelId.value);
chatId.value = UUID();
chatData.value = [];
role.value = getRoleById(roleId.value);
title.value = "新建对话";
loadChatHistory();
};
showPicker.value = false
const options = item.selectedOptions
roleId.value = options[0].value
modelId.value = options[1].value
modelValue.value = getModelName(modelId.value)
chatId.value = UUID()
chatData.value = []
role.value = getRoleById(roleId.value)
title.value = '新建对话'
loadChatHistory()
}
const onLoad = () => {
// checkSession().then(() => {
// connect()
// }).catch(() => {
// })
};
}
const loadChatHistory = () => {
httpGet("/api/chat/history?chat_id=" + chatId.value)
httpGet('/api/chat/history?chat_id=' + chatId.value)
.then((res) => {
const role = getRoleById(roleId.value);
const role = getRoleById(roleId.value)
// 加载状态结束
finished.value = true;
const data = res.data;
finished.value = true
const data = res.data
if (data.length === 0) {
chatData.value.push({
type: "reply",
type: 'reply',
id: randString(32),
icon: role.icon,
content: role.hello_msg,
orgContent: role.hello_msg,
});
return;
})
return
}
for (let i = 0; i < data.length; i++) {
if (data[i].type === "prompt") {
chatData.value.push(data[i]);
continue;
if (data[i].type === 'prompt') {
chatData.value.push(data[i])
continue
}
data[i].orgContent = data[i].content;
data[i].content = md.render(processContent(data[i].content));
chatData.value.push(data[i]);
data[i].orgContent = data[i].content
data[i].content = md.render(processContent(data[i].content))
chatData.value.push(data[i])
}
nextTick(() => {
hl.configure({ ignoreUnescapedHTML: true });
const blocks = document.querySelector("#message-list-box").querySelectorAll("pre code");
hl.configure({ ignoreUnescapedHTML: true })
const blocks = document.querySelector('#message-list-box').querySelectorAll('pre code')
blocks.forEach((block) => {
hl.highlightElement(block);
});
hl.highlightElement(block)
})
scrollListBox();
});
scrollListBox()
})
})
.catch(() => {
error.value = true;
});
};
error.value = true
})
}
// 创建 socket 连接
const prompt = ref("");
const showStopGenerate = ref(false); // 停止生成
const showReGenerate = ref(false); // 重新生成
const previousText = ref(""); // 上一次提问
const lineBuffer = ref(""); // 输出缓冲行
const canSend = ref(true);
const isNewMsg = ref(true);
const stream = ref(store.chatStream);
const prompt = ref('')
const showStopGenerate = ref(false) // 停止生成
const showReGenerate = ref(false) // 重新生成
const previousText = ref('') // 上一次提问
const lineBuffer = ref('') // 输出缓冲行
const canSend = ref(true)
const isNewMsg = ref(true)
const stream = ref(store.chatStream)
watch(
() => store.chatStream,
(newValue) => {
stream.value = newValue;
stream.value = newValue
}
);
// const connect = function () {
// // 初始化 WebSocket 对象
// const _sessionId = getSessionId();
// let host = process.env.VUE_APP_WS_HOST
// if (host === '') {
// if (location.protocol === 'https:') {
// host = 'wss://' + location.host;
// } else {
// host = 'ws://' + location.host;
// }
// }
// const _socket = new WebSocket(host + `/api/chat/new?session_id=${_sessionId}&role_id=${roleId.value}&chat_id=${chatId.value}&model_id=${modelId.value}&token=${getUserToken()}`);
// _socket.addEventListener('open', () => {
// loading.value = false
// previousText.value = '';
// canSend.value = true;
//
// if (loadHistory.value) { // 加载历史消息
// loadChatHistory()
// }
// });
//
// _socket.addEventListener('message', event => {
// if (event.data instanceof Blob) {
// const reader = new FileReader();
// reader.readAsText(event.data, "UTF-8");
// reader.onload = () => {
// const data = JSON.parse(String(reader.result));
// if (data.type === 'error') {
// showMessageError(data.message)
// return
// }
//
// if (isNewMsg.value && data.type !== 'end') {
// chatData.value.push({
// type: "reply",
// id: randString(32),
// icon: role.value.icon,
// content: data.content
// });
// if (!title.value) {
// title.value = previousText.value
// }
// lineBuffer.value = data.content;
// isNewMsg.value = false
// } else if (data.type === 'end') { // 消息接收完毕
// enableInput()
// lineBuffer.value = ''; // 清空缓冲
// isNewMsg.value = true
// } else {
// lineBuffer.value += data.content;
// const reply = chatData.value[chatData.value.length - 1]
// reply['orgContent'] = lineBuffer.value;
// reply['content'] = md.render(processContent(lineBuffer.value));
//
// nextTick(() => {
// hl.configure({ignoreUnescapedHTML: true})
// const lines = document.querySelectorAll('.message-line');
// const blocks = lines[lines.length - 1].querySelectorAll('pre code');
// blocks.forEach((block) => {
// hl.highlightElement(block)
// })
// scrollListBox()
//
// const items = document.querySelectorAll('.message-line')
// const imgs = items[items.length - 1].querySelectorAll('img')
// for (let i = 0; i < imgs.length; i++) {
// if (!imgs[i].src) {
// continue
// }
// imgs[i].addEventListener('click', (e) => {
// e.stopPropagation()
// showImagePreview([imgs[i].src]);
// })
// }
// })
// }
//
// };
// }
//
// });
//
// _socket.addEventListener('close', () => {
// // 停止发送消息
// canSend.value = true
// loadHistory.value = false
// // 重连
// connect()
// });
//
// socket.value = _socket;
// }
)
const disableInput = (force) => {
canSend.value = false;
showReGenerate.value = false;
showStopGenerate.value = !force;
};
canSend.value = false
showReGenerate.value = false
showStopGenerate.value = !force
}
const enableInput = () => {
canSend.value = true;
showReGenerate.value = previousText.value !== "";
showStopGenerate.value = false;
};
canSend.value = true
showReGenerate.value = previousText.value !== ''
showStopGenerate.value = false
}
// 将聊天框的滚动条滑动到最底部
const scrollListBox = () => {
document.getElementById("message-list-box").scrollTo(0, document.getElementById("message-list-box").scrollHeight + 46);
};
document
.getElementById('message-list-box')
.scrollTo(0, document.getElementById('message-list-box').scrollHeight + 46)
}
const sendMessage = () => {
if (canSend.value === false) {
showToast("AI 正在作答中,请稍后...");
return;
showToast('AI 正在作答中,请稍后...')
return
}
if (store.socket.conn.readyState !== WebSocket.OPEN) {
showToast("连接断开,正在重连...");
return;
showToast('连接断开,正在重连...')
return
}
if (prompt.value.trim().length === 0) {
showToast("请输入需要 AI 回答的问题");
return false;
showToast('请输入需要 AI 回答的问题')
return false
}
// 追加消息
chatData.value.push({
type: "prompt",
type: 'prompt',
id: randString(32),
icon: loginUser.value.avatar,
content: renderInputText(prompt.value),
created_at: new Date().getTime(),
});
})
// 添加空回复消息
const _role = getRoleById(roleId.value)
chatData.value.push({
chat_id: chatId,
role_id: roleId.value,
type: 'reply',
id: randString(32),
icon: _role['icon'],
content: '',
})
nextTick(() => {
scrollListBox();
});
scrollListBox()
})
disableInput(false);
disableInput(false)
store.socket.conn.send(
JSON.stringify({
channel: "chat",
type: "text",
channel: 'chat',
type: 'text',
body: {
role_id: roleId.value,
model_id: modelId.value,
@@ -534,33 +479,33 @@ const sendMessage = () => {
stream: stream.value,
},
})
);
previousText.value = prompt.value;
prompt.value = "";
return true;
};
)
previousText.value = prompt.value
prompt.value = ''
return true
}
const stopGenerate = () => {
showStopGenerate.value = false;
httpGet("/api/chat/stop?session_id=" + getClientId()).then(() => {
enableInput();
});
};
showStopGenerate.value = false
httpGet('/api/chat/stop?session_id=' + getClientId()).then(() => {
enableInput()
})
}
const reGenerate = () => {
disableInput(false);
const text = "重新生成上述问题的答案:" + previousText.value;
disableInput(false)
const text = '重新生成上述问题的答案:' + previousText.value
// 追加消息
chatData.value.push({
type: "prompt",
type: 'prompt',
id: randString(32),
icon: loginUser.value.avatar,
content: renderInputText(text),
});
})
store.socket.conn.send(
JSON.stringify({
channel: "chat",
type: "text",
channel: 'chat',
type: 'text',
body: {
role_id: roleId.value,
model_id: modelId.value,
@@ -569,44 +514,52 @@ const reGenerate = () => {
stream: stream.value,
},
})
);
};
)
}
const showShare = ref(false);
const showShare = ref(false)
const shareOptions = [
{ name: "微信", icon: "wechat" },
{ name: "复制链接", icon: "link" },
];
{ name: '微信', icon: 'wechat' },
{ name: '复制链接', icon: 'link' },
]
const shareChat = (option) => {
showShare.value = false;
if (option.icon === "wechat") {
showToast({ message: "当前会话已经导出,请通过浏览器或者微信的自带分享功能分享给好友", duration: 5000 });
showShare.value = false
if (option.icon === 'wechat') {
showToast({
message: '当前会话已经导出,请通过浏览器或者微信的自带分享功能分享给好友',
duration: 5000,
})
router.push({
path: "/mobile/chat/export",
query: { title: title.value, chat_id: chatId.value, role: role.value.name, model: modelValue.value },
});
} else if (option.icon === "link") {
document.getElementById("copy-link-btn").click();
path: '/mobile/chat/export',
query: {
title: title.value,
chat_id: chatId.value,
role: role.value.name,
model: modelValue.value,
},
})
} else if (option.icon === 'link') {
document.getElementById('copy-link-btn').click()
}
};
}
const getRoleById = function (rid) {
for (let i = 0; i < roles.value.length; i++) {
if (roles.value[i]["id"] === rid) {
return roles.value[i];
if (roles.value[i]['id'] === rid) {
return roles.value[i]
}
}
return null;
};
return null
}
const getModelName = (model_id) => {
for (let i = 0; i < models.value.length; i++) {
if (models.value[i].id === model_id) {
return models.value[i].text;
return models.value[i].text
}
}
return "";
};
return ''
}
// // eslint-disable-next-line no-undef
// const recognition = new webkitSpeechRecognition() || SpeechRecognition();
@@ -638,11 +591,11 @@ const onChange = (item) => {
const selectedValues = item.selectedOptions
if (selectedValues[0].model_id) {
for (let i = 0; i < columns.value[1].length; i++) {
columns.value[1][i].disabled = columns.value[1][i].value !== selectedValues[0].model_id;
columns.value[1][i].disabled = columns.value[1][i].value !== selectedValues[0].model_id
}
} else {
for (let i = 0; i < columns.value[1].length; i++) {
columns.value[1][i].disabled = false;
columns.value[1][i].disabled = false
}
}
}