Sfoglia il codice sorgente

fix chat for client

tycoding 1 anno fa
parent
commit
73288f51e7

+ 2 - 2
langchat-ui-client/src/layout/Sider.vue

@@ -124,8 +124,8 @@
       </n-space>
 
       <template v-if="user == null">
-        <n-avatar class="cursor-pointer" round>
-          <SvgIcon class="text-lg" icon="solar:user-broken" />
+        <n-avatar class="cursor-pointer !text-black" round>
+          <SvgIcon class="text-2xl" icon="solar:user-broken" />
         </n-avatar>
         <n-button secondary size="tiny" type="success" @click="onLogin()">
           {{ t('side.login') }}

+ 14 - 26
langchat-ui-client/src/views/modules/chat/index.vue

@@ -213,13 +213,6 @@
     }
   }
 
-  const menuOptions = ref([
-    {
-      label: 'Upload File',
-      value: 'Upload File',
-    },
-  ]);
-
   const footerClass = computed(() => {
     let classes = ['p-4 pt-0'];
     if (isMobile.value) {
@@ -272,14 +265,6 @@
                   :text="item.message"
                   @delete="handleDelete(item)"
                 />
-                <div class="sticky bottom-0 left-0 flex justify-center">
-                  <NButton v-if="loading" type="warning" @click="handleStop">
-                    <template #icon>
-                      <SvgIcon icon="ri:stop-circle-line" />
-                    </template>
-                    Stop Responding
-                  </NButton>
-                </div>
               </div>
             </div>
           </main>
@@ -294,27 +279,30 @@
                   ref="inputRef"
                   v-model:value="prompt"
                   :autosize="{ minRows: 1, maxRows: isMobile ? 1 : 4 }"
-                  :placeholder="t('chat.placeholder')"
                   class="!rounded-full px-2 py-1"
+                  placeholder="今天想聊些什么~"
                   size="large"
                   type="textarea"
                   @keypress="handleEnter"
                 >
-                  <template #prefix>
-                    <n-popselect :options="menuOptions" placement="top" trigger="click">
-                      <n-button class="!mr-2" size="large" text>
-                        <template #icon>
-                          <SvgIcon icon="ion:attach" />
-                        </template>
-                      </n-button>
-                    </n-popselect>
-                  </template>
                   <template #suffix>
-                    <n-button :loading="loading" text @click="handleSubmit">
+                    <n-button
+                      v-if="!loading"
+                      class="!cursor-pointer"
+                      size="large"
+                      text
+                      @click="handleSubmit"
+                    >
                       <template #icon>
                         <SvgIcon icon="mdi:sparkles-outline" />
                       </template>
                     </n-button>
+                    <div v-if="loading" class="!cursor-pointer" @click="handleStop">
+                      <SvgIcon
+                        class="!text-3xl hover:text-gray-500 !cursor-pointer"
+                        icon="ri:stop-circle-line"
+                      />
+                    </div>
                   </template>
                 </n-input>
               </div>

+ 1 - 0
langchat-ui-client/src/views/modules/chat/sider/index.vue

@@ -107,6 +107,7 @@
               :label-field="'name'"
               :options="chatStore.apps"
               :value-field="'id'"
+              placeholder="请选择应用"
             />
           </div>
         </div>

+ 1 - 1
langchat-ui-client/src/views/modules/common/ModelProvider.vue

@@ -27,7 +27,7 @@
   onMounted(async () => {
     const providers = await getChatModels();
     const data: any = [];
-    if (chatStore.modelName === '') {
+    if (chatStore.modelId === '' || chatStore.modelId === null) {
       chatStore.modelId = providers[0].id;
       chatStore.modelName = providers[0].model;
       chatStore.modelProvider = providers[0].provider;

+ 0 - 2
langchat-ui-client/src/views/modules/doc/components/Chat.vue

@@ -35,7 +35,6 @@
   const emits = defineEmits(['focus-active']);
   const messageRef = ref();
   const message = ref('');
-  const isGoogleSearch = ref(false);
   const loading = ref(false);
   const docStore = useDocStore();
   const chatStore = useChatStore();
@@ -111,7 +110,6 @@
           modelId: chatStore.modelId,
           modelName: chatStore.modelName,
           modelProvider: chatStore.modelProvider,
-          isGoogleSearch: isGoogleSearch.value,
         },
         ({ event }) => {
           const list = event.target.responseText.split('\n\n');

+ 11 - 4
langchat-ui-client/src/views/modules/mindmap/components/Sider.vue

@@ -26,7 +26,7 @@
   const loading = computed(() => {
     return props.loading;
   });
-  const emit = defineEmits(['generate', 'case']);
+  const emit = defineEmits(['generate', 'render']);
   const text = ref('');
   const gen = ref('');
 
@@ -37,6 +37,10 @@
     }
   );
 
+  function onReRender() {
+    emit('render', gen.value);
+  }
+
   function onCase() {
     text.value = `番茄炒蛋怎么做`;
     gen.value = `
@@ -66,7 +70,7 @@
 - 注意控制火候,避免炒焦
 - 根据个人口味调整调料比例
 		`;
-    emit('case', gen.value);
+    emit('render', gen.value);
   }
 
   function onGenerate() {
@@ -94,8 +98,11 @@
 
     <div class="mt-6">
       <div class="flex flex-wrap justify-between items-center mb-2">
-        <div>{{ t('mindmap.output') }}</div>
-        <n-button text type="success" @click="onCase">{{ t('mindmap.example') }}</n-button>
+        <div class="flex items-center gap-1">
+          <span>{{ t('mindmap.output') }}</span>
+          <n-button text type="success" @click="onCase">{{ t('mindmap.example') }}</n-button>
+        </div>
+        <n-button secondary size="tiny" type="success" @click="onReRender">重新渲染</n-button>
       </div>
     </div>
     <n-input

+ 2 - 2
langchat-ui-client/src/views/modules/mindmap/index.vue

@@ -49,7 +49,7 @@
     }
   }
 
-  function onCase(text: string) {
+  function onRender(text: string) {
     genText.value = text;
   }
 </script>
@@ -69,7 +69,7 @@
 
         <ModelProvider />
       </div>
-      <Sider :genText="genText" :loading="loading" @case="onCase" @generate="onGenerate" />
+      <Sider :genText="genText" :loading="loading" @generate="onGenerate" @render="onRender" />
     </n-layout-sider>
 
     <MindMap :genText="genText" :loading="loading" />

+ 1 - 1
langchat-ui/src/views/channel/ModelSelect.vue

@@ -31,7 +31,7 @@
 
   onMounted(async () => {
     const providers = await getModels({ type: ModelTypeEnum.CHAT });
-    if (chatStore.modelId === '') {
+    if (chatStore.modelId === '' || chatStore.modelId === null) {
       if (providers != null && providers.length != 0) {
         const item = providers[0];
         chatStore.modelId = item.id;

+ 1 - 3
langchat-ui/src/views/chat/Chat.vue

@@ -24,7 +24,6 @@
   import { useDialog, useMessage } from 'naive-ui';
   import SvgIcon from '@/components/SvgIcon/index.vue';
   import { chat } from '@/api/aigc/chat';
-  import { SparklesOutline } from '@vicons/ionicons5';
 
   const dialog = useDialog();
   const ms = useMessage();
@@ -101,7 +100,6 @@
           appId: chatStore.appId,
           message,
           role: 'user',
-          isGoogleSearch: chatStore.isGoogleSearch,
           modelId: chatStore.modelId,
           modelName: chatStore.modelName,
           modelProvider: chatStore.modelProvider,
@@ -256,7 +254,7 @@
                 @click="handleSubmit"
               >
                 <template #icon>
-                  <n-icon :component="SparklesOutline" class="!cursor-pointer" />
+                  <SvgIcon icon="mdi:sparkles-outline" />
                 </template>
               </n-button>
               <div v-if="loading" class="!cursor-pointer" @click="handleStop">

+ 0 - 12
langchat-ui/src/views/chat/Header.vue

@@ -54,18 +54,6 @@
       <span>{{ title }}</span>
     </div>
     <n-space align="center">
-      <n-tag
-        v-model:checked="chatStore.isGoogleSearch"
-        :bordered="false"
-        checkable
-        class="border"
-        type="primary"
-      >
-        <div class="text-sm flex items-center gap-1">
-          <SvgIcon icon="devicon:google" />
-          <div>Google Search</div>
-        </div>
-      </n-tag>
       <ModelSelect :id="chatStore.modelId" class="w-auto" style="min-width: 140px" />
 
       <n-button secondary size="small" type="warning" @click="handleClear">

+ 0 - 1
langchat-ui/src/views/chat/store/chat.d.ts

@@ -22,5 +22,4 @@ export interface ChatState {
   conversationId: string | null;
   appId: any;
   metadata: any;
-  isGoogleSearch: boolean;
 }

+ 0 - 1
langchat-ui/src/views/chat/store/useChatStore.ts

@@ -28,7 +28,6 @@ export const useChatStore = defineStore('chat-store', {
       messages: [],
       metadata: null,
       appId: null,
-      isGoogleSearch: false,
     },
 
   getters: {},