chd 1 개월 전
부모
커밋
54b3dbeca2
4개의 변경된 파일40개의 추가작업 그리고 43개의 파일을 삭제
  1. 2 2
      .env
  2. 12 12
      src/entrypoints/sidepanel/Chat.vue
  3. 11 15
      src/entrypoints/sidepanel/component/tools.vue
  4. 15 14
      src/store/modules/msg.ts

+ 2 - 2
.env

@@ -4,6 +4,6 @@ VITE_APP_BASE_API='http://192.168.1.166:5555'
 
 
 # 接口地址 (WebSocket) 
-VITE_API_WS_URL ='ws://192.168.1.166:7777'
+VITE_API_WS_URL ='ws://192.168.1.166:5555'
 # 终端ID 
-VITE_CLIENT_ID = '42bac061f982f0733eff0fe90099d113'
+VITE_CLIENT_ID = '7a1958fafed3268a7515b083bd6f144f'

+ 12 - 12
src/entrypoints/sidepanel/Chat.vue

@@ -47,7 +47,7 @@
       <ScrollToBottom :target="scrollbar" ref="scrollToBottomRef" />
     </div>
 
-    <Tools v-if="selectModal" :disHistory="sendLoading" :upload="type === FunctionList.File_Operation || !!formInfo" @read-click="readClick" @upload-file="(file) => createFileObj(file)" @handle-capture="handleCapture" @his-records="hisRecords"
+    <Tools :disHistory="sendLoading" :upload="type === FunctionList.File_Operation || !!formInfo" @read-click="readClick" @upload-file="(file) => createFileObj(file)" @handle-capture="handleCapture" @his-records="hisRecords"
       @add-new-dialogue="addNewDialogue" @handle-current-change="handleCurrentChange"
       @handel-intelligent-filling-click="handelIntelligentFillingClick" />
 
@@ -116,6 +116,7 @@
 <script setup>
 import { ref, onMounted, nextTick, inject, useTemplateRef, reactive,onBeforeMount } from 'vue'
 import { ElScrollbar, ElAvatar, ElInput, ElButton } from 'element-plus'
