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