This commit is contained in:
zrh050423 2024-12-21 01:44:17 +08:00
parent 515c6beba9
commit 34d84fa02f
2 changed files with 9 additions and 5 deletions

View File

@ -74,6 +74,7 @@ import { House, Document, ChatLineRound, Files, DataLine, User } from '@element-
const isCollapse = ref(false)
const activeIndex = ref('/home')
</script>
<style scoped>

View File

@ -27,14 +27,15 @@
<script setup>
import { ref } from 'vue';
import axios from 'axios';
import axiosInstance from '@/utils/axiosInstance';
const inputMessage = ref('');
const messages = ref([]);
const Base_URL = '/talk/main';
const callBackend = async (message) => {
try {
const response = await axios.post('http://127.0.0.1:8080/talk/main', {
const response = await axiosInstance.post(Base_URL,
{
"model":"glm4:latest",
"prompt": message,
"stream": false
@ -43,7 +44,9 @@ const callBackend = async (message) => {
'Content-Type': 'application/json; charset=utf-8'
}
});
return response.data.data;
console.log('请求成功:', response.data.response)
return response;
} catch (error) {
console.error('Error calling backend:', error);
if (error.response) {
@ -71,7 +74,7 @@ const sendMessage = async () => {
try {
const response = await callBackend(putmessage);
messages.value.push({ sender: '医小慧', content: response.response });
messages.value.push({ sender: '医小慧', content: response.data.response });
} catch (error) {
//
console.error('请求失败:', error); //