|
|
@@ -13,8 +13,8 @@ import { useUsingContext } from './hooks/useUsingContext'
|
|
|
import HeaderComponent from './components/Header/index.vue'
|
|
|
import { HoverButton, SvgIcon, MinePannel, VipPannel, MaskPannel, Share } from '@/components/common'
|
|
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
|
|
-import { useChatStore, useAppStore, usePromptStore, useAuthStore, useUserMemberStore } from '@/store'
|
|
|
-import { fetchChatAPIProcess } from '@/api'
|
|
|
+import { useChatStore, useAppStore, usePromptStore, useAuthStore, useUserMemberStore, useCompanyStore } from '@/store'
|
|
|
+import { fetchChatAPIProcess, fetchChatPDF } from '@/api'
|
|
|
import { t } from '@/locales'
|
|
|
import { useTheme } from '@/hooks/useTheme'
|
|
|
import { emitter } from '@/plugins'
|
|
|
@@ -75,12 +75,14 @@ if (histroyData.value?.maskId) {
|
|
|
|
|
|
const userMemberStore = useUserMemberStore()
|
|
|
function handleSubmit() {
|
|
|
- if (!userMemberStore.isVip()) {
|
|
|
- const inversions = dataSources.value.filter(item => {
|
|
|
- return item.inversion
|
|
|
- })
|
|
|
- if (inversions.length > 0 && inversions.length % 3 === 0) {
|
|
|
- showVipTips.value = true
|
|
|
+ if (company.value.id === 1) {
|
|
|
+ if (!userMemberStore.isVip()) {
|
|
|
+ const inversions = dataSources.value.filter(item => {
|
|
|
+ return item.inversion
|
|
|
+ })
|
|
|
+ if (inversions.length > 0 && inversions.length % 3 === 0) {
|
|
|
+ showVipTips.value = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -128,42 +130,82 @@ async function onConversation() {
|
|
|
try {
|
|
|
let lastText = ''
|
|
|
const fetchChatAPIOnce = async () => {
|
|
|
- await fetchChatAPIProcess<Chat.ConversationResponse>({
|
|
|
- prompt: message,
|
|
|
- options,
|
|
|
- signal: controller.signal,
|
|
|
- onDownloadProgress: ({ event }) => {
|
|
|
- const xhr = event.target
|
|
|
- const { responseText } = xhr
|
|
|
- // Always process the final line
|
|
|
- const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
|
|
- let chunk = responseText
|
|
|
- if (lastIndex !== -1) chunk = responseText.substring(lastIndex)
|
|
|
- try {
|
|
|
- const data = JSON.parse(chunk)
|
|
|
- updateChat(+uuid, dataSources.value.length - 1, {
|
|
|
- dateTime: new Date().toLocaleString(),
|
|
|
- text: lastText + (data.text ?? ''),
|
|
|
- inversion: false,
|
|
|
- error: false,
|
|
|
- loading: true,
|
|
|
- conversationOptions: { conversationId: data.conversationId, parentMessageId: data.id },
|
|
|
- requestOptions: { prompt: message, options: { ...options } }
|
|
|
- })
|
|
|
-
|
|
|
- if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
|
|
|
- options.parentMessageId = data.id
|
|
|
- lastText = data.text
|
|
|
- message = ''
|
|
|
- return fetchChatAPIOnce()
|
|
|
+ if (company.value.id === 0) {
|
|
|
+ await fetchChatAPIProcess<Chat.ConversationResponse>({
|
|
|
+ prompt: message,
|
|
|
+ options,
|
|
|
+ signal: controller.signal,
|
|
|
+ onDownloadProgress: ({ event }) => {
|
|
|
+ const xhr = event.target
|
|
|
+ const { responseText } = xhr
|
|
|
+ // Always process the final line
|
|
|
+ const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
|
|
+ let chunk = responseText
|
|
|
+ if (lastIndex !== -1) chunk = responseText.substring(lastIndex)
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(chunk)
|
|
|
+ updateChat(+uuid, dataSources.value.length - 1, {
|
|
|
+ dateTime: new Date().toLocaleString(),
|
|
|
+ text: lastText + (data.text ?? ''),
|
|
|
+ inversion: false,
|
|
|
+ error: false,
|
|
|
+ loading: true,
|
|
|
+ conversationOptions: { conversationId: data.conversationId, parentMessageId: data.id },
|
|
|
+ requestOptions: { prompt: message, options: { ...options } }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
|
|
|
+ options.parentMessageId = data.id
|
|
|
+ lastText = data.text
|
|
|
+ message = ''
|
|
|
+ return fetchChatAPIOnce()
|
|
|
+ }
|
|
|
+
|
|
|
+ scrollToBottomIfAtBottom()
|
|
|
+ } catch (error) {
|
|
|
+ //
|
|
|
}
|
|
|
-
|
|
|
- scrollToBottomIfAtBottom()
|
|
|
- } catch (error) {
|
|
|
- //
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ await fetchChatPDF<Chat.ConversationResponse>({
|
|
|
+ prompt: message,
|
|
|
+ options,
|
|
|
+ signal: controller.signal,
|
|
|
+ name: company.value.code,
|
|
|
+ onDownloadProgress: ({ event }) => {
|
|
|
+ const xhr = event.target
|
|
|
+ const { responseText } = xhr
|
|
|
+ // Always process the final line
|
|
|
+ const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
|
|
+ let chunk = responseText
|
|
|
+ if (lastIndex !== -1) chunk = responseText.substring(lastIndex)
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(chunk)
|
|
|
+ updateChat(+uuid, dataSources.value.length - 1, {
|
|
|
+ dateTime: new Date().toLocaleString(),
|
|
|
+ text: lastText + (data.answer ?? ''),
|
|
|
+ inversion: false,
|
|
|
+ error: false,
|
|
|
+ loading: true,
|
|
|
+ conversationOptions: { conversationId: data.conversationId, parentMessageId: data.id },
|
|
|
+ requestOptions: { prompt: message, options: { ...options } }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
|
|
|
+ options.parentMessageId = data.id
|
|
|
+ lastText = data.answer
|
|
|
+ message = ''
|
|
|
+ return fetchChatAPIOnce()
|
|
|
+ }
|
|
|
+
|
|
|
+ scrollToBottomIfAtBottom()
|
|
|
+ } catch (error) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
updateChatSome(+uuid, dataSources.value.length - 1, { loading: false })
|
|
|
}
|
|
|
|
|
|
@@ -233,40 +275,78 @@ async function onRegenerate(index: number) {
|
|
|
try {
|
|
|
let lastText = ''
|
|
|
const fetchChatAPIOnce = async () => {
|
|
|
- await fetchChatAPIProcess<Chat.ConversationResponse>({
|
|
|
- prompt: message,
|
|
|
- options,
|
|
|
- signal: controller.signal,
|
|
|
- onDownloadProgress: ({ event }) => {
|
|
|
- const xhr = event.target
|
|
|
- const { responseText } = xhr
|
|
|
- // Always process the final line
|
|
|
- const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
|
|
- let chunk = responseText
|
|
|
- if (lastIndex !== -1) chunk = responseText.substring(lastIndex)
|
|
|
- try {
|
|
|
- const data = JSON.parse(chunk)
|
|
|
- updateChat(+uuid, index, {
|
|
|
- dateTime: new Date().toLocaleString(),
|
|
|
- text: lastText + (data.text ?? ''),
|
|
|
- inversion: false,
|
|
|
- error: false,
|
|
|
- loading: true,
|
|
|
- conversationOptions: { conversationId: data.conversationId, parentMessageId: data.id },
|
|
|
- requestOptions: { prompt: message, options: { ...options } }
|
|
|
- })
|
|
|
-
|
|
|
- if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
|
|
|
- options.parentMessageId = data.id
|
|
|
- lastText = data.text
|
|
|
- message = ''
|
|
|
- return fetchChatAPIOnce()
|
|
|
+ if (company.value.id === 0) {
|
|
|
+ await fetchChatAPIProcess<Chat.ConversationResponse>({
|
|
|
+ prompt: message,
|
|
|
+ options,
|
|
|
+ signal: controller.signal,
|
|
|
+ onDownloadProgress: ({ event }) => {
|
|
|
+ const xhr = event.target
|
|
|
+ const { responseText } = xhr
|
|
|
+ // Always process the final line
|
|
|
+ const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
|
|
+ let chunk = responseText
|
|
|
+ if (lastIndex !== -1) chunk = responseText.substring(lastIndex)
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(chunk)
|
|
|
+ updateChat(+uuid, index, {
|
|
|
+ dateTime: new Date().toLocaleString(),
|
|
|
+ text: lastText + (data.text ?? ''),
|
|
|
+ inversion: false,
|
|
|
+ error: false,
|
|
|
+ loading: true,
|
|
|
+ conversationOptions: { conversationId: data.conversationId, parentMessageId: data.id },
|
|
|
+ requestOptions: { prompt: message, options: { ...options } }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
|
|
|
+ options.parentMessageId = data.id
|
|
|
+ lastText = data.text
|
|
|
+ message = ''
|
|
|
+ return fetchChatAPIOnce()
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ //
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- //
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ await fetchChatPDF<Chat.ConversationResponse>({
|
|
|
+ prompt: message,
|
|
|
+ options,
|
|
|
+ signal: controller.signal,
|
|
|
+ name: company.value.code,
|
|
|
+ onDownloadProgress: ({ event }) => {
|
|
|
+ const xhr = event.target
|
|
|
+ const { responseText } = xhr
|
|
|
+ // Always process the final line
|
|
|
+ const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
|
|
+ let chunk = responseText
|
|
|
+ if (lastIndex !== -1) chunk = responseText.substring(lastIndex)
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(chunk)
|
|
|
+ updateChat(+uuid, index, {
|
|
|
+ dateTime: new Date().toLocaleString(),
|
|
|
+ text: lastText + (data.answer ?? ''),
|
|
|
+ inversion: false,
|
|
|
+ error: false,
|
|
|
+ loading: true,
|
|
|
+ conversationOptions: { conversationId: data.conversationId, parentMessageId: data.id },
|
|
|
+ requestOptions: { prompt: message, options: { ...options } }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
|
|
|
+ options.parentMessageId = data.id
|
|
|
+ lastText = data.answer
|
|
|
+ message = ''
|
|
|
+ return fetchChatAPIOnce()
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
updateChatSome(+uuid, index, { loading: false })
|
|
|
}
|
|
|
await fetchChatAPIOnce()
|
|
|
@@ -384,7 +464,7 @@ function handleFocus() {
|
|
|
positiveText: t('common.yes'),
|
|
|
negativeText: t('common.no'),
|
|
|
onPositiveClick: () => {
|
|
|
- router.push('/login')
|
|
|
+ router.push({ name: 'login' })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -479,7 +559,9 @@ onMounted(() => {
|
|
|
})
|
|
|
emitter.on('changeMask', res => {
|
|
|
if (isMobile.value) {
|
|
|
- router.push('/mask')
|
|
|
+ router.push({
|
|
|
+ name: 'mask'
|
|
|
+ })
|
|
|
} else {
|
|
|
showMask.value = true
|
|
|
}
|
|
|
@@ -498,13 +580,20 @@ function goVip() {
|
|
|
|
|
|
function handleAdd() {
|
|
|
if (isMobile.value) {
|
|
|
- router.push('/mask')
|
|
|
+ router.push({
|
|
|
+ name: 'mask'
|
|
|
+ })
|
|
|
} else {
|
|
|
showMask.value = true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const showShareModal = ref(false)
|
|
|
+
|
|
|
+const companyStore = useCompanyStore()
|
|
|
+const company = computed(() => {
|
|
|
+ return companyStore.company
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -560,7 +649,7 @@ const showShareModal = ref(false)
|
|
|
<footer :class="footerClass">
|
|
|
<div class="w-full max-w-screen-xl m-auto">
|
|
|
<div class="flex items-center justify-between space-x-2">
|
|
|
- <HoverButton v-if="!isMobile" @click="handleAdd">
|
|
|
+ <HoverButton v-if="!isMobile && company.id === 0" @click="handleAdd">
|
|
|
<img class="w-[24px] h-[24px]" :src="isDark ? maskDarkIcon : maskIcon" alt="" />
|
|
|
</HoverButton>
|
|
|
<HoverButton @click="handleClear">
|