+import moment from 'moment'
 import fileLogo from '@/assets/svg/file.svg'
 import {
   getFileContent,
@@ -316,11 +317,11 @@ async function handelIntelligentFillingClick() {
 
 function handleCurrentChange(e) {
   msgStore.updateAIModel(e)
-  // if (AIModel.value.file === true) {
-  //   isShowPage.value = false
-  //   taklToHtml.value = false
-  //   pageInfoList.value = []
-  // }
+  if (AIModel.value.file === true) {
+    isShowPage.value = false
+    taklToHtml.value = false
+    pageInfoList.value = []
+  }
 }
 
 async function handleCurrentData(e) {
@@ -486,14 +487,12 @@ async function createWS(msg) {
   const websocketId= uuidv4()
    const wsUrl = `${import.meta.env.VITE_API_WS_URL}/webSocket/clue/${websocketId}`;
     const socket = new WebSocket(wsUrl);
-    console.log(selectModal.value);
-    
      askQues({
        conversationId: msgUuid.value,
     websocketId,
-    modelName: selectModal.value.modelName,
+    modelName: '通义千问-Max',
     question: type.value === FunctionList.File_Operation ? msg.rawContent : buildObjPrompt(xlsxData.value,formInfo.value),
-    id: selectModal.value.id,
+    id: '699637194561691650',
     redisKey:msg.redisKey
      }).catch(res => {
        obj.rawContent = '接口出错,请重试。'
@@ -681,10 +680,11 @@ let a = null
 // 组件挂载时滚动到底部
 onBeforeMount(async () => {
   await msgStore.initMsg()
-  await msgStore.initModal()
+  // await msgStore.initModal()
 })
 onMounted(async () => {
-  // msgStore.updateAIModel(options[0].options[0])
+  msgStore.updateAIModel(options[0].options[0])
+ 
   useAutoResizeTextarea(tareRef, inputMessage)
   chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
     if (message.type === 'TO_SIDE_PANEL_PAGE_INFO') {

+ 11 - 15
src/entrypoints/sidepanel/component/tools.vue

@@ -1,34 +1,30 @@
 <script setup lang="ts">
-import { ref, watch, watchEffect ,onMounted} from 'vue'
+import { ref, watch, watchEffect } from 'vue'
 import { storeToRefs } from 'pinia'
 import { options } from '@/entrypoints/sidepanel/mock'
 import { Reading, Upload, Paperclip, Scissor, AlarmClock, CirclePlus, Edit } from '@element-plus/icons-vue'
 import { useMsgStore } from '@/store/modules/msg'
-import { ElMessage, makeList } from 'element-plus'
-
-const { modelList } = storeToRefs(useMsgStore())
-console.log(modelList,5563);
+import { ElMessage } from 'element-plus'
 
+const { AIModel } = storeToRefs(useMsgStore())
 const selectInput = ref(null)
 const emit = defineEmits(['readClick', 'uploadFile', 'handleCapture', 'addNewDialogue', 'hisRecords', 'handleCurrentChange', 'handelIntelligentFillingClick'])
 
 watchEffect(() => {
-  // selectInput.value = AIModel.value?.value
-})
-onMounted(() => {
-  selectInput.value = modelList.value[0].id
+  selectInput.value = AIModel.value?.value
 })
 const handleUpload = (e) => {
   if (!props.upload) {
    e.stopPropagation()
     ElMessage.warning('智能填表需要先发送指令,再上传文件')
   }
+  
 }
 const props = defineProps({
   upload: {
     type: Boolean,
   },
-  disHistory:Boolean
+
 })
 </script>
 
@@ -37,9 +33,9 @@ const props = defineProps({
     <div class="flex items-center">
       <el-select placement="top" v-model="selectInput" placeholder="选择"
         @change="(e: any) => emit('handleCurrentChange', e)" style="width: 120px;margin-right: 2px">
-        <!-- <el-option-group v-for="group in options" :key="group.label" :label="group.label"> -->
-          <el-option v-for="item in modelList" :key="item.id" :label="item.modelName" :value="item.id" />
-        <!-- </el-option-group> -->
+        <el-option-group v-for="group in options" :key="group.label" :label="group.label">
+          <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value" />
+        </el-option-group>
       </el-select>
       <el-tooltip effect="dark" content="阅读此页,开启后将会根据左侧网页中的内容做出回答" placement="top">
         <el-button class="tools_btn" link :icon="Reading" @click="emit('readClick')" />
@@ -60,10 +56,10 @@ const props = defineProps({
     </div>
     <div class="flex items-center">
       <el-tooltip effect="dark" content="历史记录" placement="top">
-        <el-button :disabled="disHistory" class="tools_btn1" link :icon="AlarmClock" @click="emit('hisRecords')" />
+        <el-button class="tools_btn1" link :icon="AlarmClock" @click="emit('hisRecords')" />
       </el-tooltip>
       <el-tooltip effect="dark" content="新对话" placement="top">
-        <el-button :disabled="disHistory" class="tools_btn1" link :icon="CirclePlus" @click="emit('addNewDialogue')" />
+        <el-button class="tools_btn1" link :icon="CirclePlus" @click="emit('addNewDialogue')" />
       </el-tooltip>
     </div>
   </div>

+ 15 - 14
src/store/modules/msg.ts

@@ -1,6 +1,6 @@
 import { defineStore } from 'pinia'
 import OpenAI from 'openai'
-import { getChatDetail, getModalList } from '@/api/index'
+import { getChatDetail } from '@/api/index'
 import {
   formatMessage,
 } from '@/entrypoints/sidepanel/utils/ai-service.js'
@@ -9,12 +9,11 @@ export const useMsgStore = defineStore('msg', {
   state: () => ({
     msgUuid: <string>'',
     messages: <any[]>[],
-    hasNext:true,
+    hasNext: true,
     page: 1,
-    msgLoading:false,
+    msgLoading: false,
     pageInfoList: [],
-    modelList: <any>[],
-    selectModal: <any>null,
+    AIModel: <any>{},
     openai: <any>null
   }),
   actions: {
@@ -56,24 +55,26 @@ export const useMsgStore = defineStore('msg', {
           chrome.storage.local.set({ msgUuid: this.msgUuid })
         }
       } catch (error) {
-        
+
       } finally {
         this.msgLoading = false
       }
     },
-    async initModal() {
-      const res = await getModalList()
-      this.modelList = res.data.list
-      this.selectModal = this.modelList[0]
-    },
+
     async changePage() {
       if (this.hasNext) {
         await this.initMsg()
-
       }
     },
-    updateAIModel(id) {
-     this.selectModal = this.modelList.find(_ => _.id === id)
+    updateAIModel(model: any) {
+      this.AIModel = model
+      this.openai = new OpenAI({
+        // apiKey: import.meta.env.VITE_OPENAI_API_KEY_TONG,
+        apiKey: import.meta.env.VITE_OPENAI_API_KEY_TONG,
+        baseURL: this.AIModel.url,
+        // timeout: 5000,
+        dangerouslyAllowBrowser: true
+      })
     }
   }
 })