2025-03-14 23:48:59 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="welcome">
|
2025-06-11 22:09:21 +08:00
|
|
|
|
<HeaderBar />
|
2025-04-16 11:17:02 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="operation-bar">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<h2 class="page-title">{{ $t("roleConfig.title") }}</h2>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="main-wrapper">
|
|
|
|
|
|
<div class="content-panel">
|
|
|
|
|
|
<div class="content-area">
|
|
|
|
|
|
<el-card class="config-card" shadow="never">
|
|
|
|
|
|
<div class="config-header">
|
|
|
|
|
|
<div class="header-icon">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<img loading="lazy" src="@/assets/home/setting-user.png" alt="" />
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
<span class="header-title">{{ form.agentName }}</span>
|
2025-05-14 12:09:29 +08:00
|
|
|
|
<div class="header-actions">
|
|
|
|
|
|
<div class="hint-text">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<img loading="lazy" src="@/assets/home/info.png" alt="" />
|
|
|
|
|
|
<span>{{ $t("roleConfig.restartNotice") }}</span>
|
2025-05-14 12:09:29 +08:00
|
|
|
|
</div>
|
2025-09-13 00:47:48 +08:00
|
|
|
|
<el-button type="primary" class="save-btn" @click="saveConfig">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
{{ $t("roleConfig.saveConfig") }}
|
2025-09-13 00:47:48 +08:00
|
|
|
|
</el-button>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-button class="reset-btn" @click="resetConfig">{{
|
|
|
|
|
|
$t("roleConfig.reset")
|
|
|
|
|
|
}}</el-button>
|
|
|
|
|
|
<button class="custom-close-btn" @click="goToHome">×</button>
|
2025-05-14 12:09:29 +08:00
|
|
|
|
</div>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="divider"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form ref="form" :model="form" label-width="72px">
|
|
|
|
|
|
<div class="form-content">
|
|
|
|
|
|
<div class="form-grid">
|
|
|
|
|
|
<div class="form-column">
|
2025-09-11 17:10:50 +08:00
|
|
|
|
<el-form-item :label="$t('roleConfig.agentName') + ':'">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="form.agentName"
|
|
|
|
|
|
class="form-input"
|
|
|
|
|
|
maxlength="10"
|
|
|
|
|
|
/>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</el-form-item>
|
2025-09-11 17:10:50 +08:00
|
|
|
|
<el-form-item :label="$t('roleConfig.roleTemplate') + ':'">
|
2025-04-16 11:17:02 +08:00
|
|
|
|
<div class="template-container">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-for="(template, index) in templates"
|
|
|
|
|
|
:key="`template-${index}`"
|
|
|
|
|
|
class="template-item"
|
|
|
|
|
|
:class="{ 'template-loading': loadingTemplate }"
|
|
|
|
|
|
@click="selectTemplate(template)"
|
|
|
|
|
|
>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
{{ template.agentName }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
2025-12-10 10:26:27 +08:00
|
|
|
|
<el-form-item :label="$t('roleConfig.contextProvider') + ':'" class="context-provider-item">
|
2025-12-05 11:24:57 +08:00
|
|
|
|
<div style="display: flex; align-items: center; justify-content: space-between;">
|
|
|
|
|
|
<span style="color: #606266; font-size: 13px;">
|
2025-12-10 10:26:27 +08:00
|
|
|
|
{{ $t('roleConfig.contextProviderSuccess', { count: currentContextProviders.length }) }}<a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/context-provider-integration.md" target="_blank" class="doc-link">{{ $t('roleConfig.contextProviderDocLink') }}</a>
|
2025-12-05 11:24:57 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
class="edit-function-btn"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="openContextProviderDialog"
|
|
|
|
|
|
>
|
2025-12-10 10:26:27 +08:00
|
|
|
|
{{ $t('roleConfig.editContextProvider') }}
|
2025-12-05 11:24:57 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
2025-09-11 17:10:50 +08:00
|
|
|
|
<el-form-item :label="$t('roleConfig.roleIntroduction') + ':'">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-input
|
|
|
|
|
|
type="textarea"
|
2025-12-05 11:24:57 +08:00
|
|
|
|
rows="8"
|
2025-11-15 09:51:58 +08:00
|
|
|
|
resize="none"
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseEnterContent')"
|
|
|
|
|
|
v-model="form.systemPrompt"
|
|
|
|
|
|
maxlength="2000"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
class="form-textarea"
|
|
|
|
|
|
/>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</el-form-item>
|
2025-05-14 12:09:29 +08:00
|
|
|
|
|
2025-09-13 00:47:48 +08:00
|
|
|
|
<el-form-item :label="$t('roleConfig.memoryHis') + ':'">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-input
|
|
|
|
|
|
type="textarea"
|
2025-12-05 11:24:57 +08:00
|
|
|
|
rows="4"
|
2025-11-15 09:51:58 +08:00
|
|
|
|
resize="none"
|
|
|
|
|
|
v-model="form.summaryMemory"
|
|
|
|
|
|
maxlength="2000"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
class="form-textarea"
|
|
|
|
|
|
:disabled="form.model.memModelId !== 'Memory_mem_local_short'"
|
|
|
|
|
|
/>
|
2025-05-14 03:27:32 +08:00
|
|
|
|
</el-form-item>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('roleConfig.languageCode') + ':'"
|
|
|
|
|
|
style="display: none"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="form.langCode"
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseEnterLangCode')"
|
|
|
|
|
|
maxlength="10"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
class="form-input"
|
|
|
|
|
|
/>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</el-form-item>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('roleConfig.interactionLanguage') + ':'"
|
|
|
|
|
|
style="display: none"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="form.language"
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseEnterLangName')"
|
|
|
|
|
|
maxlength="10"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
class="form-input"
|
|
|
|
|
|
/>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</el-form-item>
|
2025-04-06 15:45:18 +08:00
|
|
|
|
</div>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
<div class="form-column">
|
2025-06-01 13:34:32 +08:00
|
|
|
|
<div class="model-row">
|
2025-12-05 14:35:53 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="featureStatus.vad"
|
|
|
|
|
|
:label="$t('roleConfig.vad')"
|
|
|
|
|
|
class="model-item"
|
|
|
|
|
|
>
|
2025-06-01 13:34:32 +08:00
|
|
|
|
<div class="model-select-wrapper">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="form.model.vadModelId"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseSelect')"
|
|
|
|
|
|
class="form-select"
|
|
|
|
|
|
@change="handleModelChange('VAD', $event)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="(item, optionIndex) in modelOptions['VAD']"
|
|
|
|
|
|
:key="`option-vad-${optionIndex}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
2025-06-01 13:34:32 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
2025-12-05 14:35:53 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="featureStatus.asr"
|
|
|
|
|
|
:label="$t('roleConfig.asr')"
|
|
|
|
|
|
class="model-item"
|
|
|
|
|
|
>
|
2025-06-01 13:34:32 +08:00
|
|
|
|
<div class="model-select-wrapper">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="form.model.asrModelId"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseSelect')"
|
|
|
|
|
|
class="form-select"
|
|
|
|
|
|
@change="handleModelChange('ASR', $event)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="(item, optionIndex) in modelOptions['ASR']"
|
|
|
|
|
|
:key="`option-asr-${optionIndex}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
2025-06-01 13:34:32 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-for="(model, index) in models.slice(2)"
|
|
|
|
|
|
:key="`model-${index}`"
|
|
|
|
|
|
:label="$t('roleConfig.' + model.type.toLowerCase())"
|
|
|
|
|
|
class="model-item"
|
|
|
|
|
|
>
|
2025-05-12 14:10:05 +08:00
|
|
|
|
<div class="model-select-wrapper">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="form.model[model.key]"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseSelect')"
|
|
|
|
|
|
class="form-select"
|
|
|
|
|
|
@change="handleModelChange(model.type, $event)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="(item, optionIndex) in modelOptions[model.type]"
|
|
|
|
|
|
v-if="!item.isHidden"
|
|
|
|
|
|
:key="`option-${index}-${optionIndex}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
2025-05-12 14:10:05 +08:00
|
|
|
|
</el-select>
|
2025-05-12 15:49:44 +08:00
|
|
|
|
<div v-if="showFunctionIcons(model.type)" class="function-icons">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-tooltip
|
|
|
|
|
|
v-for="func in currentFunctions"
|
|
|
|
|
|
:key="func.name"
|
|
|
|
|
|
effect="dark"
|
|
|
|
|
|
placement="top"
|
|
|
|
|
|
popper-class="custom-tooltip"
|
|
|
|
|
|
>
|
2025-05-12 15:49:44 +08:00
|
|
|
|
<div slot="content">
|
|
|
|
|
|
<div><strong>功能名称:</strong> {{ func.name }}</div>
|
|
|
|
|
|
</div>
|
2025-11-13 11:01:28 +08:00
|
|
|
|
<div class="icon-dot">
|
2025-11-10 15:10:59 +08:00
|
|
|
|
{{ getFunctionDisplayChar(func.name) }}
|
2025-05-12 15:49:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-tooltip>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
class="edit-function-btn"
|
|
|
|
|
|
@click="openFunctionDialog"
|
|
|
|
|
|
:class="{ 'active-btn': showFunctionDialog }"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ $t("roleConfig.editFunctions") }}
|
2025-05-12 15:49:44 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-if="
|
|
|
|
|
|
model.type === 'Memory' &&
|
|
|
|
|
|
form.model.memModelId !== 'Memory_nomem'
|
|
|
|
|
|
"
|
|
|
|
|
|
class="chat-history-options"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-radio-group
|
|
|
|
|
|
v-model="form.chatHistoryConf"
|
|
|
|
|
|
@change="updateChatHistoryConf"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-radio-button :label="1">{{
|
|
|
|
|
|
$t("roleConfig.reportText")
|
|
|
|
|
|
}}</el-radio-button>
|
|
|
|
|
|
<el-radio-button :label="2">{{
|
|
|
|
|
|
$t("roleConfig.reportTextVoice")
|
|
|
|
|
|
}}</el-radio-button>
|
2025-09-13 00:47:48 +08:00
|
|
|
|
</el-radio-group>
|
2025-05-12 15:49:44 +08:00
|
|
|
|
</div>
|
2025-05-12 14:10:05 +08:00
|
|
|
|
</div>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</el-form-item>
|
2025-09-11 17:10:50 +08:00
|
|
|
|
<el-form-item :label="$t('roleConfig.voiceType')">
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="form.ttsVoiceId"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
:placeholder="$t('roleConfig.pleaseSelect')"
|
|
|
|
|
|
class="form-select"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
2025-11-15 10:45:22 +08:00
|
|
|
|
v-for="(item, index) in voiceOptions"
|
|
|
|
|
|
:key="`voice-${index}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
style="
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
|
|
<template v-if="hasAudioPreview(item)">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
:icon="
|
|
|
|
|
|
playingVoice &&
|
|
|
|
|
|
currentPlayingVoiceId === item.value &&
|
|
|
|
|
|
!isPaused
|
|
|
|
|
|
? 'el-icon-video-pause'
|
|
|
|
|
|
: 'el-icon-video-play'
|
|
|
|
|
|
"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click.stop="toggleAudioPlayback(item.value)"
|
|
|
|
|
|
:loading="false"
|
|
|
|
|
|
class="play-button"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-option>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-card>
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-04-16 11:17:02 +08:00
|
|
|
|
</div>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
<function-dialog
|
|
|
|
|
|
v-model="showFunctionDialog"
|
|
|
|
|
|
:functions="currentFunctions"
|
|
|
|
|
|
:all-functions="allFunctions"
|
|
|
|
|
|
:agent-id="$route.query.agentId"
|
|
|
|
|
|
@update-functions="handleUpdateFunctions"
|
|
|
|
|
|
@dialog-closed="handleDialogClosed"
|
|
|
|
|
|
/>
|
2025-12-05 11:24:57 +08:00
|
|
|
|
<context-provider-dialog
|
|
|
|
|
|
:visible.sync="showContextProviderDialog"
|
|
|
|
|
|
:providers="currentContextProviders"
|
|
|
|
|
|
@confirm="handleUpdateContext"
|
|
|
|
|
|
/>
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-11-15 09:51:58 +08:00
|
|
|
|
import Api from "@/apis/api";
|
2025-11-15 16:06:58 +08:00
|
|
|
|
import { getServiceUrl } from "@/apis/api";
|
|
|
|
|
|
import RequestService from "@/apis/httpRequest";
|
2025-05-12 14:10:05 +08:00
|
|
|
|
import FunctionDialog from "@/components/FunctionDialog.vue";
|
2025-12-05 11:24:57 +08:00
|
|
|
|
import ContextProviderDialog from "@/components/ContextProviderDialog.vue";
|
2025-05-12 15:49:44 +08:00
|
|
|
|
import HeaderBar from "@/components/HeaderBar.vue";
|
2025-11-15 09:51:58 +08:00
|
|
|
|
import i18n from "@/i18n";
|
2025-12-05 14:35:53 +08:00
|
|
|
|
import featureManager from "@/utils/featureManager";
|
2025-03-14 23:48:59 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
name: "RoleConfigPage",
|
2025-12-05 11:24:57 +08:00
|
|
|
|
components: { HeaderBar, FunctionDialog, ContextProviderDialog },
|
2025-03-14 23:48:59 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2025-12-05 11:24:57 +08:00
|
|
|
|
showContextProviderDialog: false,
|
2025-03-14 23:48:59 +08:00
|
|
|
|
form: {
|
2025-03-28 11:20:08 +08:00
|
|
|
|
agentCode: "",
|
2025-03-24 17:27:08 +08:00
|
|
|
|
agentName: "",
|
|
|
|
|
|
ttsVoiceId: "",
|
2025-05-12 15:49:44 +08:00
|
|
|
|
chatHistoryConf: 0,
|
2025-03-24 17:27:08 +08:00
|
|
|
|
systemPrompt: "",
|
2025-05-14 03:27:32 +08:00
|
|
|
|
summaryMemory: "",
|
2025-03-28 11:20:08 +08:00
|
|
|
|
langCode: "",
|
|
|
|
|
|
language: "",
|
|
|
|
|
|
sort: "",
|
2025-03-18 21:49:57 +08:00
|
|
|
|
model: {
|
2025-03-24 17:27:08 +08:00
|
|
|
|
ttsModelId: "",
|
|
|
|
|
|
vadModelId: "",
|
2025-03-28 11:20:08 +08:00
|
|
|
|
asrModelId: "",
|
2025-03-24 17:27:08 +08:00
|
|
|
|
llmModelId: "",
|
2025-06-01 13:34:32 +08:00
|
|
|
|
vllmModelId: "",
|
2025-03-24 17:27:08 +08:00
|
|
|
|
memModelId: "",
|
|
|
|
|
|
intentModelId: "",
|
2025-11-15 09:51:58 +08:00
|
|
|
|
},
|
2025-03-14 23:48:59 +08:00
|
|
|
|
},
|
2025-03-18 23:08:13 +08:00
|
|
|
|
models: [
|
2025-11-15 09:51:58 +08:00
|
|
|
|
{ label: this.$t("roleConfig.vad"), key: "vadModelId", type: "VAD" },
|
|
|
|
|
|
{ label: this.$t("roleConfig.asr"), key: "asrModelId", type: "ASR" },
|
|
|
|
|
|
{ label: this.$t("roleConfig.llm"), key: "llmModelId", type: "LLM" },
|
|
|
|
|
|
{ label: this.$t("roleConfig.vllm"), key: "vllmModelId", type: "VLLM" },
|
|
|
|
|
|
{ label: this.$t("roleConfig.intent"), key: "intentModelId", type: "Intent" },
|
|
|
|
|
|
{ label: this.$t("roleConfig.memory"), key: "memModelId", type: "Memory" },
|
|
|
|
|
|
{ label: this.$t("roleConfig.tts"), key: "ttsModelId", type: "TTS" },
|
2025-03-24 17:27:08 +08:00
|
|
|
|
],
|
2025-07-24 16:17:27 +08:00
|
|
|
|
llmModeTypeMap: new Map(),
|
2025-04-06 15:45:18 +08:00
|
|
|
|
modelOptions: {},
|
|
|
|
|
|
templates: [],
|
|
|
|
|
|
loadingTemplate: false,
|
|
|
|
|
|
voiceOptions: [],
|
2025-11-15 09:51:58 +08:00
|
|
|
|
voiceDetails: {}, // 保存完整的音色信息
|
2025-05-12 14:10:05 +08:00
|
|
|
|
showFunctionDialog: false,
|
|
|
|
|
|
currentFunctions: [],
|
2025-12-05 11:24:57 +08:00
|
|
|
|
currentContextProviders: [],
|
2025-05-29 00:58:20 +08:00
|
|
|
|
allFunctions: [],
|
|
|
|
|
|
originalFunctions: [],
|
2025-11-15 09:51:58 +08:00
|
|
|
|
playingVoice: false,
|
2025-11-15 10:45:22 +08:00
|
|
|
|
isPaused: false,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
currentAudio: null,
|
2025-11-15 10:45:22 +08:00
|
|
|
|
currentPlayingVoiceId: null,
|
2025-12-05 14:35:53 +08:00
|
|
|
|
// 功能状态
|
|
|
|
|
|
featureStatus: {
|
|
|
|
|
|
vad: false, // 语言检测活动功能状态
|
|
|
|
|
|
asr: false, // 语音识别功能状态
|
|
|
|
|
|
},
|
2025-11-15 09:51:58 +08:00
|
|
|
|
};
|
2025-03-14 23:48:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2025-04-21 10:24:04 +08:00
|
|
|
|
goToHome() {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$router.push("/home");
|
2025-04-21 10:24:04 +08:00
|
|
|
|
},
|
2025-03-14 23:48:59 +08:00
|
|
|
|
saveConfig() {
|
2025-03-28 11:20:08 +08:00
|
|
|
|
const configData = {
|
|
|
|
|
|
agentCode: this.form.agentCode,
|
|
|
|
|
|
agentName: this.form.agentName,
|
|
|
|
|
|
asrModelId: this.form.model.asrModelId,
|
|
|
|
|
|
vadModelId: this.form.model.vadModelId,
|
|
|
|
|
|
llmModelId: this.form.model.llmModelId,
|
2025-06-01 13:34:32 +08:00
|
|
|
|
vllmModelId: this.form.model.vllmModelId,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
ttsModelId: this.form.model.ttsModelId,
|
|
|
|
|
|
ttsVoiceId: this.form.ttsVoiceId,
|
2025-05-11 03:19:40 +08:00
|
|
|
|
chatHistoryConf: this.form.chatHistoryConf,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
memModelId: this.form.model.memModelId,
|
|
|
|
|
|
intentModelId: this.form.model.intentModelId,
|
|
|
|
|
|
systemPrompt: this.form.systemPrompt,
|
2025-05-14 03:27:32 +08:00
|
|
|
|
summaryMemory: this.form.summaryMemory,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
langCode: this.form.langCode,
|
|
|
|
|
|
language: this.form.language,
|
2025-05-12 14:10:05 +08:00
|
|
|
|
sort: this.form.sort,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
functions: this.currentFunctions.map((item) => {
|
|
|
|
|
|
return {
|
2025-05-29 00:58:20 +08:00
|
|
|
|
pluginId: item.id,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
paramInfo: item.params,
|
|
|
|
|
|
};
|
|
|
|
|
|
}),
|
2025-12-05 11:24:57 +08:00
|
|
|
|
contextProviders: this.currentContextProviders,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
};
|
2025-06-11 22:09:21 +08:00
|
|
|
|
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
2025-04-05 21:03:46 +08:00
|
|
|
|
if (data.code === 0) {
|
2025-04-07 15:14:20 +08:00
|
|
|
|
this.$message.success({
|
2025-11-15 09:51:58 +08:00
|
|
|
|
message: i18n.t("roleConfig.saveSuccess"),
|
|
|
|
|
|
showClose: true,
|
2025-04-07 15:14:20 +08:00
|
|
|
|
});
|
2025-04-05 21:03:46 +08:00
|
|
|
|
} else {
|
2025-04-07 15:14:20 +08:00
|
|
|
|
this.$message.error({
|
2025-11-15 09:51:58 +08:00
|
|
|
|
message: data.msg || i18n.t("roleConfig.saveFailed"),
|
|
|
|
|
|
showClose: true,
|
2025-04-07 15:14:20 +08:00
|
|
|
|
});
|
2025-04-05 21:03:46 +08:00
|
|
|
|
}
|
2025-03-28 11:20:08 +08:00
|
|
|
|
});
|
2025-03-14 23:48:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
resetConfig() {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$confirm(i18n.t("roleConfig.confirmReset"), i18n.t("message.info"), {
|
|
|
|
|
|
confirmButtonText: i18n.t("button.ok"),
|
|
|
|
|
|
cancelButtonText: i18n.t("button.cancel"),
|
|
|
|
|
|
type: "warning",
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
this.form = {
|
|
|
|
|
|
agentCode: "",
|
|
|
|
|
|
agentName: "",
|
|
|
|
|
|
ttsVoiceId: "",
|
|
|
|
|
|
chatHistoryConf: 0,
|
|
|
|
|
|
systemPrompt: "",
|
|
|
|
|
|
summaryMemory: "",
|
|
|
|
|
|
langCode: "",
|
|
|
|
|
|
language: "",
|
|
|
|
|
|
sort: "",
|
|
|
|
|
|
model: {
|
|
|
|
|
|
ttsModelId: "",
|
|
|
|
|
|
vadModelId: "",
|
|
|
|
|
|
asrModelId: "",
|
|
|
|
|
|
llmModelId: "",
|
|
|
|
|
|
vllmModelId: "",
|
|
|
|
|
|
memModelId: "",
|
|
|
|
|
|
intentModelId: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
this.currentFunctions = [];
|
|
|
|
|
|
this.$message.success({
|
|
|
|
|
|
message: i18n.t("roleConfig.resetSuccess"),
|
|
|
|
|
|
showClose: true,
|
|
|
|
|
|
});
|
2025-04-07 15:14:20 +08:00
|
|
|
|
})
|
2025-11-15 09:51:58 +08:00
|
|
|
|
.catch(() => {});
|
2025-03-18 23:08:13 +08:00
|
|
|
|
},
|
2025-04-06 15:45:18 +08:00
|
|
|
|
fetchTemplates() {
|
2025-06-11 22:09:21 +08:00
|
|
|
|
Api.agent.getAgentTemplate(({ data }) => {
|
2025-04-06 15:45:18 +08:00
|
|
|
|
if (data.code === 0) {
|
|
|
|
|
|
this.templates = data.data;
|
|
|
|
|
|
} else {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$message.error(data.msg || i18n.t("roleConfig.fetchTemplatesFailed"));
|
2025-04-06 15:45:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
selectTemplate(template) {
|
2025-04-05 20:19:28 +08:00
|
|
|
|
if (this.loadingTemplate) return;
|
|
|
|
|
|
this.loadingTemplate = true;
|
2025-04-06 15:45:18 +08:00
|
|
|
|
try {
|
|
|
|
|
|
this.applyTemplateData(template);
|
2025-04-07 15:14:20 +08:00
|
|
|
|
this.$message.success({
|
2025-11-15 09:51:58 +08:00
|
|
|
|
message: `${template.agentName}${i18n.t("roleConfig.templateApplied")}`,
|
|
|
|
|
|
showClose: true,
|
2025-04-07 15:14:20 +08:00
|
|
|
|
});
|
2025-04-06 15:45:18 +08:00
|
|
|
|
} catch (error) {
|
2025-04-07 15:14:20 +08:00
|
|
|
|
this.$message.error({
|
2025-11-15 09:51:58 +08:00
|
|
|
|
message: i18n.t("roleConfig.applyTemplateFailed"),
|
|
|
|
|
|
showClose: true,
|
2025-04-07 15:14:20 +08:00
|
|
|
|
});
|
2025-11-15 09:51:58 +08:00
|
|
|
|
console.error("应用模板失败:", error);
|
2025-04-06 15:45:18 +08:00
|
|
|
|
} finally {
|
2025-04-05 21:03:46 +08:00
|
|
|
|
this.loadingTemplate = false;
|
2025-04-06 15:45:18 +08:00
|
|
|
|
}
|
2025-03-24 22:41:32 +08:00
|
|
|
|
},
|
2025-03-28 11:20:08 +08:00
|
|
|
|
applyTemplateData(templateData) {
|
|
|
|
|
|
this.form = {
|
|
|
|
|
|
...this.form,
|
|
|
|
|
|
agentName: templateData.agentName || this.form.agentName,
|
|
|
|
|
|
ttsVoiceId: templateData.ttsVoiceId || this.form.ttsVoiceId,
|
2025-05-11 03:19:40 +08:00
|
|
|
|
chatHistoryConf: templateData.chatHistoryConf || this.form.chatHistoryConf,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
systemPrompt: templateData.systemPrompt || this.form.systemPrompt,
|
2025-05-14 03:27:32 +08:00
|
|
|
|
summaryMemory: templateData.summaryMemory || this.form.summaryMemory,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
langCode: templateData.langCode || this.form.langCode,
|
|
|
|
|
|
model: {
|
|
|
|
|
|
ttsModelId: templateData.ttsModelId || this.form.model.ttsModelId,
|
|
|
|
|
|
vadModelId: templateData.vadModelId || this.form.model.vadModelId,
|
|
|
|
|
|
asrModelId: templateData.asrModelId || this.form.model.asrModelId,
|
|
|
|
|
|
llmModelId: templateData.llmModelId || this.form.model.llmModelId,
|
2025-06-01 13:34:32 +08:00
|
|
|
|
vllmModelId: templateData.vllmModelId || this.form.model.vllmModelId,
|
2025-03-28 11:20:08 +08:00
|
|
|
|
memModelId: templateData.memModelId || this.form.model.memModelId,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
intentModelId: templateData.intentModelId || this.form.model.intentModelId,
|
|
|
|
|
|
},
|
2025-03-28 11:20:08 +08:00
|
|
|
|
};
|
2025-03-24 22:41:32 +08:00
|
|
|
|
},
|
2025-04-05 20:19:28 +08:00
|
|
|
|
fetchAgentConfig(agentId) {
|
2025-06-11 22:09:21 +08:00
|
|
|
|
Api.agent.getDeviceConfig(agentId, ({ data }) => {
|
2025-04-05 21:03:46 +08:00
|
|
|
|
if (data.code === 0) {
|
|
|
|
|
|
this.form = {
|
|
|
|
|
|
...this.form,
|
|
|
|
|
|
...data.data,
|
|
|
|
|
|
model: {
|
|
|
|
|
|
ttsModelId: data.data.ttsModelId,
|
|
|
|
|
|
vadModelId: data.data.vadModelId,
|
|
|
|
|
|
asrModelId: data.data.asrModelId,
|
|
|
|
|
|
llmModelId: data.data.llmModelId,
|
2025-06-01 13:34:32 +08:00
|
|
|
|
vllmModelId: data.data.vllmModelId,
|
2025-04-05 21:03:46 +08:00
|
|
|
|
memModelId: data.data.memModelId,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
intentModelId: data.data.intentModelId,
|
|
|
|
|
|
},
|
2025-04-05 21:03:46 +08:00
|
|
|
|
};
|
2025-05-29 00:58:20 +08:00
|
|
|
|
// 后端只给了最小映射:[{ id, agentId, pluginId }, ...]
|
|
|
|
|
|
const savedMappings = data.data.functions || [];
|
2025-12-05 11:24:57 +08:00
|
|
|
|
|
|
|
|
|
|
// 加载上下文配置
|
|
|
|
|
|
this.currentContextProviders = data.data.contextProviders || [];
|
2025-05-29 00:58:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 先保证 allFunctions 已经加载(如果没有,则先 fetchAllFunctions)
|
|
|
|
|
|
const ensureFuncs = this.allFunctions.length
|
2025-06-11 22:09:21 +08:00
|
|
|
|
? Promise.resolve()
|
|
|
|
|
|
: this.fetchAllFunctions();
|
2025-05-29 00:58:20 +08:00
|
|
|
|
|
|
|
|
|
|
ensureFuncs.then(() => {
|
|
|
|
|
|
// 合并:按照 pluginId(id 字段)把全量元数据信息补齐
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.currentFunctions = savedMappings.map((mapping) => {
|
|
|
|
|
|
const meta = this.allFunctions.find((f) => f.id === mapping.pluginId);
|
2025-05-29 00:58:20 +08:00
|
|
|
|
if (!meta) {
|
|
|
|
|
|
// 插件定义没找到,退化处理
|
|
|
|
|
|
return { id: mapping.pluginId, name: mapping.pluginId, params: {} };
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
id: mapping.pluginId,
|
|
|
|
|
|
name: meta.name,
|
|
|
|
|
|
// 后端如果还有 paramInfo 字段就用 mapping.paramInfo,否则用 meta.params 默认值
|
|
|
|
|
|
params: mapping.paramInfo || { ...meta.params },
|
2025-11-15 09:51:58 +08:00
|
|
|
|
fieldsMeta: meta.fieldsMeta, // 保留以便对话框渲染 tooltip
|
2025-05-29 00:58:20 +08:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
// 备份原始,以备取消时恢复
|
|
|
|
|
|
this.originalFunctions = JSON.parse(JSON.stringify(this.currentFunctions));
|
2025-07-25 21:47:21 +08:00
|
|
|
|
|
|
|
|
|
|
// 确保意图识别选项的可见性正确
|
|
|
|
|
|
this.updateIntentOptionsVisibility();
|
2025-05-29 00:58:20 +08:00
|
|
|
|
});
|
2025-04-05 21:03:46 +08:00
|
|
|
|
} else {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$message.error(data.msg || i18n.t("roleConfig.fetchConfigFailed"));
|
2025-04-05 21:03:46 +08:00
|
|
|
|
}
|
2025-03-28 11:20:08 +08:00
|
|
|
|
});
|
2025-04-05 20:19:28 +08:00
|
|
|
|
},
|
2025-04-06 15:45:18 +08:00
|
|
|
|
fetchModelOptions() {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.models.forEach((model) => {
|
2025-07-24 16:17:27 +08:00
|
|
|
|
if (model.type != "LLM") {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
Api.model.getModelNames(model.type, "", ({ data }) => {
|
2025-07-24 16:17:27 +08:00
|
|
|
|
if (data.code === 0) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$set(
|
|
|
|
|
|
this.modelOptions,
|
|
|
|
|
|
model.type,
|
|
|
|
|
|
data.data.map((item) => ({
|
|
|
|
|
|
value: item.id,
|
|
|
|
|
|
label: item.modelName,
|
|
|
|
|
|
isHidden: false,
|
|
|
|
|
|
}))
|
|
|
|
|
|
);
|
2025-07-25 21:47:21 +08:00
|
|
|
|
|
|
|
|
|
|
// 如果是意图识别选项,需要根据当前LLM类型更新可见性
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (model.type === "Intent") {
|
2025-07-25 21:47:21 +08:00
|
|
|
|
this.updateIntentOptionsVisibility();
|
|
|
|
|
|
}
|
2025-07-24 16:17:27 +08:00
|
|
|
|
} else {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$message.error(data.msg || i18n.t("roleConfig.fetchModelsFailed"));
|
2025-07-24 16:17:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
Api.model.getLlmModelCodeList("", ({ data }) => {
|
2025-07-24 16:17:27 +08:00
|
|
|
|
if (data.code === 0) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
let LLMdata = [];
|
|
|
|
|
|
data.data.forEach((item) => {
|
2025-07-24 16:17:27 +08:00
|
|
|
|
LLMdata.push({
|
|
|
|
|
|
value: item.id,
|
|
|
|
|
|
label: item.modelName,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
isHidden: false,
|
|
|
|
|
|
});
|
|
|
|
|
|
this.llmModeTypeMap.set(item.id, item.type);
|
|
|
|
|
|
});
|
2025-07-24 16:17:27 +08:00
|
|
|
|
this.$set(this.modelOptions, model.type, LLMdata);
|
|
|
|
|
|
} else {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$message.error(data.msg || "获取LLM模型列表失败");
|
2025-07-24 16:17:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-04-06 15:45:18 +08:00
|
|
|
|
});
|
2025-04-05 20:19:28 +08:00
|
|
|
|
},
|
2025-04-06 15:45:18 +08:00
|
|
|
|
fetchVoiceOptions(modelId) {
|
|
|
|
|
|
if (!modelId) {
|
|
|
|
|
|
this.voiceOptions = [];
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.voiceDetails = {};
|
2025-04-06 15:45:18 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-11-15 09:51:58 +08:00
|
|
|
|
Api.model.getModelVoices(modelId, "", ({ data }) => {
|
2025-04-06 15:45:18 +08:00
|
|
|
|
if (data.code === 0 && data.data) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.voiceOptions = data.data.map((voice) => ({
|
2025-04-06 15:45:18 +08:00
|
|
|
|
value: voice.id,
|
2025-11-15 09:51:58 +08:00
|
|
|
|
label: voice.name,
|
2025-11-15 10:45:22 +08:00
|
|
|
|
// 复制音频相关字段,确保hasAudioPreview能检测到
|
|
|
|
|
|
voiceDemo: voice.voiceDemo,
|
|
|
|
|
|
demoUrl: voice.demoUrl,
|
|
|
|
|
|
audioUrl: voice.audioUrl,
|
|
|
|
|
|
voice_demo: voice.voice_demo,
|
|
|
|
|
|
sample_voice: voice.sample_voice,
|
|
|
|
|
|
referenceAudio: voice.referenceAudio,
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 新增:添加克隆音频相关字段
|
|
|
|
|
|
cloneAudioUrl: voice.cloneAudioUrl,
|
2025-11-15 16:36:59 +08:00
|
|
|
|
hasCloneAudio: voice.hasCloneAudio || false,
|
|
|
|
|
|
// 保存训练状态字段,用于判断是否为克隆音频
|
|
|
|
|
|
train_status: voice.trainStatus,
|
2025-04-06 15:45:18 +08:00
|
|
|
|
}));
|
2025-11-15 09:51:58 +08:00
|
|
|
|
// 保存完整的音色信息,添加调试信息
|
2025-11-15 10:45:22 +08:00
|
|
|
|
console.log("获取到的音色数据:", data.data);
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.voiceDetails = data.data.reduce((acc, voice) => {
|
|
|
|
|
|
acc[voice.id] = voice;
|
|
|
|
|
|
return acc;
|
|
|
|
|
|
}, {});
|
2025-04-06 15:45:18 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.voiceOptions = [];
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.voiceDetails = {};
|
2025-04-06 15:45:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-05-12 14:10:05 +08:00
|
|
|
|
},
|
2025-11-10 15:10:59 +08:00
|
|
|
|
getFunctionDisplayChar(name) {
|
2025-11-17 18:05:10 +08:00
|
|
|
|
if (!name || name.length === 0) return "";
|
2025-11-13 11:01:28 +08:00
|
|
|
|
|
2025-11-10 15:10:59 +08:00
|
|
|
|
for (let i = 0; i < name.length; i++) {
|
|
|
|
|
|
const char = name[i];
|
|
|
|
|
|
if (/[\u4e00-\u9fa5a-zA-Z0-9]/.test(char)) {
|
|
|
|
|
|
return char;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-13 11:01:28 +08:00
|
|
|
|
|
2025-11-10 15:10:59 +08:00
|
|
|
|
// 如果没有找到有效字符,返回第一个字符
|
|
|
|
|
|
return name.charAt(0);
|
2025-05-12 14:10:05 +08:00
|
|
|
|
},
|
|
|
|
|
|
showFunctionIcons(type) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
return type === "Intent" && this.form.model.intentModelId !== "Intent_nointent";
|
2025-05-12 14:10:05 +08:00
|
|
|
|
},
|
|
|
|
|
|
handleModelChange(type, value) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (type === "Intent" && value !== "Intent_nointent") {
|
2025-05-29 00:58:20 +08:00
|
|
|
|
this.fetchAllFunctions();
|
2025-05-12 14:10:05 +08:00
|
|
|
|
}
|
2025-11-21 18:31:01 +08:00
|
|
|
|
if (type === "Memory") {
|
|
|
|
|
|
if (value === "Memory_nomem") {
|
2025-11-21 18:39:57 +08:00
|
|
|
|
// 无记忆功能的模型,默认不记录聊天记录
|
2025-11-21 18:31:01 +08:00
|
|
|
|
this.form.chatHistoryConf = 0;
|
2025-11-21 18:39:57 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
// 有记忆功能的模型,默认记录文本和语音
|
2025-11-21 18:31:01 +08:00
|
|
|
|
this.form.chatHistoryConf = 2;
|
|
|
|
|
|
}
|
2025-05-12 15:49:44 +08:00
|
|
|
|
}
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (type === "LLM") {
|
2025-07-25 21:47:21 +08:00
|
|
|
|
// 当LLM类型改变时,更新意图识别选项的可见性
|
|
|
|
|
|
this.updateIntentOptionsVisibility();
|
2025-07-24 16:17:27 +08:00
|
|
|
|
}
|
2025-05-12 14:10:05 +08:00
|
|
|
|
},
|
2025-05-29 00:58:20 +08:00
|
|
|
|
fetchAllFunctions() {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
Api.model.getPluginFunctionList(null, ({ data }) => {
|
|
|
|
|
|
if (data.code === 0) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.allFunctions = data.data.map((item) => {
|
|
|
|
|
|
const meta = JSON.parse(item.fields || "[]");
|
2025-05-29 00:58:20 +08:00
|
|
|
|
const params = meta.reduce((m, f) => {
|
|
|
|
|
|
m[f.key] = f.default;
|
|
|
|
|
|
return m;
|
|
|
|
|
|
}, {});
|
|
|
|
|
|
return { ...item, fieldsMeta: meta, params };
|
|
|
|
|
|
});
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
} else {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.$message.error(data.msg || i18n.t("roleConfig.fetchPluginsFailed"));
|
2025-05-29 00:58:20 +08:00
|
|
|
|
reject();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-05-12 14:10:05 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2025-05-29 00:58:20 +08:00
|
|
|
|
openFunctionDialog() {
|
|
|
|
|
|
// 显示编辑对话框时,确保 allFunctions 已经加载
|
|
|
|
|
|
if (this.allFunctions.length === 0) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.fetchAllFunctions().then(() => (this.showFunctionDialog = true));
|
2025-05-29 00:58:20 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.showFunctionDialog = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-12-05 11:24:57 +08:00
|
|
|
|
openContextProviderDialog() {
|
|
|
|
|
|
this.showContextProviderDialog = true;
|
|
|
|
|
|
},
|
|
|
|
|
|
handleUpdateContext(providers) {
|
|
|
|
|
|
this.currentContextProviders = providers;
|
|
|
|
|
|
},
|
2025-05-12 14:10:05 +08:00
|
|
|
|
handleUpdateFunctions(selected) {
|
|
|
|
|
|
this.currentFunctions = selected;
|
|
|
|
|
|
},
|
|
|
|
|
|
handleDialogClosed(saved) {
|
|
|
|
|
|
if (!saved) {
|
|
|
|
|
|
this.currentFunctions = JSON.parse(JSON.stringify(this.originalFunctions));
|
2025-05-29 00:58:20 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.originalFunctions = JSON.parse(JSON.stringify(this.currentFunctions));
|
2025-05-12 14:10:05 +08:00
|
|
|
|
}
|
2025-05-29 00:58:20 +08:00
|
|
|
|
this.showFunctionDialog = false;
|
2025-05-12 14:10:05 +08:00
|
|
|
|
},
|
2025-07-25 21:47:21 +08:00
|
|
|
|
updateIntentOptionsVisibility() {
|
|
|
|
|
|
// 根据当前选择的LLM类型更新意图识别选项的可见性
|
|
|
|
|
|
const currentLlmId = this.form.model.llmModelId;
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (!currentLlmId || !this.modelOptions["Intent"]) return;
|
2025-07-25 21:47:21 +08:00
|
|
|
|
|
|
|
|
|
|
const llmType = this.llmModeTypeMap.get(currentLlmId);
|
|
|
|
|
|
if (!llmType) return;
|
|
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.modelOptions["Intent"].forEach((item) => {
|
2025-07-25 21:47:21 +08:00
|
|
|
|
if (item.value === "Intent_function_call") {
|
|
|
|
|
|
// 如果llmType是openai或ollama,允许选择function_call
|
|
|
|
|
|
// 否则隐藏function_call选项
|
|
|
|
|
|
if (llmType === "openai" || llmType === "ollama") {
|
|
|
|
|
|
item.isHidden = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
item.isHidden = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 其他意图识别选项始终可见
|
|
|
|
|
|
item.isHidden = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 如果当前选择的意图识别是function_call,但LLM类型不支持,则设置为可选的第一项
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (
|
|
|
|
|
|
this.form.model.intentModelId === "Intent_function_call" &&
|
|
|
|
|
|
llmType !== "openai" &&
|
|
|
|
|
|
llmType !== "ollama"
|
|
|
|
|
|
) {
|
2025-07-25 21:47:21 +08:00
|
|
|
|
// 找到第一个可见的选项
|
2025-11-15 09:51:58 +08:00
|
|
|
|
const firstVisibleOption = this.modelOptions["Intent"].find(
|
|
|
|
|
|
(item) => !item.isHidden
|
|
|
|
|
|
);
|
2025-07-25 21:47:21 +08:00
|
|
|
|
if (firstVisibleOption) {
|
|
|
|
|
|
this.form.model.intentModelId = firstVisibleOption.value;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 如果没有可见选项,设置为Intent_nointent
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.form.model.intentModelId = "Intent_nointent";
|
2025-07-25 21:47:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-15 09:51:58 +08:00
|
|
|
|
// 检查是否有音频预览
|
|
|
|
|
|
hasAudioPreview(item) {
|
2025-11-15 16:36:59 +08:00
|
|
|
|
// 检查item中是否包含有效的音频URL字段或克隆音频字段
|
2025-11-17 10:15:53 +08:00
|
|
|
|
// 克隆音频通过hasCloneAudio标志或ID格式判断(非TTS开头的ID)
|
2025-11-15 16:36:59 +08:00
|
|
|
|
const isCloneAudio =
|
2025-11-17 11:39:11 +08:00
|
|
|
|
item.hasCloneAudio || (item.value && !item.value.startsWith("TTS"));
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
|
|
|
|
|
const audioFields = [
|
|
|
|
|
|
item.voiceDemo,
|
|
|
|
|
|
item.demoUrl,
|
|
|
|
|
|
item.audioUrl,
|
|
|
|
|
|
item.voice_demo,
|
|
|
|
|
|
item.sample_voice,
|
|
|
|
|
|
item.referenceAudio,
|
|
|
|
|
|
item.cloneAudioUrl, // 克隆音频的URL
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有任何音频字段是有效的URL
|
|
|
|
|
|
const hasUrlAudio = audioFields.some(
|
|
|
|
|
|
(field) =>
|
|
|
|
|
|
field !== undefined &&
|
|
|
|
|
|
field !== null &&
|
|
|
|
|
|
typeof field === "string" &&
|
2025-11-15 10:45:22 +08:00
|
|
|
|
field.trim() !== "" &&
|
|
|
|
|
|
field.toLowerCase().startsWith("http")
|
2025-11-15 16:36:59 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return hasUrlAudio || isCloneAudio;
|
2025-11-15 09:51:58 +08:00
|
|
|
|
},
|
2025-11-15 10:45:22 +08:00
|
|
|
|
|
|
|
|
|
|
// 播放/暂停音频切换
|
|
|
|
|
|
toggleAudioPlayback(voiceId) {
|
|
|
|
|
|
// 如果点击的是当前正在播放的音频,则切换暂停/播放状态
|
|
|
|
|
|
if (this.playingVoice && this.currentPlayingVoiceId === voiceId) {
|
|
|
|
|
|
if (this.isPaused) {
|
|
|
|
|
|
// 从暂停状态恢复播放
|
|
|
|
|
|
this.currentAudio.play().catch((error) => {
|
|
|
|
|
|
console.error("恢复播放失败:", error);
|
|
|
|
|
|
this.$message.warning("无法恢复播放音频");
|
|
|
|
|
|
});
|
|
|
|
|
|
this.isPaused = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 暂停播放
|
|
|
|
|
|
this.currentAudio.pause();
|
|
|
|
|
|
this.isPaused = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 否则开始播放新的音频
|
|
|
|
|
|
this.playVoicePreview(voiceId);
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
// 播放音色预览
|
|
|
|
|
|
playVoicePreview(voiceId = null) {
|
|
|
|
|
|
// 如果传入了voiceId,则使用传入的,否则使用当前选中的
|
|
|
|
|
|
const targetVoiceId = voiceId || this.form.ttsVoiceId;
|
2025-11-15 10:45:22 +08:00
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (!targetVoiceId) {
|
|
|
|
|
|
this.$message.warning("请先选择一个音色");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 停止当前正在播放的音频
|
|
|
|
|
|
if (this.currentAudio) {
|
|
|
|
|
|
this.currentAudio.pause();
|
|
|
|
|
|
this.currentAudio = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 10:45:22 +08:00
|
|
|
|
// 重置播放状态
|
|
|
|
|
|
this.isPaused = false;
|
|
|
|
|
|
this.currentPlayingVoiceId = targetVoiceId;
|
|
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
try {
|
|
|
|
|
|
// 从保存的音色详情中获取音频URL
|
|
|
|
|
|
const voiceDetail = this.voiceDetails[targetVoiceId];
|
2025-11-15 10:45:22 +08:00
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
// 添加调试信息
|
2025-11-15 10:45:22 +08:00
|
|
|
|
console.log("当前选择的音色ID:", targetVoiceId);
|
|
|
|
|
|
console.log("音色详情:", voiceDetail);
|
|
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
// 尝试多种可能的音频属性名
|
|
|
|
|
|
let audioUrl = null;
|
2025-11-15 16:06:58 +08:00
|
|
|
|
let isCloneAudio = false;
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (voiceDetail) {
|
2025-11-17 10:15:53 +08:00
|
|
|
|
// 首先检查是否是克隆音频(通过ID格式判断,非TTS开头的ID)
|
2025-11-15 16:36:59 +08:00
|
|
|
|
isCloneAudio =
|
|
|
|
|
|
voiceDetail.hasCloneAudio ||
|
2025-11-17 10:15:53 +08:00
|
|
|
|
(voiceDetail.id && !voiceDetail.id.startsWith("TTS"));
|
2025-11-17 11:39:11 +08:00
|
|
|
|
console.log(
|
|
|
|
|
|
"克隆音频判断结果:",
|
|
|
|
|
|
isCloneAudio,
|
|
|
|
|
|
"训练状态:",
|
|
|
|
|
|
voiceDetail.train_status
|
|
|
|
|
|
);
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 获取音频URL
|
|
|
|
|
|
if (isCloneAudio && voiceDetail.id) {
|
|
|
|
|
|
// 对于克隆音频,使用后端提供的正确接口
|
|
|
|
|
|
// 注意:这里需要通过两步获取音频URL
|
|
|
|
|
|
// 1. 首先获取音频下载ID
|
|
|
|
|
|
// 2. 然后使用这个ID构建播放URL
|
|
|
|
|
|
// 由于异步操作,我们需要先请求getAudioId
|
|
|
|
|
|
console.log("检测到克隆音频,准备获取音频URL:", voiceDetail.id);
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 创建一个Promise来处理异步获取音频URL的操作
|
|
|
|
|
|
const getCloneAudioUrl = () => {
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
|
// 首先调用getAudioId接口获取临时UUID
|
|
|
|
|
|
RequestService.sendRequest()
|
|
|
|
|
|
.url(`${getServiceUrl()}/voiceClone/audio/${voiceDetail.id}`)
|
2025-11-15 16:36:59 +08:00
|
|
|
|
.method("POST")
|
2025-11-15 16:06:58 +08:00
|
|
|
|
.success((res) => {
|
2025-11-17 11:39:11 +08:00
|
|
|
|
if (res.data.code === 0 && res.data.data) {
|
2025-11-17 10:15:53 +08:00
|
|
|
|
// 处理返回的数据格式,在res.data基础上再套一层.data
|
|
|
|
|
|
const audioId = res.data.data;
|
|
|
|
|
|
console.log("获取到的音频ID:", audioId);
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 使用返回的UUID构建播放URL
|
2025-11-17 10:15:53 +08:00
|
|
|
|
const playUrl = `${getServiceUrl()}/voiceClone/play/${audioId}`;
|
2025-11-15 16:06:58 +08:00
|
|
|
|
console.log("构建克隆音频播放URL:", playUrl);
|
|
|
|
|
|
resolve(playUrl);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error("获取音频ID失败:", res.msg);
|
|
|
|
|
|
resolve(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-11-17 11:39:11 +08:00
|
|
|
|
.networkFail((err) => {
|
2025-11-15 16:06:58 +08:00
|
|
|
|
console.error("请求音频ID接口失败:", err);
|
|
|
|
|
|
resolve(null);
|
|
|
|
|
|
})
|
|
|
|
|
|
.send();
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 设置播放状态
|
|
|
|
|
|
this.playingVoice = true;
|
|
|
|
|
|
// 创建Audio实例
|
|
|
|
|
|
this.currentAudio = new Audio();
|
|
|
|
|
|
// 设置音量
|
|
|
|
|
|
this.currentAudio.volume = 1.0;
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 设置超时,防止加载过长时间
|
|
|
|
|
|
const timeoutId = setTimeout(() => {
|
|
|
|
|
|
if (this.currentAudio && this.playingVoice) {
|
|
|
|
|
|
this.$message.warning("音频加载时间较长,请稍后重试");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 10000); // 10秒超时
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 监听播放错误
|
|
|
|
|
|
this.currentAudio.onerror = () => {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
console.error("克隆音频播放错误");
|
|
|
|
|
|
this.$message.warning("克隆音频播放失败");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
};
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 监听播放开始,清除超时
|
|
|
|
|
|
this.currentAudio.onplay = () => {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
};
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 监听播放结束
|
|
|
|
|
|
this.currentAudio.onended = () => {
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
};
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 处理异步获取URL并播放
|
|
|
|
|
|
getCloneAudioUrl().then((url) => {
|
|
|
|
|
|
if (url) {
|
|
|
|
|
|
// 设置音频URL并播放
|
|
|
|
|
|
this.currentAudio.src = url;
|
|
|
|
|
|
this.currentAudio.play().catch((error) => {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
console.error("播放克隆音频失败:", error);
|
|
|
|
|
|
this.$message.warning("无法播放克隆音频");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
this.$message.warning("获取克隆音频失败");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 返回,避免继续执行下面的普通音频播放逻辑
|
|
|
|
|
|
return;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 对于普通音频,尝试各种可能的URL字段
|
|
|
|
|
|
audioUrl =
|
|
|
|
|
|
voiceDetail.voiceDemo ||
|
|
|
|
|
|
voiceDetail.demoUrl ||
|
|
|
|
|
|
voiceDetail.audioUrl ||
|
|
|
|
|
|
voiceDetail.voice_demo ||
|
|
|
|
|
|
voiceDetail.sample_voice ||
|
|
|
|
|
|
voiceDetail.cloneAudioUrl; // 克隆音频URL
|
|
|
|
|
|
}
|
2025-11-15 10:45:22 +08:00
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
// 如果没有找到,尝试检查是否有URL格式的字段
|
|
|
|
|
|
if (!audioUrl) {
|
|
|
|
|
|
for (const key in voiceDetail) {
|
|
|
|
|
|
const value = voiceDetail[key];
|
2025-11-15 10:45:22 +08:00
|
|
|
|
if (
|
|
|
|
|
|
typeof value === "string" &&
|
|
|
|
|
|
(value.startsWith("http://") ||
|
|
|
|
|
|
value.startsWith("https://") ||
|
|
|
|
|
|
value.endsWith(".mp3") ||
|
|
|
|
|
|
value.endsWith(".wav") ||
|
|
|
|
|
|
value.endsWith(".ogg"))
|
|
|
|
|
|
) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
audioUrl = value;
|
|
|
|
|
|
console.log(`发现可能的音频URL在字段 '${key}':`, audioUrl);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-15 10:45:22 +08:00
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (!audioUrl) {
|
|
|
|
|
|
// 如果没有音频URL,显示友好的提示
|
|
|
|
|
|
this.$message.warning("该音色暂无可预览的音频");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 非克隆音频的处理逻辑
|
|
|
|
|
|
if (!isCloneAudio) {
|
|
|
|
|
|
// 设置播放状态
|
|
|
|
|
|
this.playingVoice = true;
|
2025-11-15 10:45:22 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 创建并播放音频
|
|
|
|
|
|
this.currentAudio = new Audio();
|
|
|
|
|
|
this.currentAudio.src = audioUrl;
|
2025-11-15 16:36:59 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 设置音量
|
|
|
|
|
|
this.currentAudio.volume = 1.0;
|
2025-11-15 09:51:58 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 设置超时,防止加载过长时间
|
|
|
|
|
|
const timeoutId = setTimeout(() => {
|
|
|
|
|
|
if (this.currentAudio && this.playingVoice) {
|
|
|
|
|
|
this.$message.warning("音频加载时间较长,请稍后重试");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 10000); // 10秒超时
|
2025-11-15 09:51:58 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 监听播放错误
|
|
|
|
|
|
this.currentAudio.onerror = () => {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
console.error("音频播放错误");
|
|
|
|
|
|
this.$message.warning("音频播放失败");
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.playingVoice = false;
|
2025-11-15 16:06:58 +08:00
|
|
|
|
};
|
2025-11-15 09:51:58 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 监听播放开始,清除超时
|
|
|
|
|
|
this.currentAudio.onplay = () => {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
};
|
2025-11-15 09:51:58 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 监听播放结束
|
|
|
|
|
|
this.currentAudio.onended = () => {
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
};
|
2025-11-15 09:51:58 +08:00
|
|
|
|
|
2025-11-15 16:06:58 +08:00
|
|
|
|
// 开始播放音频
|
|
|
|
|
|
this.currentAudio.play().catch((error) => {
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
console.error("播放失败:", error);
|
|
|
|
|
|
this.$message.warning("无法播放音频");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-11-15 09:51:58 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error("播放音频过程出错:", error);
|
|
|
|
|
|
this.$message.error("播放音频过程出错");
|
|
|
|
|
|
this.playingVoice = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-05-12 15:49:44 +08:00
|
|
|
|
updateChatHistoryConf() {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
if (this.form.model.memModelId === "Memory_nomem") {
|
2025-05-12 15:49:44 +08:00
|
|
|
|
this.form.chatHistoryConf = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-12-05 14:35:53 +08:00
|
|
|
|
// 加载功能状态
|
|
|
|
|
|
async loadFeatureStatus() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 确保featureManager已初始化完成
|
|
|
|
|
|
await featureManager.waitForInitialization();
|
|
|
|
|
|
const config = featureManager.getConfig();
|
|
|
|
|
|
this.featureStatus.voiceprintRecognition = config.voiceprintRecognition || false;
|
|
|
|
|
|
this.featureStatus.vad = config.vad || false;
|
|
|
|
|
|
this.featureStatus.asr = config.asr || false;
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error("加载功能状态失败:", error);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-04-06 15:45:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
"form.model.ttsModelId": {
|
2025-04-06 15:45:18 +08:00
|
|
|
|
handler(newVal, oldVal) {
|
|
|
|
|
|
if (oldVal && newVal !== oldVal) {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
this.form.ttsVoiceId = "";
|
2025-04-06 15:45:18 +08:00
|
|
|
|
this.fetchVoiceOptions(newVal);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.fetchVoiceOptions(newVal);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-15 09:51:58 +08:00
|
|
|
|
immediate: true,
|
2025-04-06 15:45:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
voiceOptions: {
|
|
|
|
|
|
handler(newVal) {
|
|
|
|
|
|
if (newVal && newVal.length > 0 && !this.form.ttsVoiceId) {
|
|
|
|
|
|
this.form.ttsVoiceId = newVal[0].value;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-15 09:51:58 +08:00
|
|
|
|
immediate: true,
|
|
|
|
|
|
},
|
2025-03-28 11:20:08 +08:00
|
|
|
|
},
|
2025-12-05 14:35:53 +08:00
|
|
|
|
async mounted() {
|
2025-03-24 17:27:08 +08:00
|
|
|
|
const agentId = this.$route.query.agentId;
|
|
|
|
|
|
if (agentId) {
|
|
|
|
|
|
this.fetchAgentConfig(agentId);
|
2025-05-29 00:58:20 +08:00
|
|
|
|
this.fetchAllFunctions();
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
2025-04-06 15:45:18 +08:00
|
|
|
|
this.fetchModelOptions();
|
|
|
|
|
|
this.fetchTemplates();
|
2025-12-05 14:35:53 +08:00
|
|
|
|
// 加载功能状态,确保featureManager已初始化
|
|
|
|
|
|
await this.loadFeatureStatus();
|
2025-11-15 09:51:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
};
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.welcome {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
min-width: 900px;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
height: 100vh;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
display: flex;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
position: relative;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
flex-direction: column;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd);
|
2025-03-14 23:48:59 +08:00
|
|
|
|
background-size: cover;
|
|
|
|
|
|
-webkit-background-size: cover;
|
|
|
|
|
|
-o-background-size: cover;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
overflow: hidden;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
2025-03-18 21:49:57 +08:00
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
.operation-bar {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
2025-05-08 17:57:11 +08:00
|
|
|
|
padding: 1.5vh 24px;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
.page-title {
|
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
color: #2c3e50;
|
2025-03-18 23:08:13 +08:00
|
|
|
|
}
|
2025-03-18 21:49:57 +08:00
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
.main-wrapper {
|
2025-05-08 17:57:11 +08:00
|
|
|
|
margin: 1vh 22px;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
border-radius: 15px;
|
|
|
|
|
|
height: calc(100vh - 24vh);
|
|
|
|
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
background: rgba(237, 242, 255, 0.5);
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.content-panel {
|
2025-03-14 23:48:59 +08:00
|
|
|
|
flex: 1;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
border-radius: 15px;
|
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
border: 1px solid #fff;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
.content-area {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
min-width: 600px;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
background-color: white;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
.config-card {
|
|
|
|
|
|
background: white;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.config-header {
|
2025-04-21 10:24:04 +08:00
|
|
|
|
position: relative;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
gap: 13px;
|
2025-04-16 14:25:46 +08:00
|
|
|
|
padding: 0 0 5px 0;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
font-size: 19px;
|
|
|
|
|
|
color: #3d4566;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-icon {
|
|
|
|
|
|
width: 37px;
|
|
|
|
|
|
height: 37px;
|
|
|
|
|
|
background: #5778ff;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-icon img {
|
|
|
|
|
|
width: 19px;
|
|
|
|
|
|
height: 19px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.divider {
|
|
|
|
|
|
height: 1px;
|
|
|
|
|
|
background: #e8f0ff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-content {
|
2025-05-08 17:57:11 +08:00
|
|
|
|
padding: 2vh 0;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-grid {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
|
|
gap: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-column {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-04-16 17:18:11 +08:00
|
|
|
|
gap: 6px;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-input {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-select {
|
|
|
|
|
|
width: 100%;
|
2025-11-15 09:51:58 +08:00
|
|
|
|
height: 36px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.play-button {
|
2025-11-15 10:45:22 +08:00
|
|
|
|
color: #409eff;
|
2025-11-15 09:51:58 +08:00
|
|
|
|
transition: color 0.3s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.play-button:hover {
|
|
|
|
|
|
color: #66b1ff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.play-button.is-loading {
|
|
|
|
|
|
color: #909399;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-textarea {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 09:51:58 +08:00
|
|
|
|
.voice-select-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
.template-container {
|
|
|
|
|
|
display: flex;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
gap: 8px;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
flex-wrap: wrap;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.template-item {
|
2025-05-08 17:57:11 +08:00
|
|
|
|
height: 4vh;
|
2025-11-18 10:21:53 +08:00
|
|
|
|
min-width: 60px;
|
|
|
|
|
|
padding: 0 12px;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
border-radius: 8px;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
background: #e6ebff;
|
2025-05-08 17:57:11 +08:00
|
|
|
|
line-height: 4vh;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
font-weight: 400;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
font-size: 11px;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
color: #5778ff;
|
2025-03-18 23:08:13 +08:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: background-color 0.3s ease;
|
2025-11-18 10:21:53 +08:00
|
|
|
|
white-space: nowrap;
|
2025-03-18 23:08:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.template-item:hover {
|
|
|
|
|
|
background-color: #d0d8ff;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-12 14:10:05 +08:00
|
|
|
|
.model-select-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-01 13:34:32 +08:00
|
|
|
|
.model-row {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 20px;
|
|
|
|
|
|
margin-bottom: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.model-row .model-item {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.model-row .el-form-item__label {
|
|
|
|
|
|
font-size: 12px !important;
|
|
|
|
|
|
color: #3d4566 !important;
|
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
padding-bottom: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-12 14:10:05 +08:00
|
|
|
|
.function-icons {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-left: auto;
|
|
|
|
|
|
padding-left: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.icon-dot {
|
|
|
|
|
|
width: 25px;
|
|
|
|
|
|
height: 25px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2025-11-13 11:01:28 +08:00
|
|
|
|
color: #5778ff;
|
2025-05-12 14:10:05 +08:00
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
position: relative;
|
2025-11-13 11:01:28 +08:00
|
|
|
|
background-color: #e6ebff;
|
2025-05-12 14:10:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-16 11:17:02 +08:00
|
|
|
|
::v-deep .el-form-item__label {
|
2025-05-12 14:16:08 +08:00
|
|
|
|
font-size: 12px !important;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
color: #3d4566 !important;
|
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
padding-bottom: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
::v-deep .el-textarea .el-input__count {
|
|
|
|
|
|
color: #909399;
|
|
|
|
|
|
background: none;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
font-size: 12px;
|
2025-04-21 10:24:04 +08:00
|
|
|
|
right: 3%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.custom-close-btn {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 25%;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
|
width: 35px;
|
|
|
|
|
|
height: 35px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
border: 2px solid #cfcfcf;
|
|
|
|
|
|
background: none;
|
|
|
|
|
|
font-size: 30px;
|
|
|
|
|
|
font-weight: lighter;
|
|
|
|
|
|
color: #cfcfcf;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
outline: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.custom-close-btn:hover {
|
2025-11-15 09:51:58 +08:00
|
|
|
|
color: #409eff;
|
|
|
|
|
|
border-color: #409eff;
|
2025-04-16 11:17:02 +08:00
|
|
|
|
}
|
2025-05-12 14:10:05 +08:00
|
|
|
|
|
|
|
|
|
|
.edit-function-btn {
|
|
|
|
|
|
background: #e6ebff;
|
|
|
|
|
|
color: #5778ff;
|
|
|
|
|
|
border: 1px solid #adbdff;
|
|
|
|
|
|
border-radius: 18px;
|
|
|
|
|
|
padding: 10px 20px;
|
|
|
|
|
|
transition: all 0.3s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.edit-function-btn.active-btn {
|
|
|
|
|
|
background: #5778ff;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-12 15:49:44 +08:00
|
|
|
|
.chat-history-options {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 10px;
|
|
|
|
|
|
min-width: 250px;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
}
|
2025-05-14 12:09:29 +08:00
|
|
|
|
|
2025-12-05 18:08:26 +08:00
|
|
|
|
.chat-history-options ::v-deep .el-radio-button {
|
|
|
|
|
|
border-color: #5778ff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chat-history-options ::v-deep .el-radio-button .el-radio-button__inner {
|
|
|
|
|
|
color: #5778ff;
|
|
|
|
|
|
border-color: #5778ff;
|
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chat-history-options ::v-deep .el-radio-button.is-active .el-radio-button__inner {
|
|
|
|
|
|
background-color: #5778ff;
|
|
|
|
|
|
border-color: #5778ff;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chat-history-options ::v-deep .el-radio-button .el-radio-button__inner:hover {
|
|
|
|
|
|
color: #5778ff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-14 12:09:29 +08:00
|
|
|
|
.header-actions {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
margin-left: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-actions .hint-text {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
color: #979db1;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-actions .hint-text img {
|
|
|
|
|
|
width: 16px;
|
|
|
|
|
|
height: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-actions .save-btn {
|
|
|
|
|
|
background: #5778ff;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
border-radius: 18px;
|
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-actions .reset-btn {
|
|
|
|
|
|
background: #e6ebff;
|
|
|
|
|
|
color: #5778ff;
|
|
|
|
|
|
border: 1px solid #adbdff;
|
|
|
|
|
|
border-radius: 18px;
|
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-actions .custom-close-btn {
|
|
|
|
|
|
position: static;
|
|
|
|
|
|
transform: none;
|
|
|
|
|
|
width: 32px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
}
|
2025-12-05 11:24:57 +08:00
|
|
|
|
|
|
|
|
|
|
.context-provider-item ::v-deep .el-form-item__label {
|
|
|
|
|
|
line-height: 42px !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.doc-link {
|
2025-12-05 18:08:26 +08:00
|
|
|
|
color: #5778ff;
|
2025-12-05 11:24:57 +08:00
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-15 09:51:58 +08:00
|
|
|
|
</style>
|