Remove chatdoc (#227)

Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
GermeyandAceDataCloud authored and GitHub committed 2025-07-19 14:39:35 +08:00
1 parent 7c25bbd23a
commit f34a3931df
60 files changed
+42 -6340

No files matched your search

+4 -4
View File
@@ -305,10 +305,7 @@ export default defineComponent({
},
async onRestoreConversation(id: string) {
console.debug('onRestoreConversation id', id);
console.debug('onRestoreConversation route', this.$route);
const newRoute = this.$router.resolve({ path: this.$route.path, params: { id } });
console.debug('onRestoreConversation newRoute', newRoute);
this.$router.push(newRoute);
this.$router.push({ ...this.$route, params: { id } });
const conversation = this.conversations?.find((conversation: IChatConversation) => conversation.id === id);
// change the model and model group
const model = conversation?.model;
@@ -324,6 +321,9 @@ export default defineComponent({
},
async onChangeConversation(id?: string) {
console.log('onChangeConversation in conversation', id);
// stop the current request
await this.onStop();
// if id is undefined, create a new conversation
if (!id) {
this.onNewConversation();
} else {
-277
View File
@@ -1,277 +0,0 @@
<template>
<layout>
<template #chatdoc>
<div class="wrapper">
<conversations class="side" />
<div class="chat">
<div class="status">
<application-status
:show-price="false"
:initializing="initializing"
:application="application"
:need-apply="needApply"
:service="service"
@refresh="$store.dispatch('chatdoc/getApplications')"
/>
</div>
<div class="dialogue">
<div class="messages">
<message
v-for="(message, messageIndex) in messages"
:key="messageIndex"
:message="message"
class="message"
/>
</div>
</div>
<div class="bottom">
<input-box
:disabled="answering"
:question="question"
@update:question="question = $event"
@submit="onSubmit"
/>
</div>
</div>
</div>
</template>
</layout>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Layout from '@/layouts/Chatdoc.vue';
import { chatdocOperator } from '@/operators';
import Conversations from '@/components/chatdoc/Conversations.vue';
import Message from '@/components/chatdoc/Message.vue';
import InputBox from '@/components/chatdoc/InputBox.vue';
import {
ERROR_CODE_CANCELED,
ERROR_CODE_NOT_APPLIED,
ERROR_CODE_UNKNOWN,
ROLE_ASSISTANT,
ROLE_USER
} from '@/constants';
import { ROUTE_CHATDOC_CONVERSATION } from '@/router';
import axios from 'axios';
import { isJSONString } from '@/utils/is';
import { IService, Status } from '@/models';
import ApplicationStatus from '@/components/application/Status.vue';
import { IChatdocConversationResponse, IChatdocConversation, IChatdocMessageState, IChatdocRepository } from '@/models';
export default defineComponent({
name: 'ChatdocConversation',
components: {
Layout,
Conversations,
Message,
InputBox,
ApplicationStatus
},
data() {
return {
loading: false,
repositoryId: this.$route.params.repositoryId.toString(),
answering: false,
question: ''
};
},
computed: {
messages: {
get() {
return (
this.conversations?.find(
(conversation: IChatdocConversation) => conversation.id === this.$route.params.conversationId?.toString()
)?.messages || []
);
},
set(messages: any[]) {
console.debug('set messages', messages);
}
},
repository(): IChatdocRepository | undefined {
return this.$store.state?.chatdoc?.repositories?.find((repository) => repository.id === this.repositoryId);
},
conversations(): IChatdocConversation[] | undefined {
return this.repository?.conversations;
},
conversationId(): string | undefined {
return this.$route.params.conversationId?.toString();
},
application() {
return this.$store.state.chatdoc.application;
},
credential() {
return this.$store.state.chatdoc.credential;
},
needApply() {
return this.$store.state.chatdoc.status.getApplications === Status.Success && !this.application;
},
initializing() {
return this.$store.state.chatdoc.status.getApplications === Status.Request;
},
service(): IService | undefined {
return this.$store.state.chatdoc.service;
}
},
async mounted() {
console.debug('start get conversations');
this.loading = true;
this.$store.dispatch('chatdoc/getConversations', { repositoryId: this.repositoryId }).finally(() => {
this.loading = false;
});
},
methods: {
async onSubmit() {
this.messages.push({
content: this.question,
role: ROLE_USER
});
await this.onFetchAnswer();
},
async onScrollDown() {
setTimeout(() => {
const container = document.querySelector('.dialogue') as HTMLDivElement;
if (!container || !this.messages || this.messages.length === 0) {
return;
}
container.scrollTop = container?.scrollHeight;
}, 0);
},
async onFetchAnswer() {
const token = this.credential?.token;
const question = this.question;
console.debug(this.onFetchAnswer, 'validated', question);
// reset question and references
this.question = '';
if (!token || !question) {
console.error('no token or endpoint or question');
this.messages.push({
error: {
code: ERROR_CODE_NOT_APPLIED
},
role: ROLE_ASSISTANT,
state: IChatdocMessageState.FAILED
});
return;
}
let conversationId = this.conversationId;
this.messages.push({
content: '',
role: ROLE_ASSISTANT,
state: IChatdocMessageState.PENDING
});
console.debug('start to get answer', this.messages);
this.onScrollDown();
// request server to get answer
this.answering = true;
chatdocOperator
.chatConversation(
{
repositoryId: this.repositoryId,
question,
id: this.conversationId
},
{
token,
stream: (response: IChatdocConversationResponse) => {
this.messages[this.messages.length - 1] = {
role: ROLE_ASSISTANT,
content: response.answer,
state: IChatdocMessageState.ANSWERING
};
conversationId = response.id;
this.onScrollDown();
}
}
)
.then(async () => {
console.debug('finished fetch answer');
this.messages[this.messages.length - 1].state = IChatdocMessageState.FINISHED;
await this.$store.dispatch('chatdoc/setConversation', {
id: conversationId,
messages: this.messages,
repositoryId: this.repositoryId
});
this.answering = false;
if (!this.conversationId) {
console.debug('push to conversation', conversationId);
await this.$router.push({
name: ROUTE_CHATDOC_CONVERSATION,
params: {
conversationId: conversationId,
repositoryId: this.repositoryId
}
});
}
this.onScrollDown();
await this.$store.dispatch('chatdoc/getConversations', { repositoryId: this.repositoryId });
})
.catch((error) => {
if (this.messages && this.messages.length > 0) {
this.messages[this.messages.length - 1].state = IChatdocMessageState.FAILED;
}
console.error(error);
if (axios.isCancel(error)) {
this.messages[this.messages.length - 1].error = {
code: ERROR_CODE_CANCELED
};
} else if (error?.response?.data) {
let data = error?.response?.data;
if (isJSONString(data)) {
data = JSON.parse(data);
}
if (this.messages && this.messages.length > 0) {
this.messages[this.messages.length - 1].error = data.error;
}
} else {
if (this.messages && this.messages.length > 0) {
this.messages[this.messages.length - 1].error = {
code: ERROR_CODE_UNKNOWN
};
}
}
this.answering = false;
});
}
}
});
</script>
<style lang="scss" scoped>
.wrapper {
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
}
.chat {
flex: 1;
width: calc(100% - 300px);
padding: 15px;
flex-direction: column;
height: 100%;
display: flex;
.status {
margin-bottom: 10px;
}
.dialogue {
flex: 1;
overflow-y: scroll;
margin: 15px 0;
position: relative;
.messages {
.message {
margin-bottom: 15px;
}
}
}
.bottom {
width: 100%;
display: flex;
flex-direction: column;
}
}
</style>
-195
View File
@@ -1,195 +0,0 @@
<template>
<layout>
<template #chatdoc>
<div class="wrapper">
<div class="title">
{{ $t('chatdoc.title.repositories') }}
</div>
<div class="introduction">
{{ $t('chatdoc.message.introductionForRepository') }}
</div>
<div class="status">
<application-status
:show-price="false"
:initializing="initializing"
:application="application"
:need-apply="needApply"
:service="service"
@refresh="$store.dispatch('chatdoc/getApplications')"
/>
</div>
<el-row class="repositories" :gutter="15">
<el-col :xl="4" :md="6" :sm="12" :xs="24">
<el-card class="repository text-center" shadow="hover" @click="onCreate">
<create-repository />
<p class="operation">{{ $t('chatdoc.title.createRepository') }}</p>
</el-card>
</el-col>
<el-col
v-for="(repository, repositoryIndex) in repositories"
:key="repositoryIndex"
:xl="4"
:md="6"
:sm="12"
:xs="24"
>
<el-card class="repository" shadow="hover" @click="onClick(repository)">
<el-dropdown v-if="false">
<font-awesome-icon class="more" :icon="['fas', 'book']" />
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="onDelete(repository.id)">{{
$t('common.button.delete')
}}</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<h2 class="name">{{ repository.name }}</h2>
<p class="id">
<font-awesome-icon :icon="['fas', 'book']" />
ID: {{ repository.id }}
</p>
<p class="description">
{{ repository.description }}
</p>
</el-card>
</el-col>
</el-row>
</div>
</template>
</layout>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Layout from '@/layouts/Chatdoc.vue';
import { ElCard, ElRow, ElCol, ElDropdown, ElDropdownItem, ElDropdownMenu, ElMessage } from 'element-plus';
import { IChatdocRepository } from '@/models';
import { ROUTE_CHATDOC_MANAGE } from '@/router';
import CreateRepository from '@/components/chatdoc/CreateRepository.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ApplicationStatus from '@/components/application/Status.vue';
import { Status } from '@/models';
export default defineComponent({
name: 'ChatdocKnowledge',
components: {
Layout,
ElCard,
ElRow,
ElCol,
CreateRepository,
FontAwesomeIcon,
ElDropdown,
ElDropdownItem,
ElDropdownMenu,
ApplicationStatus
},
data() {
return {};
},
computed: {
repositories() {
return this.$store.state.chatdoc.repositories;
},
needApply() {
return this.$store.state.chatdoc.status.getApplications === Status.Success && !this.application;
},
application() {
return this.$store.state.chatdoc.application;
},
service() {
return this.$store.state.chatdoc.service;
},
initializing() {
return this.$store.state.chatdoc.status.getApplications === Status.Request;
}
},
async mounted() {},
methods: {
onClick(repository: IChatdocRepository) {
this.$router.push({
name: ROUTE_CHATDOC_MANAGE,
params: {
repositoryId: repository.id
}
});
},
onDelete(id: string) {
this.$store.dispatch('chatdoc/deleteRepository', { id }).then(() => {
ElMessage.success(this.$t('chatdoc.message.deleteRepositorySuccess'));
this.$store.dispatch('chatdoc/getRepositories');
});
}
}
});
</script>
<style lang="scss" scoped>
.wrapper {
width: 100%;
height: 100%;
padding: 20px;
background-color: var(--el-bg-color-page);
display: flex;
flex-direction: column;
}
.title {
font-size: 20px;
font-weight: bold;
margin-bottom: 20px;
color: var(--el-text-color-primary);
}
.introduction {
margin-bottom: 20px;
font-size: 14px;
color: var(--el-text-color-regular);
}
.status {
margin-bottom: 10px;
width: fit-content;
}
.repositories {
flex: 1;
overflow-y: scroll;
.repository {
width: 100%;
height: 150px;
margin-bottom: 20px;
cursor: pointer;
position: relative;
.el-dropdown {
position: absolute;
right: 20px;
top: 20px;
}
.operation {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.name {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.id {
font-size: 12px;
color: var(--el-text-color-regular);
}
.description {
font-size: 12px;
color: var(--el-text-color-regular);
}
}
}
</style>
-178
View File
@@ -1,178 +0,0 @@
<template>
<layout>
<template #chatdoc>
<div class="wrapper">
<div class="title">
{{ $t('chatdoc.title.manage') }}
</div>
<div class="introduction">
{{ $t('chatdoc.message.introductionForKnowledge') }}
</div>
<div class="status">
<application-status
:show-price="false"
:initializing="initializing"
:application="application"
:need-apply="needApply"
:service="service"
@refresh="$store.dispatch('chatdoc/getApplications')"
/>
</div>
<div class="operations">
<upload-document />
</div>
<div class="documents">
<el-table v-loading="loading" :data="documents" border>
<el-table-column prop="id" label="ID" />
<el-table-column prop="file_name" :label="$t('chatdoc.field.fileName')" />
<el-table-column :label="$t('chatdoc.field.fileExtension')" width="100px">
<template #default="scope">
{{ scope.row.file_name.split('.').pop() }}
</template>
</el-table-column>
<el-table-column :label="$t('chatdoc.field.createdAt')" width="200px">
<template #default="scope">
{{ scope.row.created_at ? $dayjs.format(scope.row.created_at) : '' }}
</template>
</el-table-column>
<el-table-column :label="$t('chatdoc.field.state')" width="180px">
<template #default="scope">
<el-tag v-if="scope.row.state === 'processing'" type="info">
{{ $t('chatdoc.field.stateProcessing') }}
</el-tag>
<el-tag v-if="scope.row.state === 'failed'" type="danger">
{{ $t('chatdoc.field.stateFailed') }}
</el-tag>
<el-tag v-if="scope.row.state === 'completed'" type="success">
{{ $t('chatdoc.field.stateCompleted') }}
</el-tag>
</template>
</el-table-column>
<el-table-column>
<template #default="scope">
<el-button type="primary" round size="small" @click="onPreview(scope.row.file_url)">
{{ $t('common.button.preview') }}
</el-button>
<el-button type="danger" round size="small" @click="onDelete(scope.row.id)">
{{ $t('common.button.delete') }}
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</template>
</layout>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Layout from '@/layouts/Chatdoc.vue';
import { IChatdocRepository } from '@/models';
import { ElButton, ElTag, ElTable, ElTableColumn, ElMessage } from 'element-plus';
import UploadDocument from '@/components/chatdoc/UploadDocument.vue';
import { Status } from '@/models';
import ApplicationStatus from '@/components/application/Status.vue';
export default defineComponent({
name: 'ChatdocKnowledge',
components: {
Layout,
ElButton,
ElTable,
ElTag,
ApplicationStatus,
ElTableColumn,
UploadDocument
},
data() {
return {
loading: false,
repositoryId: this.$route.params.repositoryId.toString()
};
},
computed: {
repository(): IChatdocRepository | undefined {
return this.$store.state?.chatdoc?.repositories?.find((repository) => repository.id === this.repositoryId);
},
documents() {
return this.repository?.documents;
},
needApply() {
return this.$store.state.chatdoc.status.getApplications === Status.Success && !this.application;
},
service() {
return this.$store.state.chatdoc.service;
},
application() {
return this.$store.state.chatdoc.application;
},
initializing() {
return this.$store.state.chatdoc.status.getApplications === Status.Request;
}
},
async mounted() {
console.log('start get documents');
this.loading = true;
this.$store
.dispatch('chatdoc/getDocuments', { repositoryId: this.repositoryId })
.then(() => {
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
methods: {
onDelete(id: string) {
this.$store.dispatch('chatdoc/deleteDocument', { id }).then(() => {
ElMessage.success(this.$t('chatdoc.message.deleteDocumentSuccess'));
this.$store.dispatch('chatdoc/getDocuments', {
repositoryId: this.repositoryId
});
});
},
onPreview(url: string) {
window.open(url, '_blank');
}
}
});
</script>
<style lang="scss" scoped>
.wrapper {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
padding: 30px;
}
.el-button {
border-radius: 20px;
}
.title {
font-size: 20px;
font-weight: bold;
margin-bottom: 20px;
}
.introduction {
margin-bottom: 20px;
font-size: 14px;
color: var(--el-text-color-regular);
}
.operations {
margin-bottom: 20px;
}
.documents {
width: 100%;
}
.status {
margin-bottom: 10px;
width: fit-content;
}
</style>
-22
View File
@@ -1,22 +0,0 @@
<template>
<layout>
<template #chatdoc> Setting </template>
</layout>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Layout from '@/layouts/Chatdoc.vue';
export default defineComponent({
name: 'ChatdocSetting',
components: {
Layout
},
data() {
return {};
},
async mounted() {},
methods: {}
});
</script>
+1 -1
View File
@@ -10,7 +10,7 @@
<el-col :span="24">
<el-card shadow="hover" class="card">
<el-row>
<el-col :span="16" :offset="4">
<el-col class="max-w-4xl mx-auto">
<p class="introduction">
{{ $t('console.subscription.title') }}
</p>
+7 -1
View File
@@ -168,8 +168,14 @@ export default defineComponent({
await this.$store.dispatch('resetAll');
await this.$store.dispatch('chat/resetAll');
await this.$store.dispatch('midjourney/resetAll');
await this.$store.dispatch('chatdoc/resetAll');
await this.$store.dispatch('qrart/resetAll');
await this.$store.dispatch('flux/resetAll');
await this.$store.dispatch('hailuo/resetAll');
await this.$store.dispatch('headshots/resetAll');
await this.$store.dispatch('kling/resetAll');
await this.$store.dispatch('luma/resetAll');
await this.$store.dispatch('pika/resetAll');
await this.$store.dispatch('suno/resetAll');
await this.$store.dispatch('login');
}
}