zhengnaiwen_citu 1 hete
szülő
commit
532ab6e391
3 módosított fájl, 25 hozzáadás és 41 törlés
  1. 2 2
      src/api/dataChart.js
  2. 3 2
      src/utils/request.js
  3. 20 37
      src/views/dataChart/dataChartEditChat.vue

+ 2 - 2
src/api/dataChart.js

@@ -2,8 +2,8 @@
 import http from '@/utils/request'
 
 // vanna 问答
-export function getAsk (data) {
-  return http.post('/vanna/v0/ask_agent', data)
+export function getAsk (data, config) {
+  return http.post('/vanna/v0/ask_agent', data, config)
 }
 
 // 提交到正确训练集

+ 3 - 2
src/utils/request.js

@@ -68,14 +68,15 @@ service.interceptors.response.use(
 
 // 请求方法
 const http = {
-  post (url, params) {
+  post (url, params, config = {}) {
     return service.post(url, params, {
       transformRequest: [(params) => {
         return JSON.stringify(params)
       }],
       headers: {
         'Content-Type': 'application/json'
-      }
+      },
+      ...config
     })
   },
   get (url, params) {

+ 20 - 37
src/views/dataChart/dataChartEditChat.vue

@@ -73,9 +73,10 @@
                       max-width="300"
                       attach=".chart-content-chat-box"
                     >
-                      <template v-slot:activator>
+                      <template v-slot:activator="{ on , attrs}">
                         <v-btn
-                          @click="item.showMenu = true"
+                          v-on="on"
+                          v-bind="attrs"
                           text
                           color="primary"
                         >我要画图</v-btn>
@@ -179,6 +180,13 @@
     </div>
     <div class="pa-3 chart-content-chat-btn">
       <div class="send">
+        <div class="pa-3 text-center" v-if="conversationId">
+          <v-btn color="indigo" outlined small @click="onNew">
+            <v-icon left>
+              mdi-chat-plus-outline
+            </v-icon>新对话
+          </v-btn>
+        </div>
         <div class="send-box">
           <v-textarea
             v-model="question"
@@ -214,41 +222,6 @@
         </div>
       </div>
     </div>
-    <!-- <v-dialog
-      v-model="show"
-      persistent
-      max-width="290"
-    >
-      <v-card>
-        <v-card-title class="text-h5">
-          提示
-        </v-card-title>
-        <v-card-text>是否添加到训练集</v-card-text>
-        <v-card-actions>
-          <v-spacer></v-spacer>
-          <v-btn
-            text
-            @click="show = false"
-          >
-            取消
-          </v-btn>
-          <v-btn
-            color="error darken-1"
-            text
-            @click="onSure(false)"
-          >
-            不添加
-          </v-btn>
-          <v-btn
-            color="green darken-1"
-            text
-            @click="onSure(true)"
-          >
-            添加
-          </v-btn>
-        </v-card-actions>
-      </v-card>
-    </v-dialog> -->
   </div>
 </template>
 
@@ -283,6 +256,7 @@ export default {
           ]
         }
       ],
+      abortController: null,
       conversationId: undefined
       // trueData: false
     }
@@ -291,6 +265,12 @@ export default {
     ...mapGetters(['userInfo'])
   },
   methods: {
+    onNew () {
+      this.abortController.abort('')
+      this.abortController = null
+      this.items.splice(1, this.items.length - 1)
+      this.conversationId = undefined
+    },
     handleKeyCode (event) {
       if (event.keyCode === 13) {
         if (!event.ctrlKey) {
@@ -336,11 +316,14 @@ export default {
       this.items.push(ask)
       this.question = ''
       try {
+        this.abortController = new AbortController()
         const { data } = await getAsk({
           question,
           user_id: this.userInfo.id,
           routing_mode: this.routingMode,
           conversation_id: this.conversationId
+        }, {
+          signal: this.abortController.signal
         })
         ask.content = data
         this.conversationId = data.conversation_id