Browse Source

ai接口修改

liuqiang 1 year ago
parent
commit
e26436b633
2 changed files with 16 additions and 8 deletions
  1. 10 3
      src/api/chatglm/chatglm.js
  2. 6 5
      src/layout/components/AIPage/AIPage.vue

+ 10 - 3
src/api/chatglm/chatglm.js

@@ -1,9 +1,9 @@
 import request from '@/utils/request'
 export function chat(data) {
     return request({
-        url: '/chat-glm3',
-        method: 'post',
-        data: data,
+        url: '/chat-glm3/chat',
+        method: 'get',
+        params: data,
         timeout: 1000*60*5,
         headers: {
             'Content-Type': 'application/json'
@@ -16,4 +16,11 @@ export function canChat(data) {
         method: 'get',
         data: data
     })
+}
+export function getUuid(data) {
+    return request({
+        url: '/chat-glm3',
+        method: 'post',
+        data: data
+    })
 }

+ 6 - 5
src/layout/components/AIPage/AIPage.vue

@@ -54,7 +54,7 @@
 
 <script setup>
 import { ref, computed, watch, onMounted } from "vue";
-import { chat } from "@/api/chatglm/chatglm.js";
+import { chat,getUuid } from "@/api/chatglm/chatglm.js";
 import useUserStore from "@/store/modules/user";
 import send from "@/assets/images/send.png";
 import { getToken } from "@/utils/auth";
@@ -79,7 +79,7 @@ const msg = ref([
 // 这里的数值可能需要根据实际的CSS调整
 const baseInputHeight = 52;
 const maxInputHeight = 115;
-const enterChat = () => {
+const enterChat =async () => {
   if (disabled.value) return;
   disabled.value = true;
   const newUser = {
@@ -97,9 +97,10 @@ const enterChat = () => {
     const longArr = msg.value.slice(msg.value.length - 11, msg.value.length);
     query = [msg.value[0], ...longArr];
   }
-  fetch(`${wangzhi}/chat-glm3`, {
-    method: "post",
-    body: JSON.stringify(query),
+  const uuid = await getUuid(query)
+  // console.log("uuid", uuid);
+  fetch(`${wangzhi}/chat-glm3/chat?uuid=${uuid.msg}`, {
+    method: "get",
     headers: {
       "Content-Type": "application/json",
       Authorization: "Bearer " + getToken(),