|
@@ -100,6 +100,7 @@
|
|
<i class="el-icon-upload2"></i>
|
|
<i class="el-icon-upload2"></i>
|
|
</button>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
+ <!-- <button @click="playAudio" class="btn">播放音频</button> -->
|
|
<button @click="sendMessage" class="btn">发送</button>
|
|
<button @click="sendMessage" class="btn">发送</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -204,6 +205,15 @@ export default {
|
|
this.init();
|
|
this.init();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ /* 播放音频 */
|
|
|
|
+ playAudio(audioBase64) {
|
|
|
|
+ console.log(audioBase64);
|
|
|
|
+ // 创建音频元素
|
|
|
|
+ const audio = new Audio(audioBase64); // 播放音频
|
|
|
|
+ audio.play().catch((error) => {
|
|
|
|
+ console.error("Error playing audio:", error);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
async handleFileUpload(event) {
|
|
async handleFileUpload(event) {
|
|
const files = Array.from(event.target.files);
|
|
const files = Array.from(event.target.files);
|
|
|
|
|
|
@@ -402,9 +412,9 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const chatId = this.getUuid();
|
|
const chatId = this.getUuid();
|
|
- const wsUrl = `${process.env.VUE_APP_BASE_API}/chatbot/multimodal`;
|
|
|
|
|
|
+ const wsUrl = `${"http://192.168.66.187:8082"}/chatbot/multimodal`; //process.env.VUE_APP_BASE_API
|
|
let message = this.userInput.trim();
|
|
let message = this.userInput.trim();
|
|
-
|
|
|
|
|
|
+
|
|
const imageUrls = this.uploadFiles
|
|
const imageUrls = this.uploadFiles
|
|
.filter((file) => file.type.startsWith("image/"))
|
|
.filter((file) => file.type.startsWith("image/"))
|
|
.map((file) => file.url);
|
|
.map((file) => file.url);
|
|
@@ -441,23 +451,25 @@ export default {
|
|
|
|
|
|
try {
|
|
try {
|
|
const response = await axios({
|
|
const response = await axios({
|
|
- method: 'post',
|
|
|
|
|
|
+ method: "post",
|
|
url: wsUrl,
|
|
url: wsUrl,
|
|
data: {
|
|
data: {
|
|
message: message,
|
|
message: message,
|
|
chat_config_id: "17",
|
|
chat_config_id: "17",
|
|
user_id: this.phone,
|
|
user_id: this.phone,
|
|
session_id: this.session_id || "",
|
|
session_id: this.session_id || "",
|
|
- source: 'pc',
|
|
|
|
|
|
+ source: "pc",
|
|
image_urls: imageUrls,
|
|
image_urls: imageUrls,
|
|
- history_limit: 10
|
|
|
|
- }
|
|
|
|
|
|
+ //history_limit: 10
|
|
|
|
+ },
|
|
});
|
|
});
|
|
|
|
|
|
this.session_id = response.data.data.session_id;
|
|
this.session_id = response.data.data.session_id;
|
|
-
|
|
|
|
|
|
+
|
|
if (response.data.code !== 200) {
|
|
if (response.data.code !== 200) {
|
|
- throw new Error(`HTTP error! status: ${response.status}, message: ${response.data.message}`);
|
|
|
|
|
|
+ throw new Error(
|
|
|
|
+ `HTTP error! status: ${response.status}, message: ${response.data.message}`
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
thinkingController.abort();
|
|
thinkingController.abort();
|
|
@@ -470,16 +482,21 @@ export default {
|
|
console.log("ID Object:", idObject);
|
|
console.log("ID Object:", idObject);
|
|
await this.getMinioUrls(idObject);
|
|
await this.getMinioUrls(idObject);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ // 如果有音频,播放音频
|
|
|
|
+ if (
|
|
|
|
+ response.data.data.audio_info &&
|
|
|
|
+ response.data.data.audio_info.audio_base64
|
|
|
|
+ ) {
|
|
|
|
+ this.playAudio(response.data.data.audio_info.audio_base64);
|
|
|
|
+ }
|
|
this.handleResponse(response.data, botMessage);
|
|
this.handleResponse(response.data, botMessage);
|
|
-
|
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error("Error sending message:", error);
|
|
console.error("Error sending message:", error);
|
|
thinkingController.abort();
|
|
thinkingController.abort();
|
|
await thinkingPromise;
|
|
await thinkingPromise;
|
|
botMessage.done = true;
|
|
botMessage.done = true;
|
|
botMessage.message = "抱歉,发生了错误,请稍后再试。";
|
|
botMessage.message = "抱歉,发生了错误,请稍后再试。";
|
|
-
|
|
|
|
|
|
+
|
|
if (error.response) {
|
|
if (error.response) {
|
|
console.error("Response data:", error.response.data);
|
|
console.error("Response data:", error.response.data);
|
|
console.error("Response status:", error.response.status);
|
|
console.error("Response status:", error.response.status);
|