mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
perf: 优化 AI 设置
This commit is contained in:
parent
ff41f5c041
commit
b01d5ce8c4
@ -3090,7 +3090,7 @@ class DialogController extends AbstractController
|
||||
]
|
||||
)) {
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog_id, 'notice', [
|
||||
'notice' => $value ? ("修改提示词:" . $value) : "取消提示词",
|
||||
'notice' => $value ? ("修改提示词:" . Base::cutStr($value, 100)) : "取消提示词",
|
||||
], User::userid(), true, true);
|
||||
}
|
||||
|
||||
|
||||
@ -287,6 +287,7 @@ class SystemController extends AbstractController
|
||||
* @apiParam {String} type
|
||||
* - get: 获取(默认)
|
||||
* - save: 保存设置(参数:[...])
|
||||
* @apiParam {String} filter 过滤字段(可选)
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
@ -297,6 +298,7 @@ class SystemController extends AbstractController
|
||||
User::auth('admin');
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
$filter = trim(Request::input('filter'));
|
||||
$setting = Base::setting('aibotSetting');
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
@ -311,10 +313,18 @@ class SystemController extends AbstractController
|
||||
}
|
||||
$setting = Base::setting('aibotSetting', Base::newTrim($setting));
|
||||
}
|
||||
if ($filter) {
|
||||
$setting = array_filter($setting, function($value, $key) use ($filter) {
|
||||
return str_starts_with($key, $filter);
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
//
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
foreach ($setting as $key => $item) {
|
||||
if (str_contains($key, '_key') && $item) {
|
||||
if (empty($item)) {
|
||||
continue;
|
||||
}
|
||||
if (str_ends_with($key, '_key') || str_ends_with($key, '_secret')) {
|
||||
$setting[$key] = substr($item, 0, 4) . str_repeat('*', strlen($item) - 8) . substr($item, -4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class Setting extends AbstractModel
|
||||
}
|
||||
$array = [];
|
||||
$aiList = ['openai', 'claude', 'deepseek', 'gemini', 'grok', 'ollama', 'zhipu', 'qianwen', 'wenxin'];
|
||||
$fieldList = ['key', 'models', 'model', 'base_url', 'agency', 'temperature', 'system', 'secret'];
|
||||
$fieldList = ['key', 'secret', 'models', 'model', 'base_url', 'agency', 'temperature', 'system'];
|
||||
foreach ($aiList as $aiName) {
|
||||
foreach ($fieldList as $fieldName) {
|
||||
$key = $aiName . '_' . $fieldName;
|
||||
|
||||
@ -1295,7 +1295,7 @@ class Base
|
||||
* 获取或设置
|
||||
* @param $setname // 配置名称
|
||||
* @param bool $array // 保存内容
|
||||
* @param false $isUpdate // 保存内容为更新模式,默认否
|
||||
* @param bool $isUpdate // 保存内容为更新模式,默认否
|
||||
* @return array
|
||||
*/
|
||||
public static function setting($setname, $array = false, $isUpdate = false)
|
||||
|
||||
@ -449,11 +449,12 @@
|
||||
<Form :model="modifyData" @submit.native.prevent>
|
||||
<FormItem prop="value" style="margin-bottom: 16px">
|
||||
<Input
|
||||
:maxlength="500"
|
||||
:maxlength="20000"
|
||||
type="textarea"
|
||||
:autosize="{minRows:3,maxRows:5}"
|
||||
v-model="modifyData.value"
|
||||
:placeholder="$L('例如:你是一个人开发的AI助手')"/>
|
||||
:placeholder="$L('例如:你是一个人开发的AI助手')"
|
||||
show-word-limit/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer" class="adaption">
|
||||
@ -2896,7 +2897,8 @@ export default {
|
||||
this.modifyLoad++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/config/save',
|
||||
data: this.modifyData
|
||||
data: this.modifyData,
|
||||
method: 'post'
|
||||
}).then(({data, msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$store.dispatch("saveDialog", data);
|
||||
|
||||
@ -22,11 +22,12 @@
|
||||
</template>
|
||||
<template v-else-if="field.type === 'textarea'">
|
||||
<Input
|
||||
:maxlength="500"
|
||||
:maxlength="field.maxlength || 500"
|
||||
type="textarea"
|
||||
:autosize="{minRows:2,maxRows:6}"
|
||||
v-model="formData[field.prop]"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
:placeholder="$L(field.placeholder)"
|
||||
:show-word-limit="!!field.showWordLimit"/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Input
|
||||
@ -174,8 +175,12 @@ export default {
|
||||
const data = Object.fromEntries(Object.entries(this.formData).filter(([key]) => props.includes(key)));
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'system/setting/aibot?type=' + (save ? 'save' : 'all'),
|
||||
data: save ? data : {},
|
||||
url: 'system/setting/aibot',
|
||||
data: Object.assign(save ? data : {}, {
|
||||
type: save ? 'save' : 'get',
|
||||
filter: this.type,
|
||||
}),
|
||||
method: save ? 'post' : 'get',
|
||||
}).then(({data}) => {
|
||||
if (save) {
|
||||
$A.messageSuccess('修改成功');
|
||||
|
||||
2
resources/assets/js/store/ai.js
vendored
2
resources/assets/js/store/ai.js
vendored
@ -120,6 +120,8 @@ const AISystemConfig = {
|
||||
label: "默认提示词",
|
||||
prop: "system",
|
||||
type: "textarea",
|
||||
maxlength: 20000,
|
||||
showWordLimit: true,
|
||||
placeholder: "请输入默认提示词",
|
||||
tip: "例如:你是一个人开发的AI助手"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user