vue页面完成90%
This commit is contained in:
parent
839911a330
commit
fc9d9f3c25
|
|
@ -1,4 +1,3 @@
|
|||
import qs from 'qs'
|
||||
import { api } from './api'
|
||||
|
||||
export const chat = (params: any) => {
|
||||
|
|
@ -11,9 +10,9 @@ export const chat = (params: any) => {
|
|||
|
||||
export const chatfile = (params: any) => {
|
||||
return api({
|
||||
url: '/chatfile',
|
||||
url: '/local_doc_qa/local_doc_chat',
|
||||
method: 'post',
|
||||
data: qs.stringify(params),
|
||||
data: JSON.stringify(params),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
import { defineStore } from 'pinia'
|
||||
|
||||
export const idStore = defineStore('idStore', {
|
||||
state: () => {
|
||||
return {
|
||||
knowledgeid: 'samples',
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
})
|
||||
|
|
@ -15,6 +15,7 @@ import { useBasicLayout } from '@/hooks/useBasicLayout'
|
|||
import { useChatStore, usePromptStore } from '@/store'
|
||||
import { t } from '@/locales'
|
||||
import { chat, chatfile } from '@/api/chat'
|
||||
import { idStore } from '@/store/modules/knowledgebaseid/id'
|
||||
let controller = new AbortController()
|
||||
|
||||
// const openLongReply = import.meta.env.VITE_GLOB_OPEN_LONG_REPLY === 'true'
|
||||
|
|
@ -22,7 +23,7 @@ let controller = new AbortController()
|
|||
const route = useRoute()
|
||||
const dialog = useDialog()
|
||||
const ms = useMessage()
|
||||
|
||||
const idstore = idStore()
|
||||
const chatStore = useChatStore()
|
||||
const history = ref<any>([])
|
||||
const { isMobile } = useBasicLayout()
|
||||
|
|
@ -60,9 +61,12 @@ function handleSubmit() {
|
|||
|
||||
async function onConversation() {
|
||||
const message = prompt.value
|
||||
dataSources.value.forEach((item) => {
|
||||
console.log(item)
|
||||
})
|
||||
if (usingContext.value) {
|
||||
for (let i = 0; i < dataSources.value.length; i = i + 2)
|
||||
history.value.push([dataSources.value[i].text, dataSources.value[i + 1].text])
|
||||
}
|
||||
else { history.value.length = 0 }
|
||||
|
||||
if (loading.value)
|
||||
return
|
||||
|
||||
|
|
@ -112,6 +116,7 @@ async function onConversation() {
|
|||
const fetchChatAPIOnce = async () => {
|
||||
const res = active.value
|
||||
? await chatfile({
|
||||
knowledge_base_id: idstore.knowledgeid,
|
||||
question: message,
|
||||
history: history.value,
|
||||
})
|
||||
|
|
@ -266,7 +271,11 @@ async function onRegenerate(index: number) {
|
|||
const lastText = ''
|
||||
const fetchChatAPIOnce = async () => {
|
||||
const res = active.value
|
||||
? await chatfile({ message })
|
||||
? await chatfile({
|
||||
knowledge_base_id: idstore.knowledgeid,
|
||||
question: message,
|
||||
history: history.value,
|
||||
})
|
||||
: await chat({
|
||||
question: message,
|
||||
history: history.value,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function handleEnter({ uuid }: Chat.History, isEdit: boolean, event: KeyboardEve
|
|||
<NUpload
|
||||
multiple
|
||||
directory-dnd
|
||||
action="http://192.168.1.128:1002/api/local_doc_qa/upload_file"
|
||||
action="http://127.0.0.1:1002/api/local_doc_qa/upload_file"
|
||||
:headers="{
|
||||
'naive-info': 'hello!',
|
||||
}"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,13 @@ import { NButton, NForm, NFormItem, NInput } from 'naive-ui'
|
|||
import { onMounted, ref } from 'vue'
|
||||
import filelist from './filelist.vue'
|
||||
import { getfilelist } from '@/api/chat'
|
||||
import { idStore } from '@/store/modules/knowledgebaseid/id'
|
||||
const items = ref<any>([])
|
||||
const choice = ref('')
|
||||
const store = idStore()
|
||||
|
||||
onMounted(async () => {
|
||||
choice.value = store.knowledgeid
|
||||
const res = await getfilelist({})
|
||||
res.data.data.forEach((item: any) => {
|
||||
items.value.push({
|
||||
|
|
@ -28,6 +33,9 @@ const rules = {
|
|||
},
|
||||
}
|
||||
const handleValidateClick = (item: any) => {
|
||||
// console.log(item)
|
||||
choice.value = item
|
||||
store.knowledgeid = choice.value
|
||||
items.value.forEach((res: { value: any; show: boolean }) => {
|
||||
if (res.value === item)
|
||||
res.show = !res.show
|
||||
|
|
@ -46,6 +54,9 @@ const handleClick = () => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<NButton block size="large">
|
||||
对话知识库:{{ choice }}
|
||||
</NButton>
|
||||
<NForm
|
||||
ref="formRef"
|
||||
inline
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ export default defineConfig((env) => {
|
|||
open: false,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://146.56.190.29',
|
||||
// target: 'http://127.0.0.1:7861',
|
||||
target: 'http://127.0.0.1:7861',
|
||||
changeOrigin: true, // 允许跨域
|
||||
rewrite: path => path.replace('/api/', ''),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue