Browse Source

fix:修改连续问答时,不携带session_id的问题

hanyang 1 năm trước cách đây
mục cha
commit
2a362d1bd0

+ 4 - 1
src/views/ConversationQA.vue

@@ -10,6 +10,7 @@
           :session_id="chat_session"
           :key="chat_key"
           :conversation_params="conversation_params"
+          @updateSessionId="updateSessionId"
         />
       </template>
 
@@ -191,7 +192,9 @@ function comfirmAgent(agent_id) {
   // 根据agent_id 查询到动态表单数据
   getConversationParams(chat_agent.value);
 }
-
+const updateSessionId = (session_id) => {
+  chat_session.value = session_id;
+};
 async function init() {
   const route = useRoute();
 

+ 5 - 1
src/views/conversation/ConversationChatContainer.vue

@@ -130,6 +130,7 @@ const props = defineProps({
    * */
   conversation_params: Object
 });
+const emit = defineEmits(['updateSessionId']);
 
 const i18n = useI18n();
 
@@ -741,12 +742,15 @@ const sseOnMessage = (ev) => {
   // return;
   // sse流返回的数据
   const res_data = JSON.parse(ev.data);
+  if (res_data.session_id) {
+    emit('updateSessionId', res_data.session_id);
+  }
   //sse流式结束
   if (res_data.event === 'message_end') {
     stopStream();
   }
   //sse错误,显示错误信息
-  if (res_data.event === 'error') {
+  if (res_data.event === 'error' || res_data.message === 'error') {
     handleChatRequestionException({
       message: res_data.error
     });