|
@@ -18,30 +18,14 @@
|
|
|
</div>
|
|
|
<div class="history_box" v-show="visibleMap['history']">
|
|
|
<ul>
|
|
|
- <li>
|
|
|
- <span class="title">今天</span>
|
|
|
- <ul>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- </ul>
|
|
|
- </li>
|
|
|
- <li>
|
|
|
- <span class="title">昨天</span>
|
|
|
- <ul>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- </ul>
|
|
|
- </li>
|
|
|
- <li>
|
|
|
- <span class="title">30天内</span>
|
|
|
- <ul>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- <li>什么是闲置土地</li>
|
|
|
- </ul>
|
|
|
- </li>
|
|
|
+ <template v-for="(session, index) in sessionLists">
|
|
|
+ <li :key="index" v-if="session['datas'].length > 0">
|
|
|
+ <span class="title">{{session['title']}}</span>
|
|
|
+ <ul>
|
|
|
+ <li v-for="(item, cindex) in session['datas']" :key="cindex" @click="switchSession(item)">{{item['tittle']}}</li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ </template>
|
|
|
</ul>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -383,6 +367,7 @@ import {
|
|
|
UpOutlined,
|
|
|
DownOutlined
|
|
|
} from "@ant-design/icons-vue";
|
|
|
+import dayjs from 'dayjs';
|
|
|
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
|
import PDFViewer from '@/components/pdf/PdfCanvas.vue';
|
|
|
import WordViewer from '@/components/pdf/WordViewer.vue';
|
|
@@ -396,7 +381,7 @@ import { useUserStore } from '@/stores';
|
|
|
import DraggableSplitter from "./components/DraggableSplitter.vue";
|
|
|
|
|
|
let ctr = null;
|
|
|
-
|
|
|
+const userStore = useUserStore();
|
|
|
const visibleMap = reactive({
|
|
|
history: true,
|
|
|
tool: true
|
|
@@ -415,10 +400,12 @@ const historys = ref([])
|
|
|
let historyIndex = -1;
|
|
|
const cQuestion = ref('')
|
|
|
|
|
|
+const isSessionNew = ref(true)
|
|
|
const startNewSessionHandle = () => {
|
|
|
cQuestion.value = ''
|
|
|
historys.value = []
|
|
|
historyIndex = -1
|
|
|
+ isSessionNew.value = true
|
|
|
}
|
|
|
|
|
|
const onKeydownHandle = (e) => {
|
|
@@ -657,6 +644,7 @@ const quest = async (isFllow) => {
|
|
|
const id = questHistories.value.length;
|
|
|
historys.value[historyIndex].currentResponse = {
|
|
|
loading: true,
|
|
|
+ time: 0,
|
|
|
hintTxt: '',
|
|
|
question: question.value,
|
|
|
id,
|
|
@@ -667,6 +655,10 @@ const quest = async (isFllow) => {
|
|
|
docs: []
|
|
|
};
|
|
|
activeIndex.value = 0;
|
|
|
+ if (isSessionNew.value) {
|
|
|
+ sessionCreate();
|
|
|
+ isSessionNew.value = false
|
|
|
+ }
|
|
|
getQuestionKeyWords();
|
|
|
if (activeTab.value === 'net') {
|
|
|
questionUrl = '/chat/bing_chat';
|
|
@@ -786,6 +778,7 @@ const handleKnowledgeResponse = (msg, id) => {
|
|
|
endTime.value = Date.now();
|
|
|
var time = ((endTime.value - startTime.value) / 1000).toFixed(0);
|
|
|
historys.value[historyIndex].currentResponse.hintTxt = `已深度思考(用时 ${time} 秒)`;
|
|
|
+ historys.value[historyIndex].currentResponse.time = time;
|
|
|
historys.value[historyIndex].currentResponse.loading = false;
|
|
|
aiLoading.value=true;
|
|
|
historys.value[historyIndex].currentResponse.originAnswer = rData.choices[0]?.delta?.content.replaceAll(
|
|
@@ -1041,17 +1034,87 @@ const getNum = (str) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const sessionId = ref('');
|
|
|
+const sessionCreate = () => {
|
|
|
+ const sendData = {
|
|
|
+ tittle: historys.value[historyIndex].currentResponse.question,
|
|
|
+ creator: userStore.user.syUser.Id
|
|
|
+ }
|
|
|
+ ManagerAPI.create(sendData).then((res) => {
|
|
|
+ if (res.data) {
|
|
|
+ sessionId.value = res.data
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+const sessionLists = reactive([
|
|
|
+ {
|
|
|
+ title: '今天',
|
|
|
+ times: [
|
|
|
+ dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ ],
|
|
|
+ datas: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '昨天',
|
|
|
+ times: [
|
|
|
+ dayjs().subtract(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ dayjs().subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ ],
|
|
|
+ datas: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '30天内',
|
|
|
+ times: [
|
|
|
+ dayjs().subtract(30, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ dayjs().subtract(2, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ ],
|
|
|
+ datas: []
|
|
|
+ }
|
|
|
+])
|
|
|
+const sessionList = async (times) => {
|
|
|
+ const res = await ManagerAPI.list(userStore.user.syUser.Id, times);
|
|
|
+ return res.data
|
|
|
+}
|
|
|
+sessionLists.forEach(async (session) => {
|
|
|
+ session['datas'] = await sessionList(session['times'])
|
|
|
+})
|
|
|
+const getQuestionList = async (chatId) => {
|
|
|
+ const res = await ManagerAPI.getQuestionList({
|
|
|
+ chatId
|
|
|
+ });
|
|
|
+ return res.data
|
|
|
+}
|
|
|
+const switchSession = async (item) => {
|
|
|
+ const results = await getQuestionList(item['id'])
|
|
|
+ historys.value = []
|
|
|
+ results.forEach((item) => {
|
|
|
+ historys.value.push({
|
|
|
+ question: item['question'],
|
|
|
+ dsChecked: true,
|
|
|
+ sourceVisible: false,
|
|
|
+ currentResponse: {
|
|
|
+ loading: false,
|
|
|
+ hintTxt: `已深度思考(用时 ${item['thinkTime']} 秒)`,
|
|
|
+ msg: item['answer'],
|
|
|
+ docs: item['answerSources'] || []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ historyIndex = results.length - 1;
|
|
|
+ })
|
|
|
+}
|
|
|
// 埋点采集数据
|
|
|
const collectQuestion = () => {
|
|
|
- const { question, originAnswer, keywords = [] } = historys.value[historyIndex].currentResponse;
|
|
|
- const userStore = useUserStore();
|
|
|
+ const { question, originAnswer, docs, time, keywords = [] } = historys.value[historyIndex].currentResponse;
|
|
|
const param = {
|
|
|
question,
|
|
|
answer: originAnswer,
|
|
|
+ answerSources: docs,
|
|
|
+ thinkTime: time,
|
|
|
questionType: askType.value === 'zcfg' ? '政策法规' : '土地市场',
|
|
|
keywords: Array.isArray(keywords) ? keywords.join(',') : keywords,
|
|
|
- user: '游客',
|
|
|
- userId: '-1'
|
|
|
+ creator: userStore.user.syUser.Id,
|
|
|
+ chatId: sessionId.value
|
|
|
};
|
|
|
if (userStore.isLogin) {
|
|
|
const { id = '-1', displayName = '游客' } = userStore?.user?.user || {};
|
|
@@ -1133,20 +1196,12 @@ const splitWords = (word) => {
|
|
|
return [];
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-const changeActiveTab = (tab) => {
|
|
|
- activeTab.value = tab;
|
|
|
-};
|
|
|
-
|
|
|
const stopAI = () => {
|
|
|
if (ctr) {
|
|
|
ctr.abort();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-defineExpose({ changeActiveTab, stopAI });
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|