mirror of
https://github.com/kuaifan/dootask.git
synced 2026-07-21 05:28:06 +00:00
feat(ai-bot): 增加 AIBotModels2Array 方法的可见性过滤选项
This commit is contained in:
parent
18163e1e82
commit
746a0bf9a1
@ -216,10 +216,11 @@ class Setting extends AbstractModel
|
||||
/**
|
||||
* AI 机器人模型转数组
|
||||
* @param $models
|
||||
* @param bool $retValue
|
||||
* @param bool $retValue 仅返回模型 value 列表
|
||||
* @param bool $visibleOnly 仅返回可见模型(跳过标记 hidden 的项,供展示给终端用户的场景)
|
||||
* @return array
|
||||
*/
|
||||
public static function AIBotModels2Array($models, $retValue = false)
|
||||
public static function AIBotModels2Array($models, $retValue = false, $visibleOnly = false)
|
||||
{
|
||||
$list = null;
|
||||
if (is_array($models)) {
|
||||
@ -244,6 +245,10 @@ class Setting extends AbstractModel
|
||||
if ($value === '') {
|
||||
continue;
|
||||
}
|
||||
// 隐藏模型:仍保存在设置中,但展示给终端用户时跳过($visibleOnly)
|
||||
if ($visibleOnly && !empty($item['hidden'])) {
|
||||
continue;
|
||||
}
|
||||
$label = trim((string)($item['name'] ?? $item['label'] ?? ''));
|
||||
$thinking = strtolower(trim((string)($item['thinking'] ?? 'off')));
|
||||
if (!in_array($thinking, ['off', 'low', 'medium', 'high'], true)) {
|
||||
|
||||
@ -273,8 +273,11 @@ class UserBot extends AbstractModel
|
||||
if ($match[1] === "ai-") {
|
||||
$aibotSetting = Base::setting('aibotSetting');
|
||||
$aibotModel = $aibotSetting[$match[2] . '_model'];
|
||||
$aibotModels = Setting::AIBotModels2Array($aibotSetting[$match[2] . '_models']);
|
||||
$aibotModels = Setting::AIBotModels2Array($aibotSetting[$match[2] . '_models'], false, true);
|
||||
if ($aibotModels) {
|
||||
if (!in_array($aibotModel, array_column($aibotModels, 'value'), true)) {
|
||||
$aibotModel = $aibotModels[0]['value'];
|
||||
}
|
||||
$menus = array_merge(
|
||||
[
|
||||
[
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user