Переглянути джерело

fix:修改问题框样式问题,修改智能体问答多轮对话参数问题

hanyang 1 рік тому
батько
коміт
da9fee6aca

+ 1 - 0
src/modules/conversation-chat/DialogItem.vue

@@ -4,6 +4,7 @@
       v-if="item_type === 'q'"
       :question="questionInfo"
       :agent_id="agent_id"
+      :width="width"
       @send="handleSend"
       @select="handleSelectChat"
     />

+ 19 - 2
src/modules/conversation-item/DialogQuestion.vue

@@ -12,7 +12,12 @@
               @copy="handleCopy"
               @edit="handleEdit"
             ></DialogQuestionActions>
-            <DialogContent :content="question.content" :show_think="false" class="question-content-core-text">
+            <DialogContent
+              :content="question.content"
+              :max_width="content_max_width"
+              :show_think="false"
+              class="question-content-core-text"
+            >
             </DialogContent>
             <ReEditQuestion
               v-if="show_edit_modal"
@@ -54,7 +59,11 @@ const props = defineProps({
    * 用户提问数据
    */
   question: Object,
-  agent_id: String
+  agent_id: String,
+  /**
+   * 对话区域的宽度
+   */
+  width: Number
 });
 
 const select_btn_visible = computed(() => {
@@ -68,6 +77,14 @@ const question_attached_files = computed(() => {
     return [];
   }
 });
+/**
+ * 内容区域的最大宽度
+ * 内容区域的宽度,根据父容器的宽度,减去此组件内非内容区域元素(icon等)的宽度,以及横向的的margin/padding
+ * 最终得出内容区域的最大宽度
+ */
+const content_max_width = computed(() => {
+  return props.width - 40 - 40;
+});
 
 const emit = defineEmits(['select']);
 

+ 40 - 10
src/views/conversation/ConversationChatContainer.vue

@@ -76,6 +76,7 @@
                 :user_input_form="conversation_params.user_input_form"
                 :chat_history="chat_history"
                 @initModel="initModel"
+                @toAutoSubmit="autoSubmit"
                 ref="dialog_input_top"
               />
             </template>
@@ -1094,6 +1095,15 @@ const initModel = (val) => {
 };
 
 const target_action_config = ref({});
+
+/**
+ * 智能体中心对话,如果是workflow类型,点击动态表单中的开始对话,直接继续对话,省略主动发送操作
+ * */
+const autoSubmit = () => {
+  // handleInputSubmit()
+  // console.log('自动执行');
+};
+
 /**
  * 初始化sse相关方法
  * */
@@ -1109,6 +1119,7 @@ const { startStream, stopStream } = useFetchEventSource();
  */
 
 const handleInputSubmit = async (options) => {
+  console.log(options, 1111);
   show_welcome.value = false;
   if (!chat_display_list.value.length) {
     pushInitAnswer();
@@ -1261,18 +1272,37 @@ const handleInputSubmit = async (options) => {
     const chat_id = chat_round_id.value;
     const menu_id = current_menu_id.value;
     for (const key in files_obj) {
-      const upload_files = files_obj[key].map((item) => item.file);
+      let upload_files;
+      if (Array.isArray(files_obj[key])) {
+        upload_files = files_obj[key].map((item) => item.file);
+      } else {
+        upload_files = [files_obj[key]].map((item) => item.file);
+      }
+
       const uploadResult = await uploadFileByAgentInfo(agent_id, chat_id, upload_files, menu_id);
       if (uploadResult && uploadResult.length) {
-        files_obj[key] = files_obj[key].map((file) => {
-          const uploadedFile = uploadResult.find((uploaded) => uploaded.name === file.name);
-          // 如果找到了匹配的文件,则回填 id
-          if (uploadedFile) {
-            file.upload_file_id = uploadedFile.id;
-            file.url = '';
-          }
-          return file;
-        });
+        if (Array.isArray(files_obj[key])) {
+          files_obj[key] = files_obj[key].map((file) => {
+            const uploadedFile = uploadResult.find((uploaded) => uploaded.name === file.name);
+            // 如果找到了匹配的文件,则回填 id
+            if (uploadedFile) {
+              file.upload_file_id = uploadedFile.id;
+              file.url = '';
+            }
+            return file;
+          });
+        } else {
+          files_obj[key] = [files_obj[key]].map((file) => {
+            const uploadedFile = uploadResult.find((uploaded) => uploaded.name === file.name);
+            // 如果找到了匹配的文件,则回填 id
+            if (uploadedFile) {
+              file.upload_file_id = uploadedFile.id;
+              file.url = '';
+            }
+            return file;
+          });
+        }
+
         // 判断如果对应的文件是单文件上传,则显示为对象
         if (files_obj[key].some((item) => item.limit_1)) {
           files_obj[key] = files_obj[key][0];

+ 2 - 2
vite.config.mjs

@@ -36,8 +36,8 @@ export default defineConfig(({ mode }) => {
         '/api/': {
           // target: 'http://smartai.com:8401',
 
-          target: 'http://192.168.20.119:9301',
-          // target: 'http://192.168.20.116:28004',
+          // target: 'http://192.168.20.119:9301',
+          target: 'http://192.168.20.116:28004',
           // target: 'http://smartai.com:8164',
           changeOrigin: true,
           secure: false,