From 74cdd0f00c6e6640871f35d8dd951a858ddcefa2 Mon Sep 17 00:00:00 2001 From: yangyin <18723093654@163.com> Date: 星期日, 07 七月 2024 11:44:41 +0800 Subject: [PATCH] fix:提交代码 --- src/views/project/ch/home/component/waterRight/top.vue | 70 ++++++++++++++++++++++++++++++---- 1 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/views/project/ch/home/component/waterRight/top.vue b/src/views/project/ch/home/component/waterRight/top.vue index be9499e..b771ebd 100644 --- a/src/views/project/ch/home/component/waterRight/top.vue +++ b/src/views/project/ch/home/component/waterRight/top.vue @@ -4,13 +4,17 @@ <p class="set-waterTitle"><strong>WI 姘村姟鏅鸿兘涓撳</strong>鏅烘収姘村姟鍔╂墜</p> </div> <div class="flex items-center pc-roleList"> - <div v-for="(item, index) in state.roleList" :key="index" class="flex items-center pl-6" @click="handleClick(item)"> - <el-tooltip :content="item.Content" placement="top" effect="light" popper-class="my-pop"> - <div class="modelItem cursor-pointer flex items-center" :class="{ modelItemActive: item.ID === state.activeRole }"> + <div v-for="(item, index) in llmList" :key="item.logicId" class="flex items-center pl-6" @click="handleClick(item)"> + <div class="modelItem cursor-pointer flex items-center" :class="{ modelItemActive: item.logicId === activeLLMId }"> + <img :src="item.icon" alt="icon" class="set-icon box-border" /> + <span>{{ item.logicTitle }}</span> + </div> + <!-- <el-tooltip :content="item.Content" placement="top" effect="light" popper-class="my-pop"> + <div class="modelItem cursor-pointer flex items-center " :class="{ modelItemActive: item.ID === state.activeRole }"> <img :src="item.Icon" alt="icon" class="set-icon box-border" /> <span>{{ item.Title }}</span> </div> - </el-tooltip> + </el-tooltip> --> </div> <div class="flex items-center cursor-pointer pl-5"> <div class="modelItem cursor-pointer flex items-center"> @@ -23,18 +27,29 @@ </template> <script setup lang="ts"> -import { reactive, ref } from 'vue'; +import { onMounted, reactive, ref } from 'vue'; +import { GetLLMList, SetLLM } from '/@/api/ai/chat'; import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; import router from '/@/router'; -import { activeChatRoom } from '/@/stores/chatRoom'; +import { activeChatRoom, activeLLMId, activeSectionAId } from '/@/stores/chatRoom'; +import emitter from '/@/utils/mitt'; +import { ElMessage } from 'element-plus'; const emits = defineEmits(['sendClick']); const inputValue = ref(''); const sendClick = () => { if (!inputValue.value) return; + if (!activeSectionAId.value) { + ElMessage.warning('璇烽�夋嫨搴旂敤鍦烘櫙'); + return; + } activeChatRoom.value.title = inputValue.value; + activeChatRoom.value.isInitial = false; router.push({ name: 'AskAnswer', + query: { + id: activeChatRoom.value.id, + }, }); }; let state = reactive({ @@ -61,11 +76,48 @@ }, ], activeRole: 0, - inputAnswer: '', }); -const handleClick = (item) => { - state.activeRole = item.id; + +const llmList = ref([]); +const iconList = ['/static/images/wave/Glm.jpg', '/static/images/wave/Glm.jpg', '/static/images/wave/Glm.jpg']; +const getLLMList = async () => { + const res = await GetLLMList(); + + const resData = (res?.llm_list || []) as any[]; + llmList.value = resData.map((item, index) => ({ + get logicId() { + return this.logicModel.id; + }, + get logicTitle() { + return this.logicModel.title; + }, + icon: iconList[index], + logicModel: { + ...item, + }, + })); + const first = llmList.value?.[0]; + first && setLLm(first.logicId); }; + +const setLLm = async (llmId: string) => { + // const res = await SetLLM({ + // llm: llmId, + // }); + activeLLMId.value = llmId; + + return true; +}; +const handleClick = (item) => { + setLLm(item.logicId); +}; + +onMounted(() => { + getLLMList(); + emitter.on('updateChatInput', (value) => { + inputValue.value = value; + }); +}); </script> <style scoped lang="scss"> .set-waterTitle { -- Gitblit v1.9.3