|
@@ -1,14 +1,23 @@
|
|
|
<script setup>
|
|
|
-import { onMounted, ref } from 'vue';
|
|
|
+import { onMounted, ref, unref } from 'vue';
|
|
|
import { useUserStore } from '@/stores/modules/userStore';
|
|
|
import { useRecommend } from '@/composables/useRecommend';
|
|
|
+import { chatApi } from '@/api/chat';
|
|
|
+import { streamChatRequest } from '@/utils/streamRequest';
|
|
|
+import { useChat } from '@/composables/useChat';
|
|
|
+
|
|
|
+const ANSWER_ID_KEY = '@@id@@';
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
+const { chatDataSource, addChat, updateChat, clearChat, updateById } = useChat();
|
|
|
+
|
|
|
const showRight = ref(null);
|
|
|
|
|
|
const { recommendList } = useRecommend({ type: 0 });
|
|
|
|
|
|
+const currenSessionId = ref('');
|
|
|
+
|
|
|
const inpValue = ref('');
|
|
|
|
|
|
// const jumpChatView = () => {
|
|
@@ -32,6 +41,57 @@ const closeDrawer = () => {
|
|
|
showRight.value.close();
|
|
|
}
|
|
|
|
|
|
+const onRegenerate = ({ showVal, question, realQuestion, tools, uploadFileList }) => {
|
|
|
+
|
|
|
+ // 参数相关先不组合 - 后续统一整理
|
|
|
+ // const sessionId = unref(currenSessionId);
|
|
|
+
|
|
|
+ streamChatRequest({
|
|
|
+ data: {"sessionId":"1b6d485e6aef4ec9bed46c0d37d4e303","showVal":"今天天气","question":"今天天气","module":0,"modelType":0,"isStrong":0,"tools":null,"onlineSearch":false,"prompt":null},
|
|
|
+ onProgress: (responseText) => {
|
|
|
+ const [ answer ] = responseText.split(ANSWER_ID_KEY);
|
|
|
+
|
|
|
+ updateChat({
|
|
|
+ sessionId: "1b6d485e6aef4ec9bed46c0d37d4e303",
|
|
|
+ showVal: showVal,
|
|
|
+ question,
|
|
|
+ answer,
|
|
|
+ loading: true,
|
|
|
+ delayLoading: false,
|
|
|
+ uploadFileList
|
|
|
+ })
|
|
|
+
|
|
|
+ // console.log( "chatDataSource.value", chatDataSource.value );
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 提交问答
|
|
|
+const handleSubmit = async ({ showVal, question, selectedOption, realQuestion = '', uploadFileList = [] }) => {
|
|
|
+ /**
|
|
|
+ * showVal: input输入框的内容 - 展示使用
|
|
|
+ * question: 问题 - 用于传给大模型使用
|
|
|
+ * selectedOption: 智能体-智能差数,这个需要后续完善
|
|
|
+ * **/
|
|
|
+ const { data: sessionId } = await chatApi.getChatSessionTag();
|
|
|
+ currenSessionId.value = sessionId;
|
|
|
+
|
|
|
+ addChat({
|
|
|
+ sessionId: '1b6d485e6aef4ec9bed46c0d37d4e303',
|
|
|
+ showVal,
|
|
|
+ question,
|
|
|
+ realQuestion,
|
|
|
+ answer: '',
|
|
|
+ loading: true,
|
|
|
+ delayLoading: true,
|
|
|
+ uploadFileList
|
|
|
+ })
|
|
|
+
|
|
|
+ onRegenerate({ showVal, question, realQuestion, tools: selectedOption?.tools || null, uploadFileList });
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
// setInterval(item => {
|
|
|
// num.value = num.value + 1;
|
|
@@ -58,21 +118,29 @@ onMounted(() => {
|
|
|
'期待与您一同规划和完成未来的工作',
|
|
|
'有任何重点或需讨论的事项,随时告诉我'
|
|
|
]"
|
|
|
- :card-content="recommendList">
|
|
|
+ :card-content="recommendList"
|
|
|
+ >
|
|
|
</ChatWelcome>
|
|
|
- <ChatTaskGroup></ChatTaskGroup>
|
|
|
+ <ChatTaskGroup ></ChatTaskGroup>
|
|
|
</view>
|
|
|
|
|
|
<view class="qa-container">
|
|
|
- <view clas="qa-item">
|
|
|
- <ChatAsk></ChatAsk>
|
|
|
- <ChatAnswer></ChatAnswer>
|
|
|
+ <view class="qa-item" v-for="item, index in chatDataSource" :key="item.id">
|
|
|
+ <ChatAsk :content="item.showVal" :sessionId="item.sessionId" :uploadFileList="item.uploadFileList"></ChatAsk>
|
|
|
+ <ChatAnswer
|
|
|
+ :id="item.id"
|
|
|
+ :content="item.answer"
|
|
|
+ :loading="item.loading"
|
|
|
+ :delay-loading="item.delayLoading"
|
|
|
+ :isSatisfied="item.isSatisfied"
|
|
|
+ :isVisibleResetBtn="chatDataSource.length - 1 === index"
|
|
|
+ ></ChatAnswer>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<template #footer>
|
|
|
- <ChatInput v-model="inpValue"></ChatInput>
|
|
|
+ <ChatInput v-model="inpValue" @on-submit="handleSubmit"></ChatInput>
|
|
|
</template>
|
|
|
</BasePublicLayout>
|
|
|
|
|
@@ -98,10 +166,8 @@ onMounted(() => {
|
|
|
}
|
|
|
|
|
|
.qa-container {
|
|
|
+ width: 100vw;
|
|
|
padding-top: 64rpx;
|
|
|
}
|
|
|
|
|
|
-// .qu-item {
|
|
|
-// padding: ;
|
|
|
-// }
|
|
|
</style>
|