Skip to content

Commit 21bb7de

Browse files
committed
feat: add VIP rank icons and refine VIP page styling
1 parent b1efe2f commit 21bb7de

118 files changed

Lines changed: 1860 additions & 278 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ _delete_.*
2222
/AGENTS.md
2323
/.github/
2424
/.agents
25+
26+
# OpenCode
27+
_temp/
28+
DEV_*.md

module/AdminManager/Docs/release.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [Unreleased]
2+
3+
- 优化:多语言管理菜单显示优化
4+
5+
---
6+
17
## 1.8.0 调用命令升级,日志优化显示
28

39
- 新增:系统升级调用命令容错处理

module/AdminManager/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"title": "管理员基础框架",
1414
"version": "1.8.0",
1515
"author": "ModStart",
16-
"modstartVersion": ">=3.3.0",
16+
"modstartVersion": ">=5.0.0",
1717
"description": "提供基于管理员角色、管理员、管理日志基础功能"
1818
}

module/AigcBase/Admin/Controller/AigcKeyPoolController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ public function config(AdminConfigBuilder $builder)
164164
$builder->useDialog();
165165
$builder->pageTitle('功能设置');
166166
$builder->switch('AigcBase_AdminRichEditorEnable', '后台富文本编辑器AI功能')->defaultValue(false);
167-
$builder->select('AigcBase_AdminRichEditorDriver', '后台富文本编辑器AI驱动')->options(AigcChatProvider::modelMap());
168-
$builder->select('AigcBase_AdminDefaultChatDriver', '后台默认AI对话驱动')->options(AigcChatProvider::modelMap());
167+
$builder->select('AigcBase_AdminRichEditorDriver', '后台富文本编辑器AI驱动')->options(AigcKeyPoolUtil::configuredChatModelMap());
168+
$builder->select('AigcBase_AdminDefaultChatDriver', '后台默认AI对话驱动')->options(AigcKeyPoolUtil::configuredChatModelMap());
169169
$builder->formClass('wide-lg');
170170
$builder->disableBoxWrap(true);
171171
return $builder->perform();

module/AigcBase/Docs/module/content.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@
2121

2222
> 以上AI驱动需要在后台模块进行自定义安装
2323
24+
25+
## 模块入口
26+
27+
- `/aigc/distribution` AI分发
28+
2429
{ADMIN_MENUS}

module/AigcBase/Docs/release.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## [Unreleased]
2+
3+
- 优化:将中间件检查方式从 class_exists 改为 file_exists,提升系统兼容性
4+
5+
---
6+
7+
## 1.5.0 新增 AigcChatUtil 工具类与模型配置优化
8+
9+
- 新增:AigcChatUtil 工具类,支持通过系统配置调用 AI 对话,提供 chat() 和 chatText() 方法
10+
- 新增:AigcKeyPoolUtil 新增 configuredChatModelMap() 方法,仅返回已配置的 AI 模型选项
11+
- 优化:后台 AI 驱动下拉选项改为仅显示已配置的模型
12+
- 优化:chatText() 方法增加 markdown 选项并自动去除 AI 返回内容中的 HTML 标签
13+
14+
- 优化:多语言管理菜单显示优化
15+
---
16+
117
## 1.4.5 新增支持 systemPrompt 配置,支持系统级提示词设置
218

