Parcourir la source

change chat page

tycoding il y a 1 an
Parent
commit
a59c1cd08a

+ 4 - 3
langchat-core/src/main/java/cn/tycoding/langchat/core/component/WebSearchComponent.java

@@ -1,5 +1,8 @@
 package cn.tycoding.langchat.core.component;
 
+import static cn.tycoding.langchat.core.consts.PropConst.GOOGLE_CON;
+import static cn.tycoding.langchat.core.consts.PropConst.TAVILY_CON;
+
 import cn.tycoding.langchat.core.properties.search.GoogleProps;
 import cn.tycoding.langchat.core.properties.search.TavilyProps;
 import cn.tycoding.langchat.core.properties.search.WebSearchProps;
@@ -10,8 +13,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import static cn.tycoding.langchat.core.consts.PropConst.GOOGLE_CON;
-
 /**
  * @author tycoding
  * @since 2024/6/6
@@ -40,7 +41,7 @@ public class WebSearchComponent {
     }
 
     @Bean
-    @ConditionalOnProperty(GOOGLE_CON)
+    @ConditionalOnProperty(TAVILY_CON)
     public TavilyWebSearchEngine tavilyWebSearchEngine() {
         TavilyProps tavily = props.getTavily();
         return TavilyWebSearchEngine

+ 2 - 0
langchat-core/src/main/java/cn/tycoding/langchat/core/consts/PropConst.java

@@ -13,4 +13,6 @@ public interface PropConst {
     String AZUREOPENAI_CON = "langchat.azureopenai.api-key";
 
     String GOOGLE_CON = "langchat.web-search.google.api-key";
+
+    String TAVILY_CON = "langchat.web-search.tavily.api-key";
 }

+ 27 - 25
langchat-ui/src/views/aigc/chat/components/Chat.vue

@@ -8,6 +8,7 @@
   import { useDialog, useMessage } from 'naive-ui';
   import SvgIcon from '@/components/SvgIcon/index.vue';
   import { chat } from '@/api/aigc/chat';
+  import { AttachOutline, SparklesOutline } from '@vicons/ionicons5';
 
   const dialog = useDialog();
   const ms = useMessage();
@@ -20,6 +21,12 @@
   const aiChatId = ref<string>('');
   let controller = new AbortController();
 
+  const menuOptions = ref([
+    {
+      label: 'Upload File',
+      value: 'Upload File',
+    },
+  ]);
   const footerClass = computed(() => {
     let classes = ['p-4'];
     if (isMobile.value) {
@@ -27,9 +34,6 @@
     }
     return classes;
   });
-  const buttonDisabled = computed(() => {
-    return loading.value;
-  });
 
   // 初始化加载数据
   const dataSources = computed(() => {
@@ -205,35 +209,33 @@
     <footer :class="footerClass">
       <div class="w-full max-w-screen-3xl m-auto pl-8 pr-8 pb-6 relative">
         <div class="flex items-center justify-between space-x-2">
-          <NInput
+          <n-input
             ref="inputRef"
             v-model:value="message"
             type="textarea"
-            :autosize="{ minRows: 3, maxRows: isMobile ? 4 : 8 }"
             @keypress="handleEnter"
-            class="custom-input"
+            :autosize="{ minRows: 1, maxRows: isMobile ? 1 : 4 }"
+            class="!rounded-full px-2 py-1"
+            placeholder="搜索"
+            size="large"
           >
+            <template #prefix>
+              <n-popselect placement="top" :options="menuOptions" trigger="click">
+                <n-button text class="!mr-2">
+                  <template #icon>
+                    <n-icon class="text-2xl" :component="AttachOutline" />
+                  </template>
+                </n-button>
+              </n-popselect>
+            </template>
             <template #suffix>
-              <div class="flex items-center gap-2">
-                <NButton
-                  type="default"
-                  size="small"
-                  :disabled="buttonDisabled"
-                  @click="handleSubmit"
-                >
-                  <SvgIcon icon="ph:file-plus-duotone" />
-                </NButton>
-                <NButton
-                  type="primary"
-                  size="small"
-                  :disabled="buttonDisabled"
-                  @click="handleSubmit"
-                >
-                  <SvgIcon icon="ri:send-plane-fill" />
-                </NButton>
-              </div>
+              <n-button text :loading="loading" @click="handleSubmit">
+                <template #icon>
+                  <n-icon :component="SparklesOutline" />
+                </template>
+              </n-button>
             </template>
-          </NInput>
+          </n-input>
         </div>
       </div>
     </footer>

+ 1 - 1
langchat-ui/src/views/aigc/chat/docs.vue

@@ -161,7 +161,7 @@
         </template>
 
         <template #2>
-          <div class="p-8 pt-6 w-full h-full mb-2">
+          <div class="p-7 pt-6 w-full h-full mb-2">
             <Header title="AI智能助手" />
             <div class="w-full h-full rounded-md p-2 flex items-center justify-center">
               <n-spin :show="chatLoading">