| | |
| | | > |
| | | </a-textarea> |
| | | </template> |
| | | <template #actions> |
| | | <div class="action" |
| | | @click="stopChat" |
| | | style="background: var(--color-bg-2);color: var(--color-primary-light-4);" v-if="displayedText != ''"> |
| | | <icon-record-stop /> |
| | | 停止生成 |
| | | </div> |
| | | </template> |
| | | <!-- <template #actions>--> |
| | | <!-- <div class="action"--> |
| | | <!-- @click="stopChat"--> |
| | | <!-- style="background: var(--color-bg-2);color: var(--color-primary-light-4);" v-if="displayedText != ''">--> |
| | | <!-- <icon-record-stop />--> |
| | | <!-- 停止生成--> |
| | | <!-- </div>--> |
| | | <!-- </template>--> |
| | | </a-comment> |
| | | </div> |
| | | <!-- <div class="chartStart" v-if="isStart" @click="startChat" |
| | |
| | | maxRows: 5, |
| | | }" |
| | | /> |
| | | <div style="height: 40px"></div> |
| | | <div class="btn-send"> |
| | | <!-- <icon-send size="32" /> --> |
| | | <a-button |
| | |
| | | <a-modal v-model:visible="visible" title="修改名称" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start"> |
| | | <a-form ref="formRef" :rules="rules" :model="agentObj" @submit="handleSubmit" > |
| | | <a-form-item field="name" label="名称"> |
| | | <a-input v-model="agentObj.name" placeholder="请输入名称"/> |
| | | <a-input v-model="agentTitle" placeholder="请输入名称"/> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <div style="width: 100%;text-align: right"> |
| | |
| | | import { agentResetApi, agentSetApi, getAgentSessionDetailsApi } from "@/api/agentSession"; |
| | | import EventBus from '@/utils/EventBus'; |
| | | import useClipboard from "vue-clipboard3"; |
| | | import { addSessionApi } from "@/api/session"; |
| | | import { addSessionApi, getSessionDetailsApi } from "@/api/session"; |
| | | const props = defineProps({ |
| | | modalObj: Object, |
| | | }); |
| | |
| | | }); |
| | | |
| | | const visible = ref(false); |
| | | let isHistory = ref(false);//是否是历史记录 |
| | | let dsl = reactive({}); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | const handleSubmit = async({values, errors}) => { |
| | | if(errors) return; |
| | | |
| | | const { code, data } = await addSessionApi(agentObj); |
| | | // agentObj.name = agentTitle.value; |
| | | // agentObj.conversation_id = agentObj.id; |
| | | console.log(agentObj, 'agentObj'); |
| | | let chatData = { |
| | | id:activeSessionId.value, |
| | | conversation_id:activeSessionId.value, |
| | | name: agentTitle.value |
| | | } |
| | | const { code, data } = await addSessionApi(chatData); |
| | | if (data) { |
| | | Message.success("修改成功"); |
| | | handleCancel() |
| | | queryAgentSessionDetail(agentObj.id); |
| | | // queryAgentSessionDetail(agentObj.id); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | const createNewAgent = async (session) => { |
| | | Object.assign(agentObj, session); |
| | | isHistory.value = false; |
| | | initPage(); |
| | | |
| | | |
| | |
| | | } |
| | | }; |
| | | |
| | | // 获取agent会话详情 |
| | | const querySessionDetail = async (session) => { |
| | | Object.assign(agentObj, session); |
| | | agentObj.id = session.dialog_id; |
| | | activeSessionId.value = session.id; |
| | | agentTitle.value = session.name; |
| | | console.log(agentTitle.value, '会话名称'); |
| | | const { code, data } = await getSessionDetailsApi(session.id); |
| | | if (code == 200) { |
| | | sessionDetailList.value = data.message.messages; |
| | | const res = await getAgentSessionDetailsApi(session.dialog_id); |
| | | if (res.code == 0) { |
| | | console.log(res.data,'会话详情'); |
| | | Object.assign(dsl, res.data.dsl); |
| | | refreshScroll(); //刷新滚动条位置 |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | const { toClipboard } = useClipboard(); |
| | | const copy = async (text) => { |
| | |
| | | |
| | | |
| | | const startChat = async(valMsg)=>{ |
| | | |
| | | sessionDetailList.value.push({ |
| | | content: valMsg, |
| | | role: 'user', |
| | | }); |
| | | sessionDetailList.value.push({ role: 'last' }); |
| | | refreshScroll(); |
| | | let chatStr = { |
| | | id: agentObj.id, |
| | | message: valMsg, |
| | | } |
| | | if(isHistory.value){ |
| | | chatStr.dsl = dsl; |
| | | } |
| | | const response = await fetch( |
| | | '/api/v1/canvas/completion', |
| | | { |
| | |
| | | 'Authorization': getAuthorization(), |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | body: JSON.stringify({ |
| | | id: agentObj.id, |
| | | message: valMsg, |
| | | }), |
| | | body: JSON.stringify(chatStr), |
| | | } |
| | | ); |
| | | |
| | |
| | | // Message.success("已停止"); |
| | | // queryNewSessionDetail(activeSessionId.value); |
| | | // } |
| | | loading.value = false; |
| | | chatDis.value = false; |
| | | isStopChat.value = true; |
| | | console.log('stopChat'); |
| | | console.log(displayedText.value, 'displayedText'); |
| | |
| | | createNewAgent(data); |
| | | }); |
| | | EventBus.on('queryAgentSessionDetail', (data) => { |
| | | Object.assign(agentObj, data); |
| | | queryAgentSessionDetail(data.id); |
| | | isHistory.value = true; |
| | | querySessionDetail(data); |
| | | }); |
| | | }); |
| | | onBeforeUnmount(() => { |
| | |
| | | |
| | | .btn-send { |
| | | position: absolute !important; |
| | | right: 10px; |
| | | right: 4px; |
| | | top: 80px; |
| | | z-index: 10; |
| | | } |