可信代码库-AI大模型批量对话接口对话及对话功能开发

This commit is contained in:
付民康
2025-05-13 17:59:24 +08:00
parent 4b7583b049
commit a08cb3f613
9 changed files with 533 additions and 47 deletions

View File

@@ -22,27 +22,10 @@
<WarningList v-else-if="msg.type===2"/>
<!--软件详情-->
<OssDetail v-else-if="msg.type===3"/>
<McMarkdownCard v-else :content="msg.content"></McMarkdownCard>
<div class="conversation-cnxw">
<a class="flex conversation-cnxw-item">
<span class="span2">猜你想问</span>
<img style="height: 15px;margin-right: 8px" width="16" src="@/assets/imgs/jyh/ai/icon_generate.png" />
</a>
<div class="flex conversation-cnxw-item">
<a class="g-header-copilot" @click="onSubmit('我想看Redis的详情')">
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
<span class="ml-xs">我想看Redis的详情</span>
</a>
</div>
<div class="flex conversation-cnxw-item">
<a class="g-header-copilot" @click="onSubmit('Redis的可信评分是多少')">
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
<span class="ml-xs">Redis的可信评分是多少</span>
</a>
</div>
</div>
<!--软件详情-->
<AIList v-else-if="msg.type==='df'" :content="msg.content"/>
<!--text或者富文本展示-->
<Other v-else :content="msg.content"></Other>
</McBubble>
<!-- <McBubble v-else :loading="msg.loading ?? false" :avatarConfig="msg.avatarConfig">-->
@@ -56,6 +39,24 @@
<!-- </template>-->
<!-- </McBubble>-->
</template>
<div class="conversation-cnxw">
<a class="flex conversation-cnxw-item">
<span class="span2">猜你想问</span>
<img style="height: 15px;margin-right: 8px" width="16" src="@/assets/imgs/jyh/ai/icon_generate.png" />
</a>
<div class="flex conversation-cnxw-item">
<a class="g-header-copilot" @click="onSubmit('我想看Redis的详情')">
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
<span class="ml-xs">我想看Redis的详情</span>
</a>
</div>
<div class="flex conversation-cnxw-item">
<a class="g-header-copilot" @click="onSubmit('Redis的可信评分是多少')">
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
<span class="ml-xs">Redis的可信评分是多少</span>
</a>
</div>
</div>
</div>
<div v-else class="welcome-page">
<div class="home-title">
@@ -142,6 +143,15 @@ import GuessYouWantToAsk from './GuessYouWantToAsk.vue';
import OssList from './components/OssList.vue';
import WarningList from './components/WarningList.vue';
import OssDetail from './components/OssDetail.vue';
import Other from './components/Other.vue';
import AIList from './components/AIList.vue';
import { getChat } from '@/api/jyh';
import axios from 'axios';
import { useDiscussGetUserInfo } from '@/api/discussion/hook';
// 获取当前用户信息 & 是否登录
const { isLogin = false, userInfo = {}} = useDiscussGetUserInfo();
debugger
const inputValue = ref('');
const startChat = ref(false);
@@ -201,20 +211,32 @@ const onSubmit = (e, answer = undefined) => {
});
});
// getAIAnswer(answer ?? e);
getAIAnswer(mockAnswer,1);
getAIAnswer(e,1);
};
const getAIAnswer = (content,type) => {
const getAIAnswer = async (content) => {
messages.value.push({
from: 'ai-model',
type: type || 1,
content: content,
type: '',
content: '',
avatarPosition: 'side-left',
avatarConfig: { ...aiModelAvatar },
loading: false,
loading: true,
});
const {data} = await axios.get('http://222.20.126.208:8089/api/v0/chat_use_sql?question='+content);
debugger
const {text,type} = data;
if(type==='text') {
messages.value[messages.value.length - 1].content = text;
messages.value[messages.value.length - 1].loading = false;
messages.value[messages.value.length - 1].type = 'text';
} else if(type==='df') {
messages.value[messages.value.length - 1].content = data[type];
messages.value[messages.value.length - 1].loading = false;
messages.value[messages.value.length - 1].type = 'df';
}
// messages.value.push({
// from: 'ai-model',
// content: '',