import { defineComponent, ref, reactive, computed, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrRenderAttr, ssrInterpolate, ssrRenderStyle, ssrRenderClass, ssrRenderComponent } from 'vue/server-renderer'; import { u as useApi } from './useApi-B-E5eLsI.mjs'; import { u as useToast } from './useToast-CS21XT61.mjs'; import { L as LANG_OPTIONS } from './useLangOptions-DMhiAuTa.mjs'; import { _ as __nuxt_component_0 } from './LangSelect-C_QPlcDf.mjs'; import { _ as _export_sfc } from './server.mjs'; import './useLoading-D4zrSa2m.mjs'; import '../nitro/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:path'; import 'node:crypto'; import 'node:url'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import 'pinia'; import 'perfect-debounce'; const CAT_STT = 1; const CAT_TTS = 2; const CAT_MT = 3; const CAT_AST = 4; const CAT_LLM = 5; const CAT_STS = 7; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "agents", __ssrInlineRender: true, setup(__props) { const AGENT_TYPES = [ { value: "chat", label: "对话", icon: "💬", hint: "STT → LLM → TTS 三段拼接", color: "#b45309", bg: "#fef9c3" }, { value: "translate", label: "翻译", icon: "🧩", hint: "STT → MT → TTS 三段拼接", color: "#059669", bg: "#dcfce7" }, { value: "sts-chat", label: "端到端对话", icon: "⚡", hint: "单个 STS 服务直接完成语音对话", color: "#be185d", bg: "#fce7f3" }, { value: "ast-translate", label: "端到端翻译", icon: "🚀", hint: "单个 AST 服务直接完成语音翻译", color: "#c2410c", bg: "#fff7ed" } ]; const SLOTS = { chat: [ { key: "stt_svc_id", slot: "STT", label: "语音识别", cat: CAT_STT, color: "#1664ff" }, { key: "llm_svc_id", slot: "LLM", label: "大语言模型", cat: CAT_LLM, color: "#b45309" }, { key: "tts_svc_id", slot: "TTS", label: "语音合成", cat: CAT_TTS, color: "#7c3aed" } ], translate: [ { key: "stt_svc_id", slot: "STT", label: "语音识别", cat: CAT_STT, color: "#1664ff" }, { key: "mt_svc_id", slot: "MT", label: "机器翻译", cat: CAT_MT, color: "#059669" }, { key: "tts_svc_id", slot: "TTS", label: "语音合成", cat: CAT_TTS, color: "#7c3aed" } ], "sts-chat": [{ key: "sts_svc_id", slot: "STS", label: "端到端语音对话", cat: CAT_STS, color: "#be185d" }], "ast-translate": [{ key: "ast_svc_id", slot: "AST", label: "端到端语音翻译", cat: CAT_AST, color: "#f97316" }] }; function slotsOfType(t) { return SLOTS[t] ?? []; } useApi(); useToast(); const scopeApp = ref(""); const scopeApps = ref([]); const agents2 = ref([]); const allSvcs = ref([]); const modalOpen = ref(false); const isEditing = ref(false); const submitting = ref(false); function emptyForm() { return { app_name: "", id: "", name: "", type: "translate", description: "", avatar_url: "", enable: true, stt_svc_id: "", llm_svc_id: "", tts_svc_id: "", mt_svc_id: "", sts_svc_id: "", ast_svc_id: "", system_prompt: "", gender: 0, greeting_enabled: false, greeting_text: "", support_langs: "", default_lang: "", voice_map: [], sort: 0 }; } const form = reactive(emptyForm()); const isChatType = computed(() => form.type === "chat" || form.type === "sts-chat"); const supportedLangOptions = computed(() => { const codes = (form.support_langs || "").split(",").map((x) => x.trim()).filter(Boolean); if (!codes.length) return LANG_OPTIONS; return LANG_OPTIONS.filter((o) => codes.includes(o.code)); }); const grouped = computed( () => AGENT_TYPES.map((t) => ({ ...t, type: t.value, items: agents2.value.filter((a) => a.type === t.value).sort((a, b) => (b.sort || 0) - (a.sort || 0) || (a.name || "").localeCompare(b.name || "")) })).filter((g) => g.items.length) ); function svcsByCat(cat) { return allSvcs.value.filter( (s) => s.enable && (s.categories || "").split(",").map(Number).includes(cat) ); } function svcName(id) { if (!id) return "未配置"; const s = allSvcs.value.find((x) => x.id === id); return s ? s.name : id; } function pipelineOf(a) { return slotsOfType(a.type).map((s) => ({ slot: s.slot, color: s.color, id: a[s.key] })); } return (_ctx, _push, _parent, _attrs) => { _push(`

Agent 配置

把已配置的第三方服务编排成可下发客户端的智能体。四种类型按需引用不同服务;通话翻译规则只能引用「翻译」与「端到端翻译」两类。

作用域
`); if (!agents2.value.length) { _push(`
🤖

当前作用域下还没有 Agent

先在「第三方服务配置」里配好服务,再来把它们组装成 Agent

`); } else { _push(``); } _push(``); ssrRenderList(grouped.value, (g) => { _push(`
${ssrInterpolate(g.icon)} ${ssrInterpolate(g.label)}${ssrInterpolate(g.hint)}·${ssrInterpolate(g.items.length)} 个
`); ssrRenderList(g.items, (a) => { _push(`
${ssrInterpolate(a.name || a.id)}
${ssrInterpolate(a.id)}
`); if (a.enable) { _push(`启用`); } else { _push(`停用`); } _push(`
`); if (a.description) { _push(`

${ssrInterpolate(a.description)}

`); } else { _push(``); } _push(`
`); ssrRenderList(pipelineOf(a), (s) => { _push(`${ssrInterpolate(s.slot)}: ${ssrInterpolate(svcName(s.id))}`); }); _push(`
`); if (a.support_langs) { _push(`
支持语言:${ssrInterpolate(a.support_langs)}
`); } else { _push(``); } _push(`
`); }); _push(`
`); }); _push(`

${ssrInterpolate(isEditing.value ? "编辑 Agent" : "新建 Agent")}

${ssrInterpolate(scopeApp.value || "全局默认")}
类型
`); ssrRenderList(AGENT_TYPES, (t) => { _push(``); }); _push(`
`); if (isEditing.value) { _push(`

类型创建后不可更改;需要换类型请新建一个 Agent。

`); } else { _push(``); } _push(`
基本信息
Agent ID *
名称 *
描述
头像 URL
排序(越大越靠前)
音色性别偏好
服务编排
`); ssrRenderList(slotsOfType(form.type), (s, i) => { _push(`
${ssrInterpolate(s.slot)}${ssrInterpolate(s.label)}
`); if (i < slotsOfType(form.type).length - 1) { _push(`→`); } else { _push(``); } _push(``); }); _push(`
语言与音色
支持语言(多选)`); _push(ssrRenderComponent(__nuxt_component_0, { modelValue: form.support_langs, "onUpdate:modelValue": ($event) => form.support_langs = $event, multiple: "" }, null, _parent)); _push(`
默认语言`); _push(ssrRenderComponent(__nuxt_component_0, { modelValue: form.default_lang, "onUpdate:modelValue": ($event) => form.default_lang = $event, options: supportedLangOptions.value }, null, _parent)); _push(`
音色覆盖(不填则用 TTS 服务自带默认音色)
`); if (!form.voice_map.length) { _push(`
未设置音色覆盖
`); } else { _push(``); } _push(``); ssrRenderList(form.voice_map, (v, i) => { _push(`
`); }); _push(`
`); if (isChatType.value) { _push(`
对话设定
系统提示词
`); if (form.greeting_enabled) { _push(``); } else { _push(``); } _push(`
`); } else { _push(``); } _push(`
`); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/agents.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; const agents = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-463df649"]]); export { agents as default }; //# sourceMappingURL=agents-sIgrTlD1.mjs.map