319
- 新增:支持 systemPrompt 配置,支持系统级提示词设置
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
4+
namespace Module\AigcBase\Util;
5+
6+
7+
use ModStart\Core\Exception\BizException;
8+
use ModStart\Core\Input\Response;
9+
use Module\AigcBase\Provider\AbstractAigcChatProvider;
10+
use Module\AigcBase\Provider\AigcChatProvider;
11+
12+
class AigcChatUtil
13+
{
14+
/**
15+
* 调用AI对话
16+
*
17+
* @param string $systemPrompt 系统提示词
18+
* @param string $userPrompt 用户消息
19+
* @param array $option 选项
20+
* - driver: 直接指定驱动全名(优先级最高)
21+
* - driverKey: 从配置读取驱动的 config key,默认 AigcBase_AdminDefaultChatDriver
22+
* @return array Response格式
23+
* @throws BizException
24+
*/
25+
public static function chat($systemPrompt, $userPrompt, $option = [])
26+
{
27+
$driver = isset($option['driver']) ? $option['driver'] : null;
28+
if (empty($driver)) {
29+
$driverKey = isset($option['driverKey']) ? $option['driverKey'] : 'AigcBase_AdminDefaultChatDriver';
30+
$driver = modstart_config($driverKey);
31+
}
32+
if (!$driver) {
33+
BizException::throws('机器人没有配置,请在 后台→系统设置→AI平台对接→功能设置 中配置');
34+
}
35+
/** @var AbstractAigcChatProvider $provider */
36+
$provider = AigcChatProvider::getByFullName($driver);
37+
if (empty($provider)) {
38+
BizException::throws('机器人没有配置');
39+
}
40+
$chatOption = array_merge($option, [
41+
'systemPrompt' => $systemPrompt,
42+
'markdown' => false,
43+
]);
44+
unset($chatOption['driver']);
45+
unset($chatOption['driverKey']);
46+
$ret = $provider->chat(uniqid('chat_', true), $userPrompt, $chatOption);
47+
return $ret;
48+
}
49+
50+
/**
51+
* 调用AI对话并返回文本内容
52+
*
53+
* @param string $systemPrompt 系统提示词
54+
* @param string $userPrompt 用户消息
55+
* @param array $option 选项(同 chat())
56+
* @return string
57+
* @throws BizException
58+
*/
59+
public static function chatText($systemPrompt, $userPrompt, $option = [])
60+
{
61+
$ret = self::chat($systemPrompt, $userPrompt, array_merge($option, ['markdown' => true]));
62+
if (!Response::isSuccess($ret)) {
63+
BizException::throws('AI对话失败:' . (isset($ret['msg']) ? $ret['msg'] : '未知错误'));
64+
}
65+
if (!empty($ret['data']['isError'])) {
66+
BizException::throws('AI对话失败');
67+
}
68+
$content = isset($ret['data']['msg']['content']) ? $ret['data']['msg']['content'] : '';
69+
return trim(strip_tags($content));
70+
}
71+
}

module/AigcBase/Util/AigcKeyPoolUtil.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use ModStart\Core\Dao\ModelUtil;
99
use ModStart\Core\Util\ArrayUtil;
1010
use Module\AigcBase\Model\AigcKeyPool;
11+
use Module\AigcBase\Provider\AigcChatProvider;
12+
use Module\AigcBase\Provider\AigcProvider;
1113
use Module\AigcBase\Type\AigcKeyPoolStatus;
1214
use Module\Vendor\Util\CacheUtil;
1315

@@ -81,4 +83,32 @@ public static function markFail($keyPool)
8183
self::markEnd($keyPool, false);
8284
}
8385

86+
public static function configuredChatModelMap()
87+
{
88+
$records = self::all();
89+
$result = [];
90+
foreach ($records as $record) {
91+
$model = !empty($record['param']['model']) ? $record['param']['model'] : 'default';
92+
$key = $record['type'] . ':' . $model;
93+
94+
try {
95+
$provider = AigcProvider::getByName($record['type']);
96+
if ($provider) {
97+
$models = $provider->models();
98+
if (isset($models[$model])) {
99+
// 使用 provider 的 models() 中的显示名
100+
$result[$key] = $provider->title() . '-' . $models[$model];
101+
} else {
102+
// model 不在列表中(可能是动态输入的值),直接使用 model 名
103+
$result[$key] = $model;
104+
}
105+
}
106+
} catch (\Exception $e) {
107+
// 异常情况,使用 model 作为显示名
108+
$result[$key] = $model;
109+
}
110+
}
111+
return $result;
112+
}
113+
84114
}

module/AigcBase/Web/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/* @var \Illuminate\Routing\Router $router */
33
$middlewares = [];
4-
if (class_exists(\Module\Member\Middleware\WebAuthMiddleware::class)) {
4+
if (file_exists(base_path('module/Member/Middleware/WebAuthMiddleware.php'))) {
55
$middlewares[] = \Module\Member\Middleware\WebAuthMiddleware::class;
66
}
77
$router->group([

module/AigcBase/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"AigcChatXunfei",
3333
"AigcChatZhipuAi"
3434
],
35-
"version": "1.4.5",
36-
"modstartVersion": ">=4.1.0",
35+
"version": "1.5.0",
36+
"modstartVersion": ">=5.0.0",
3737
"author": "ModStart",
3838
"description": "提供AI基础框架包,支持各种模型接入",
3939
"providers": [],

0 commit comments

Comments
 (0)