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
db6500369f
commit
f78c4a1fb0
@ -68,39 +68,39 @@
|
||||
</li>
|
||||
</ul>
|
||||
<Tabs v-else v-model="aibotTabAction" class="ai-tabs">
|
||||
<TabPane label="ChatGPT" name="opanai">
|
||||
<TabPane label="ChatGPT" name="openai">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="ChatGPT" v-if="aibotTabAction == 'opanai'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'openai'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane label="Claude" name="claude">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="Claude" v-if="aibotTabAction == 'claude'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'claude'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane label="DeepSeek" name="deepseek">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="DeepSeek" v-if="aibotTabAction == 'deepseek'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'deepseek'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane label="Gemini" name="gemini">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="Gemini" v-if="aibotTabAction == 'gemini'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'gemini'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane :label="$L('智谱清言')" name="zhipu">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="Zhipu" v-if="aibotTabAction == 'zhipu'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'zhipu'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane :label="$L('文心一言')" name="wenxin">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="Wenxin" v-if="aibotTabAction == 'wenxin'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'wenxin'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane :label="$L('通义千问')" name="qianwen">
|
||||
<div class="aibot-warp">
|
||||
<SystemAibot type="Qianwen" v-if="aibotTabAction == 'qianwen'" />
|
||||
<SystemAibot :type="aibotTabAction" v-if="aibotTabAction == 'qianwen'" />
|
||||
</div>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
@ -298,7 +298,7 @@ export default {
|
||||
desc: this.$L('我是达摩院自主研发的超大规模语言模型,能够回答问题、创作文字,还能表达观点、撰写代码。')
|
||||
},
|
||||
],
|
||||
aibotTabAction: "opanai",
|
||||
aibotTabAction: "openai",
|
||||
aibotShow: false,
|
||||
aibotType: 1,
|
||||
aibotDialogSearchLoad: "",
|
||||
@ -449,7 +449,7 @@ export default {
|
||||
break;
|
||||
case 'robot':
|
||||
this.aibotType = 1;
|
||||
this.aibotTabAction = "opanai";
|
||||
this.aibotTabAction = "openai";
|
||||
this.aibotShow = true;
|
||||
break;
|
||||
case 'signin':
|
||||
|
||||
@ -6,49 +6,47 @@
|
||||
:rules="ruleData"
|
||||
v-bind="formOptions"
|
||||
@submit.native.prevent>
|
||||
<div class="block-setting-box" v-if="aiConfig[type]">
|
||||
<h3>{{ type }}</h3>
|
||||
<div class="form-box">
|
||||
<template v-for="field in aiConfig[type].fields">
|
||||
<FormItem :label="$L(field.label)" :prop="field.prop">
|
||||
<template v-if="field.type === 'password'">
|
||||
<Input
|
||||
:maxlength="255"
|
||||
v-model="formData[field.prop]"
|
||||
type="password"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
</template>
|
||||
<template v-else-if="field.type === 'model'">
|
||||
<Select v-model="formData[field.prop]" transfer>
|
||||
<Option v-for="item in modelOption(field.prop)" :value="item.value" :key="item.value">{{ item.label }}</Option>
|
||||
</Select>
|
||||
</template>
|
||||
<template v-else-if="field.type === 'textarea'">
|
||||
<Input
|
||||
:maxlength="500"
|
||||
type="textarea"
|
||||
:autosize="{minRows:2,maxRows:6}"
|
||||
v-model="formData[field.prop]"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Input
|
||||
:maxlength="500"
|
||||
v-model="formData[field.prop]"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
</template>
|
||||
<div v-if="field.link || field.tip" class="form-tip">
|
||||
<template v-if="field.link">
|
||||
{{$L(field.tipPrefix || '获取方式')}} <a :href="field.link" target="_blank">{{ field.link }}</a>
|
||||
</template>
|
||||
<template v-else-if="field.tip">
|
||||
{{$L(field.tip)}}
|
||||
</template>
|
||||
</div>
|
||||
</FormItem>
|
||||
<template v-for="field in fields">
|
||||
<FormItem :label="$L(field.label)" :prop="field.prop">
|
||||
<template v-if="field.type === 'password'">
|
||||
<Input
|
||||
:maxlength="255"
|
||||
v-model="formData[field.prop]"
|
||||
type="password"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<template v-else-if="field.type === 'model'">
|
||||
<Select v-model="formData[field.prop]" transfer>
|
||||
<Option v-for="item in modelOption(field.prop)" :value="item.value" :key="item.value">{{ item.label }}</Option>
|
||||
</Select>
|
||||
</template>
|
||||
<template v-else-if="field.type === 'textarea'">
|
||||
<Input
|
||||
:maxlength="500"
|
||||
type="textarea"
|
||||
:autosize="{minRows:2,maxRows:6}"
|
||||
v-model="formData[field.prop]"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Input
|
||||
:maxlength="500"
|
||||
v-model="formData[field.prop]"
|
||||
:placeholder="$L(field.placeholder)"/>
|
||||
</template>
|
||||
<div v-if="field.link || field.tip" class="form-tip">
|
||||
<template v-if="field.link">
|
||||
{{$L(field.tipPrefix || '获取方式')}} <a :href="field.link" target="_blank">{{ field.link }}</a>
|
||||
</template>
|
||||
<template v-else-if="field.tip">
|
||||
{{$L(field.tip)}}
|
||||
</template>
|
||||
</div>
|
||||
<div v-if="field.functions" class="form-tip" style="margin-top:-5px">
|
||||
<a href="javascript:void(0)" @click="functionClick(field.prop)">{{ $L(field.functions) }}</a>
|
||||
</div>
|
||||
</FormItem>
|
||||
</template>
|
||||
</Form>
|
||||
<div class="setting-footer">
|
||||
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{ $L('提交') }}</Button>
|
||||
@ -73,344 +71,159 @@ export default {
|
||||
formData: {},
|
||||
ruleData: {},
|
||||
aiConfig: {
|
||||
ChatGPT: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'openai_key',
|
||||
type: 'password',
|
||||
placeholder: 'OpenAI API Key',
|
||||
tipPrefix: '访问OpenAI网站查看',
|
||||
link: 'https://platform.openai.com/account/api-keys'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'openai_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://platform.openai.com/docs/models'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'openai_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: 'Base URL',
|
||||
prop: 'openai_base_url',
|
||||
placeholder: 'Enter base URL...',
|
||||
tip: 'API请求的基础URL路径,如果没有请留空'
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'openai_agency',
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: '例如:http://proxy.com 或 socks5://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'openai_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'openai_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
},
|
||||
Claude: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'claude_key',
|
||||
type: 'password',
|
||||
placeholder: 'Claude API Key',
|
||||
link: 'https://docs.anthropic.com/en/api/getting-started'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'claude_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://docs.anthropic.com/en/docs/about-claude/models'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'claude_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'claude_agency',
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: '例如:http://proxy.com 或 socks5://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'claude_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'claude_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
},
|
||||
DeepSeek: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'deepseek_key',
|
||||
type: 'password',
|
||||
placeholder: 'DeepSeek API Key',
|
||||
tipPrefix: '访问DeepSeek网站查看',
|
||||
link: 'https://platform.deepseek.com/api_keys'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'deepseek_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://api-docs.deepseek.com/zh-cn/quick_start/pricing'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'deepseek_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: 'Base URL',
|
||||
prop: 'deepseek_base_url',
|
||||
type: 'input',
|
||||
placeholder: 'Enter base URL...',
|
||||
tip: 'API请求的基础URL路径,如果没有请留空'
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'deepseek_agency',
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: '例如:http://proxy.com 或 socks5://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'deepseek_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'deepseek_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
},
|
||||
Gemini: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'gemini_key',
|
||||
type: 'password',
|
||||
placeholder: 'Gemini API Key',
|
||||
link: 'https://makersuite.google.com/app/apikey'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'gemini_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://ai.google.dev/models/gemini'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'gemini_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'gemini_agency',
|
||||
placeholder: '仅支持 http 代理',
|
||||
tip: '例如:http://proxy.com 或 https://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'gemini_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'gemini_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
},
|
||||
Zhipu: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'zhipu_key',
|
||||
type: 'password',
|
||||
placeholder: 'Zhipu API Key',
|
||||
link: 'https://bigmodel.cn/usercenter/apikeys'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'zhipu_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://open.bigmodel.cn/dev/api'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'zhipu_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'zhipu_agency',
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: '例如:http://proxy.com 或 socks5://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'zhipu_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'zhipu_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
},
|
||||
Qianwen: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'qianwen_key',
|
||||
type: 'password',
|
||||
placeholder: 'Qianwen API Key',
|
||||
link: 'https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'qianwen_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://help.aliyun.com/zh/model-studio/getting-started/models'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'qianwen_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'qianwen_agency',
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: '例如:http://proxy.com 或 socks5://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'qianwen_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'qianwen_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
},
|
||||
Wenxin: {
|
||||
fields: [
|
||||
{
|
||||
label: 'API Key',
|
||||
prop: 'wenxin_key',
|
||||
type: 'password',
|
||||
placeholder: 'Wenxin API Key',
|
||||
link: 'https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1'
|
||||
},
|
||||
{
|
||||
label: 'Secret Key',
|
||||
prop: 'wenxin_secret',
|
||||
type: 'password',
|
||||
placeholder: 'Wenxin Secret Key',
|
||||
link: 'https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1'
|
||||
},
|
||||
{
|
||||
label: '模型列表',
|
||||
prop: 'wenxin_models',
|
||||
type: 'textarea',
|
||||
placeholder: '一行一个模型名称',
|
||||
tipPrefix: '查看说明',
|
||||
link: 'https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Blfmc9dlf'
|
||||
},
|
||||
{
|
||||
label: '默认模型',
|
||||
prop: 'wenxin_model',
|
||||
type: 'model',
|
||||
placeholder: '请选择默认模型',
|
||||
tip: '可选数据来自模型列表',
|
||||
},
|
||||
{
|
||||
label: '使用代理',
|
||||
prop: 'wenxin_agency',
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: '例如:http://proxy.com 或 socks5://proxy.com'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
prop: 'wenxin_temperature',
|
||||
placeholder: '模型温度,低则保守,高则多样',
|
||||
tip: '例如:0.7,范围:0-1,默认:0.7'
|
||||
},
|
||||
{
|
||||
label: '默认提示词',
|
||||
prop: 'wenxin_system',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入默认提示词',
|
||||
tip: '例如:你是一个人开发的AI助手'
|
||||
}
|
||||
]
|
||||
fields: [
|
||||
{
|
||||
label: "API Key",
|
||||
prop: "key",
|
||||
type: "password"
|
||||
},
|
||||
{
|
||||
label: "模型列表",
|
||||
prop: "models",
|
||||
type: "textarea",
|
||||
placeholder: "一行一个模型名称",
|
||||
functions: "使用默认模型列表"
|
||||
},
|
||||
{
|
||||
label: "默认模型",
|
||||
prop: "model",
|
||||
type: "model",
|
||||
placeholder: "请选择默认模型",
|
||||
tip: "可选数据来自模型列表"
|
||||
},
|
||||
{
|
||||
label: "Base URL",
|
||||
prop: "base_url",
|
||||
placeholder: "Enter base URL...",
|
||||
tip: "API请求的基础URL路径,如果没有请留空"
|
||||
},
|
||||
{
|
||||
label: "使用代理",
|
||||
prop: "agency",
|
||||
placeholder: '支持 http 或 socks 代理',
|
||||
tip: "例如:http://proxy.com 或 socks5://proxy.com"
|
||||
},
|
||||
{
|
||||
label: "Temperature",
|
||||
prop: "temperature",
|
||||
placeholder: "模型温度,低则保守,高则多样",
|
||||
tip: "例如:0.7,范围:0-1,默认:0.7"
|
||||
},
|
||||
{
|
||||
label: "默认提示词",
|
||||
prop: "system",
|
||||
type: "textarea",
|
||||
placeholder: "请输入默认提示词",
|
||||
tip: "例如:你是一个人开发的AI助手"
|
||||
}
|
||||
],
|
||||
aiList: {
|
||||
openai: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "OpenAI API Key",
|
||||
link: "https://platform.openai.com/account/api-keys"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://platform.openai.com/docs/models",
|
||||
}
|
||||
]
|
||||
},
|
||||
claude: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "Claude API Key",
|
||||
link: "https://docs.anthropic.com/en/api/getting-started"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://docs.anthropic.com/en/docs/about-claude/models"
|
||||
}
|
||||
]
|
||||
},
|
||||
deepseek: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "DeepSeek API Key",
|
||||
link: "https://platform.deepseek.com/api_keys"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://api-docs.deepseek.com/zh-cn/quick_start/pricing"
|
||||
}
|
||||
]
|
||||
},
|
||||
gemini: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "Gemini API Key",
|
||||
link: "https://makersuite.google.com/app/apikey"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://ai.google.dev/models/gemini"
|
||||
},
|
||||
{
|
||||
prop: "agency",
|
||||
placeholder: "仅支持 http 代理",
|
||||
tip: "例如:http://proxy.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
zhipu: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "Zhipu API Key",
|
||||
link: "https://bigmodel.cn/usercenter/apikeys"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://open.bigmodel.cn/dev/api"
|
||||
}
|
||||
]
|
||||
},
|
||||
qianwen: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "Qianwen API Key",
|
||||
link: "https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://help.aliyun.com/zh/model-studio/getting-started/models"
|
||||
}
|
||||
]
|
||||
},
|
||||
wenxin: {
|
||||
extraFields: [
|
||||
{
|
||||
prop: "key",
|
||||
placeholder: "Wenxin API Key",
|
||||
link: "https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1"
|
||||
},
|
||||
{
|
||||
prop: "secret",
|
||||
placeholder: "Wenxin Secret Key",
|
||||
link: "https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1",
|
||||
type: "password",
|
||||
label: "Secret Key",
|
||||
after: "key"
|
||||
},
|
||||
{
|
||||
prop: "models",
|
||||
link: "https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Blfmc9dlf"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -418,6 +231,62 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapState(['formOptions']),
|
||||
|
||||
fields({aiConfig, type}) {
|
||||
// 如果type不存在于aiList中,返回空数组
|
||||
if (!aiConfig.aiList?.[type]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取基础fields和当前type的extraFields
|
||||
const baseFields = JSON.parse(JSON.stringify(aiConfig.fields));
|
||||
const { extraFields = [] } = aiConfig.aiList[type];
|
||||
|
||||
// 处理每个field,添加type前缀
|
||||
const prefixedFields = baseFields.map(field => ({
|
||||
...field,
|
||||
prop: `${type}_${field.prop}`
|
||||
}));
|
||||
|
||||
// 处理extraFields
|
||||
extraFields.forEach(extraField => {
|
||||
const newField = {
|
||||
...extraField,
|
||||
prop: `${type}_${extraField.prop}`
|
||||
};
|
||||
|
||||
// 查找是否已存在相同prop的field
|
||||
const existingIndex = prefixedFields.findIndex(f =>
|
||||
f.prop === newField.prop
|
||||
);
|
||||
|
||||
if (existingIndex !== -1) {
|
||||
// 如果存在,则覆盖原有的field
|
||||
prefixedFields[existingIndex] = {
|
||||
...prefixedFields[existingIndex],
|
||||
...newField
|
||||
};
|
||||
} else {
|
||||
// 如果不存在,需要插入
|
||||
if (extraField.after) {
|
||||
// 如果指定了after,找到对应位置插入
|
||||
const afterIndex = prefixedFields.findIndex(f =>
|
||||
f.prop === `${type}_${extraField.after}`
|
||||
);
|
||||
if (afterIndex !== -1) {
|
||||
prefixedFields.splice(afterIndex + 1, 0, newField);
|
||||
} else {
|
||||
prefixedFields.push(newField);
|
||||
}
|
||||
} else {
|
||||
// 没有指定after,直接添加到末尾
|
||||
prefixedFields.push(newField);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return prefixedFields;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
modelOption(prop) {
|
||||
@ -430,6 +299,7 @@ export default {
|
||||
}
|
||||
return []
|
||||
},
|
||||
|
||||
submitForm() {
|
||||
this.$refs.formData.validate((valid) => {
|
||||
if (valid) {
|
||||
@ -437,16 +307,18 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
resetForm() {
|
||||
this.formData = $A.cloneJSON(this.formDatum_bak);
|
||||
},
|
||||
|
||||
systemSetting(save) {
|
||||
const props = this.aiConfig[this.type].fields.map(item => item.prop);
|
||||
const props = this.fields.map(item => item.prop);
|
||||
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,
|
||||
data: save ? data : {},
|
||||
}).then(({data}) => {
|
||||
if (save) {
|
||||
$A.messageSuccess('修改成功');
|
||||
@ -460,6 +332,21 @@ export default {
|
||||
}).finally(_ => {
|
||||
this.loadIng--;
|
||||
});
|
||||
},
|
||||
|
||||
functionClick(prop) {
|
||||
if (prop === `${this.type}_models`) {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'system/setting/aibot_defmodels?type=' + this.type,
|
||||
spinner: 600,
|
||||
}).then(({data}) => {
|
||||
this.formData[prop] = data.models.join('\n');
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg || '获取失败');
|
||||
});
|
||||
} else {
|
||||
$A.messageError('未知操作');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user