提交 919a400c 作者: fxjhello

bingsearch前后端修改,history完善

上级 b8272bfe
......@@ -249,7 +249,7 @@ async def local_doc_chat(
async def bing_search_chat(
question: str = Body(..., description="Question", example="工伤保险是什么?"),
history: List[List[str]] = Body(
history: Optional[List[List[str]]] = Body(
[],
description="History of previous questions and answers",
example=[
......@@ -265,7 +265,7 @@ async def bing_search_chat(
):
pass
source_documents = [
f"""出处 [{inum + 1}] <a href="{doc.metadata["source"]}" target="_blank">{doc.metadata["source"]}</a> \n\n{doc.page_content}\n\n"""
f"""出处 [{inum + 1}]({doc.metadata["source"]}) \n\n{doc.page_content}\n\n"""
for inum, doc in enumerate(resp["source_documents"])
]
......
......@@ -24,11 +24,11 @@ export const getfilelist = (knowledge_base_id: any) => {
})
}
export const bing_search = (search_text: any) => {
export const bing_search = (params: any) => {
return api({
url: '/bing_search',
method: 'get',
params: { search_text },
url: '/local_doc_qa/bing_search_chat',
method: 'post',
data: JSON.stringify(params),
})
}
......
......@@ -40,7 +40,7 @@ const conversationList = computed(() => dataSources.value.filter(item => (!item.
const prompt = ref<string>('')
const loading = ref<boolean>(false)
const inputRef = ref<Ref | null>(null)
const search = ref<boolean>('对话')
const search = ref<string>('对话')
// 添加PromptStore
const promptStore = usePromptStore()
......@@ -58,7 +58,7 @@ dataSources.value.forEach((item, index) => {
})
async function handleSubmit() {
if (search.value == 'Bing搜索') {
if (search.value === 'Bing搜索') {
loading.value = true
const options: Chat.ConversationRequest = {}
const lastText = ''
......@@ -76,9 +76,9 @@ async function handleSubmit() {
},
)
scrollToBottom()
const res = await bing_search(prompt.value)
const res = await bing_search({ question: prompt.value })
const result = active.value ? `${res.data.response}\n\n数据来源:\n\n>${res.data.source_documents.join('>')}` : res.data.response
const result = `${res.data.response}\n\n数据来源:\n\n${res.data.source_documents}`
addChat(
+uuid,
{
......@@ -116,12 +116,10 @@ async function handleSubmit() {
async function onConversation() {
const message = prompt.value
history.value = []
history.value = []
if (usingContext.value) {
for (let i = 0; i < dataSources.value.length; i = i + 2) {
if (!i)
history.value.push([dataSources.value[i].text, dataSources.value[i + 1].text.split('\n\n数据来源:\n\n>')[0]])
}
for (let i = 0; i < dataSources.value.length; i = i + 2)
history.value.push([dataSources.value[i].text, dataSources.value[i + 1].text.split('\n\n数据来源:\n\n>')[0]])
}
else { history.value.length = 0 }
......@@ -589,7 +587,7 @@ onUnmounted(() => {
controller.abort()
})
function searchfun() {
if (search.value == '知识库')
if (search.value === '知识库')
active.value = true
else
......
......@@ -37,7 +37,7 @@ export default defineConfig((env) => {
open: false,
proxy: {
'/api': {
target: 'http://127.0.0.1:7861',
target: 'http://146.56.190.29:7861',
changeOrigin: true, // 允许跨域
rewrite: path => path.replace('/api/', ''),
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论