香港数字人接口对接
This commit is contained in:
parent
2b6a8cba20
commit
006aa04a7f
@ -35,12 +35,12 @@ jobs:
|
||||
uses: https://gitea.yantootech.com/neil/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: hub.kce.ksyun.com/yantoo/yantoo-repository/baidu-digital-human-app:${{ gitea.run_id }}
|
||||
tags: hub.kce.ksyun.com/yantoo/yantoo-repository/xg-digital-human-app:${{ gitea.run_id }}
|
||||
- name: Install
|
||||
run: |
|
||||
helm upgrade --install baidu-digital-human-app ./.gitea/charts \
|
||||
helm upgrade --install xg-digital-human-app ./.gitea/charts \
|
||||
--namespace digital-human-prod \
|
||||
--create-namespace \
|
||||
--set image.repository=hub.kce.ksyun.com/yantoo/yantoo-repository/baidu-digital-human-app \
|
||||
--set image.repository=hub.kce.ksyun.com/yantoo/yantoo-repository/xg-digital-human-app \
|
||||
--set image.tag=${{ gitea.run_id }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
|
||||
12
src/App.vue
12
src/App.vue
@ -465,7 +465,7 @@ import SubtitlePanel from "@/components/SubtitlePanel.vue";
|
||||
import { useDigitalHuman } from "@/hooks/useDigitalHuman";
|
||||
import { useLLM } from "@/hooks/useLLM";
|
||||
|
||||
const { sendToLLM } = useLLM();
|
||||
const { sendToChatBase } = useLLM();
|
||||
|
||||
const {
|
||||
isConnected,
|
||||
@ -522,23 +522,21 @@ const hasSubstantialContent = (text: string): boolean => {
|
||||
async function handleVoiceQueryComplete(text: string) {
|
||||
if (!text.trim() || !hasSubstantialContent(text)) return;
|
||||
try {
|
||||
const reply = await sendToLLM(text);
|
||||
const reply = await sendToChatBase(text);
|
||||
if (reply) {
|
||||
textRender(reply);
|
||||
} else {
|
||||
// LLM返回空回复,恢复空闲状态
|
||||
setPickPhase("idle", "LLM返回空回复");
|
||||
setPickPhase("idle", "ChatBase返回空回复");
|
||||
if (audioMode.value === "rtc") {
|
||||
changeMicrophoneState(false);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
// LLM请求失败,恢复空闲状态
|
||||
setPickPhase("idle", "LLM请求失败");
|
||||
setPickPhase("idle", "ChatBase请求失败");
|
||||
if (audioMode.value === "rtc") {
|
||||
changeMicrophoneState(false);
|
||||
}
|
||||
ElMessage.error(`大模型请求失败: ${err.message || "未知错误"}`);
|
||||
ElMessage.error(`ChatBase请求失败: ${err.message || "未知错误"}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -7,7 +7,7 @@ import { TokenManager } from "@/utils/tokenManager";
|
||||
import type { ChatMessage, SubtitleMode } from "@/types";
|
||||
|
||||
const DEFAULT_TEXT =
|
||||
"你好,我是东航小云,请问有什么需要帮忙的吗?";
|
||||
"你好,我是GP超霸博士,请问有什么需要帮忙的吗?";
|
||||
const OPENING_TTS_DELAY_MS = 200;
|
||||
const SILENCE_TIMEOUT_MS = 5000;
|
||||
// 最短有效语音时长(秒),低于此时长视为无效输入
|
||||
|
||||
@ -5,11 +5,21 @@ const LLM_API_URL =
|
||||
"https://ai.yantootech.com/polyhedron/api/ark/chat/completions";
|
||||
const DEFAULT_MODEL = "bot-20260605135355-68pth";
|
||||
|
||||
// ChatBase API 配置
|
||||
const CHATBASE_API_URL = "https://www.chatbase.co/api/v1/chat";
|
||||
const CHATBASE_API_KEY = "ca4616db-417c-4dce-8c65-b9909621f53e";
|
||||
const CHATBASE_CHATBOT_ID = "TRIe58TuVExBm6K0HKTfz";
|
||||
|
||||
interface LLMMessage {
|
||||
role: "system" | "user" | "assistant";
|
||||
content: string;
|
||||
}
|
||||
|
||||
interface ChatBaseMessage {
|
||||
content: string;
|
||||
role: "user";
|
||||
}
|
||||
|
||||
interface LLMChoice {
|
||||
index: number;
|
||||
message: {
|
||||
@ -105,11 +115,63 @@ export function useLLM() {
|
||||
conversationHistory.value = [];
|
||||
};
|
||||
|
||||
const sendToChatBase = async (userMessage: string): Promise<string> => {
|
||||
if (!userMessage.trim()) return "";
|
||||
|
||||
isLoading.value = true;
|
||||
error.value = "";
|
||||
|
||||
try {
|
||||
const messages: ChatBaseMessage[] = [
|
||||
{ content: userMessage, role: "user" },
|
||||
];
|
||||
|
||||
const response = await fetch(CHATBASE_API_URL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${CHATBASE_API_KEY}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
chatbotId: CHATBASE_CHATBOT_ID,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP错误: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const aiReply = data.text || "";
|
||||
|
||||
conversationHistory.value.push({
|
||||
role: "user",
|
||||
content: userMessage,
|
||||
});
|
||||
|
||||
conversationHistory.value.push({
|
||||
role: "assistant",
|
||||
content: aiReply,
|
||||
});
|
||||
|
||||
return aiReply;
|
||||
} catch (err: any) {
|
||||
const errorMsg = err.message || "请求失败";
|
||||
error.value = errorMsg;
|
||||
console.error("ChatBase请求错误:", err);
|
||||
throw err;
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
error,
|
||||
conversationHistory,
|
||||
sendToLLM,
|
||||
sendToChatBase,
|
||||
clearHistory,
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user