|
@@ -45,6 +45,9 @@ const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
const routeParam = ref(null);
|
|
|
|
|
|
+// AI 客服回覆訊息
|
|
|
+let messages = ref([]);
|
|
|
+
|
|
|
let qrCodeDialog = ref(false);
|
|
|
let qrCodeLoading = ref(true);
|
|
|
let location = ref(""); // 當前位置
|
|
@@ -130,9 +133,6 @@ onMounted(() => {
|
|
|
const userMessage = ref("");
|
|
|
let modules = [Navigation, Autoplay]; // Swiper
|
|
|
|
|
|
-// AI 客服回覆訊息
|
|
|
-let messages = ref([]);
|
|
|
-
|
|
|
watch(messages.value, (val) => {
|
|
|
scrollToBottom();
|
|
|
updateMenuHeight();
|
|
@@ -169,18 +169,32 @@ function setBtnValue(val) {
|
|
|
sendMessage("text");
|
|
|
}
|
|
|
|
|
|
+let questions = reactive([
|
|
|
+ "觀景台營業時間",
|
|
|
+ "測試",
|
|
|
+ "台北101幾號出口?",
|
|
|
+ "請問停車收費方式",
|
|
|
+ "台北101有多高",
|
|
|
+ "有素食餐廳嗎",
|
|
|
+ "台北101樓層介紹",
|
|
|
+ "請問101觀景台可以帶寵物嗎",
|
|
|
+ "美食街怎麼走",
|
|
|
+ "台北101美食",
|
|
|
+ "台北101有置物櫃嗎",
|
|
|
+ "台北101觀景台需要預約嗎?",
|
|
|
+ "觀景台可以使用美金付款嗎",
|
|
|
+ "台北101世界第幾高2024?",
|
|
|
+ "台北101品牌",
|
|
|
+]);
|
|
|
+
|
|
|
// 傳送訊息 (如 type="text" 代表為純文字訊息,不需語音回覆)
|
|
|
async function sendMessage(type = "") {
|
|
|
- if (userMessage.value === "") {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
let question = userMessage.value;
|
|
|
qaQuery.push(question);
|
|
|
|
|
|
- let url = "https://api.itri-101-5g.com/v1/qa/";
|
|
|
-
|
|
|
- try {
|
|
|
+ if (userMessage.value === "") {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
// 使用者訊息
|
|
|
messages.value.push({
|
|
|
label: "text",
|
|
@@ -188,6 +202,33 @@ async function sendMessage(type = "") {
|
|
|
author: "user",
|
|
|
});
|
|
|
|
|
|
+ const isQuestionIncluded = questions.includes(userMessage.value);
|
|
|
+
|
|
|
+ if (isQuestionIncluded) {
|
|
|
+ let answer = await getVideoCache(userMessage.value);
|
|
|
+
|
|
|
+ // AI 客服回傳訊息
|
|
|
+ messages.value.push({
|
|
|
+ label: "text",
|
|
|
+ author: "ai",
|
|
|
+ body: videoCacheData.value.answer,
|
|
|
+ });
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log("是否包含", isQuestionIncluded);
|
|
|
+ }
|
|
|
+
|
|
|
+ let url = "https://api.itri-101-5g.com/v1/qa/";
|
|
|
+
|
|
|
+ try {
|
|
|
+ // // 使用者訊息
|
|
|
+ // messages.value.push({
|
|
|
+ // label: "text",
|
|
|
+ // body: question,
|
|
|
+ // author: "user",
|
|
|
+ // });
|
|
|
+
|
|
|
userMessage.value = "";
|
|
|
// hideMenu.value = true;
|
|
|
|
|
@@ -2555,6 +2596,26 @@ async function clickBtn(type, brand, item) {
|
|
|
console.log("error", error);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+let videoCacheData = ref({});
|
|
|
+
|
|
|
+async function getVideoCache(messages) {
|
|
|
+ let lang = getLang();
|
|
|
+
|
|
|
+ let url = `https://cmm.ai:9101/video_cache?client_message=${messages}&language=${lang}`;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const response = await axios.post(url);
|
|
|
+ console.log("response", response);
|
|
|
+ console.log("response.status", response.status);
|
|
|
+ if (response.data.state === 200) {
|
|
|
+ videoCacheData.value = response.data.message[0];
|
|
|
+ return videoCacheData.value.answer;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error);
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|