diff --git a/api.py b/api.py
index af20303..7308311 100644
--- a/api.py
+++ b/api.py
@@ -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}] {doc.metadata["source"]} \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"])
]
diff --git a/views/src/api/chat.ts b/views/src/api/chat.ts
index 5adbb3b..41f9f99 100644
--- a/views/src/api/chat.ts
+++ b/views/src/api/chat.ts
@@ -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),
})
}
diff --git a/views/src/views/chat/index.vue b/views/src/views/chat/index.vue
index 2087357..c1418df 100644
--- a/views/src/views/chat/index.vue
+++ b/views/src/views/chat/index.vue
@@ -40,7 +40,7 @@ const conversationList = computed(() => dataSources.value.filter(item => (!item.
const prompt = ref('')
const loading = ref(false)
const inputRef = ref[(null)
-const search = ref('对话')
+const search = ref('对话')
// 添加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
diff --git a/views/vite.config.ts b/views/vite.config.ts
index 796872f..af9e990 100644
--- a/views/vite.config.ts
+++ b/views/vite.config.ts
@@ -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/', ''),
},
]