From e5c48a2529ba5441181de82cf6a1e2cd66c2080e Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期五, 05 七月 2024 11:12:41 +0800 Subject: [PATCH] fix: 修改指令模板 --- src/views/project/ch/home/component/waterRight/top.vue | 69 +++++++++++++++++++++++++++++----- 1 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/views/project/ch/home/component/waterRight/top.vue b/src/views/project/ch/home/component/waterRight/top.vue index bf73d7e..1a911ce 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,19 +27,25 @@ </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 (!inputValue.value) return; + if (!activeSectionAId.value) { + ElMessage.warning('璇烽�夋嫨搴旂敤鍦烘櫙'); + return; + } activeChatRoom.value.title = inputValue.value; router.push({ name: 'AskAnswer', - }); }; let state = reactive({ @@ -62,11 +72,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