Skip to content

Commit 28da026

Browse files
author
AceDataCloud
committed
Migrate new service (#1)
1 parent f13ca37 commit 28da026

File tree

109 files changed

+1158
-1051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1158
-1051
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "migrate to new architecture",
4+
"packageName": "@acedatacloud/hub",
5+
"email": "cqc@cuiqingcai.com",
6+
"dependentChangeType": "patch"
7+
}

src/components/application/Confirm.vue

+17-32
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
<template>
2-
<el-dialog :model-value="visible" width="500px" center @close="$emit('update:visible', false)">
2+
<el-dialog
3+
:model-value="visible"
4+
width="500px"
5+
:title="$t('application.message.confirmApplying')"
6+
center
7+
@close="$emit('update:visible', false)"
8+
>
39
<div class="content">
410
<el-descriptions :column="1">
511
<el-descriptions-item :label="$t('application.field.name')">
6-
{{ object?.title }}
12+
{{ service?.title }}
713
</el-descriptions-item>
814
<el-descriptions-item :label="$t('application.field.freeAmount')">
9-
<span v-if="type === applicationType.API">
10-
{{ object?.free_amount }}{{ $t(`api.unit.${object?.unit}`) }}
11-
</span>
15+
<span> {{ service?.free_amount }} {{ $t(`service.unit.${service?.unit}`) }} </span>
1216
</el-descriptions-item>
1317
</el-descriptions>
14-
<p class="description">
15-
{{ $t('application.message.applyDescription') }}
16-
</p>
1718
<el-divider class="my-2" />
1819
<div class="policy">
1920
<el-checkbox v-model="checked" size="large" class="policy-checkbox" />
2021
<span class="policy-title"> {{ $t('application.message.readPolicy') }} </span>
21-
<span class="policy-title highlight" @click="showPolicy = true"> {{ $t('application.message.policy') }} </span>
22+
<span class="policy-title highlight" @click="showPolicy = true">
23+
&nbsp;{{ $t('application.message.policy') }}</span
24+
>
2225
<application-policy v-model.visible="showPolicy" />
2326
</div>
24-
<el-button type="primary" class="btn btn-apply" @click="onApply">
25-
{{ $t('common.button.applyForFree') }}
26-
</el-button>
27+
<el-button type="primary" @click="onApply">{{ $t('common.button.apply') }}</el-button>
2728
</div>
2829
</el-dialog>
2930
</template>
3031

3132
<script lang="ts">
3233
import { defineComponent } from 'vue';
3334
import { ElDialog, ElDescriptions, ElDescriptionsItem, ElDivider, ElCheckbox, ElButton, ElMessage } from 'element-plus';
34-
import { IApi, IApplicationType } from '@/operators';
35+
import { IService } from '@/models';
3536
import ApplicationPolicy from './Policy.vue';
3637
3738
interface IData {
38-
applicationType: typeof IApplicationType;
3939
checked: boolean;
4040
showPolicy: boolean;
4141
}
@@ -52,12 +52,8 @@ export default defineComponent({
5252
ApplicationPolicy
5353
},
5454
props: {
55-
object: {
56-
type: Object as () => IApi | undefined,
57-
required: true
58-
},
59-
type: {
60-
type: Object as () => IApplicationType,
55+
service: {
56+
type: Object as () => IService,
6157
required: true
6258
},
6359
visible: {
@@ -69,8 +65,7 @@ export default defineComponent({
6965
emits: ['update:visible', 'apply'],
7066
data(): IData {
7167
return {
72-
applicationType: IApplicationType,
73-
checked: true,
68+
checked: false,
7469
showPolicy: false
7570
};
7671
},
@@ -90,18 +85,8 @@ export default defineComponent({
9085
<style lang="scss" scoped>
9186
.content {
9287
padding: 10px 40px;
93-
94-
.description {
95-
font-size: 12px;
96-
}
97-
98-
.btn-apply {
99-
border-radius: 20px;
100-
}
101-
10288
.policy {
10389
margin-bottom: 10px;
104-
10590
.policy-checkbox {
10691
margin-right: 10px !important;
10792
}

src/components/common/ApiStatus.vue src/components/application/Status.vue

+14-28
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,58 @@
88
</div>
99
<div v-else-if="application" class="status">
1010
<span class="info">
11-
{{ $t('common.message.usedCount') }}: {{ application?.used_amount }} {{ $t('common.message.remainingCount') }}:
12-
{{ application?.remaining_amount }}
11+
{{ $t('common.message.usedAmount') }}: {{ application?.used_amount?.toFixed(6) }}
12+
{{ $t('common.message.remainingAmount') }}:
13+
{{ application?.remaining_amount?.toFixed(6) }}
1314
</span>
1415
<span class="actions">
1516
<el-button size="small" type="primary" @click="onBuyMore(application)">{{
1617
$t('common.button.buyMore')
1718
}}</el-button>
1819
</span>
1920
</div>
20-
<div v-if="needApply && api" class="text-center info">
21+
<div v-if="needApply && service" class="text-center info">
2122
<span class="mr-2">{{ $t('chat.message.notApplied') }}</span>
2223
<span>
2324
<el-button type="primary" class="btn btn-apply" size="small" @click="confirming = true">
2425
{{ $t('common.button.apply') }}
2526
</el-button>
2627
</span>
2728
<span class="ml-1">{{ $t('chat.message.tryForFree') }}</span>
28-
<application-confirm v-model.visible="confirming" :object="api" :type="applicationType.API" @apply="onApply" />
29+
<application-confirm v-if="service" v-model.visible="confirming" :service="service" @apply="onApply" />
2930
</div>
3031
</template>
3132

3233
<script lang="ts">
3334
import { defineComponent } from 'vue';
34-
import { IApplication, IApplicationDetailResponse, applicationOperator } from '@/operators';
35+
import { applicationOperator } from '@/operators';
3536
import { ElButton, ElMessage, ElSkeleton, ElSkeletonItem } from 'element-plus';
3637
import ApplicationConfirm from '@/components/application/Confirm.vue';
37-
import { IApplicationType } from '@/operators';
38-
import { apiOperator } from '@/operators/api/operator';
39-
import { IApiDetailResponse, IApi } from '@/operators/api';
38+
import { IApplicationType, IApplication, IApplicationDetailResponse, IService } from '@/models';
4039
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
4140
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
4241
4342
export interface IData {
4443
confirming: boolean;
4544
applicationType: typeof IApplicationType;
46-
api: IApi | undefined;
4745
}
4846
4947
export default defineComponent({
50-
name: 'ApiStatus',
48+
name: 'ApplicationStatus',
5149
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem },
5250
props: {
5351
application: {
5452
type: Object as () => IApplication | undefined,
5553
required: true
5654
},
57-
apiId: {
58-
type: String,
59-
required: true
60-
},
6155
initializing: {
6256
type: Boolean,
6357
default: false
6458
},
59+
service: {
60+
type: Object as () => IService | undefined,
61+
required: true
62+
},
6563
needApply: {
6664
type: Boolean,
6765
default: false
@@ -71,8 +69,7 @@ export default defineComponent({
7169
data(): IData {
7270
return {
7371
confirming: this.needApply,
74-
applicationType: IApplicationType,
75-
api: undefined
72+
applicationType: IApplicationType
7673
};
7774
},
7875
computed: {
@@ -88,20 +85,9 @@ export default defineComponent({
8885
if (val) {
8986
this.confirming = val;
9087
}
91-
},
92-
apiId() {
93-
this.onFetchApi();
9488
}
9589
},
96-
mounted() {
97-
this.onFetchApi();
98-
},
9990
methods: {
100-
onFetchApi() {
101-
apiOperator.get(this.apiId).then(({ data: data }: { data: IApiDetailResponse }) => {
102-
this.api = data;
103-
});
104-
},
10591
onBuyMore(application: IApplication) {
10692
this.$router.push({
10793
name: ROUTE_CONSOLE_APPLICATION_BUY,
@@ -114,7 +100,7 @@ export default defineComponent({
114100
applicationOperator
115101
.create({
116102
type: IApplicationType.API,
117-
api_id: this.apiId
103+
service_id: this.service?.id
118104
})
119105
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
120106
ElMessage.success(this.$t('application.message.applySuccessfully'));

src/components/chat/InputBox.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@
5050
import { defineComponent } from 'vue';
5151
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
5252
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
53-
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
53+
import { IChatModel } from '@/models';
5454
import { getBaseUrlData } from '@/utils';
55+
import { CHAT_MODEL_GPT_4_VISION } from '@/constants';
5556
5657
export default defineComponent({
5758
name: 'InputBox',
@@ -96,7 +97,7 @@ export default defineComponent({
9697
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
9798
},
9899
canUpload() {
99-
return [CHAT_MODEL_CHATGPT4_VISION.name].includes(this.model.name);
100+
return [CHAT_MODEL_GPT_4_VISION.name].includes(this.model.name);
100101
},
101102
model(): IChatModel {
102103
return this.$store.state.chat.model;

src/components/chat/Introduction.vue

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { defineComponent } from 'vue';
7373
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
7474
import IntroductionItem from './IntroductionItem.vue';
7575
import { ElRow, ElCol } from 'element-plus';
76+
7677
export default defineComponent({
7778
name: 'ConversationIntroduction',
7879
components: {

src/components/chat/Message.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import AnsweringMark from './AnsweringMark.vue';
3333
import copy from 'copy-to-clipboard';
3434
import { ElAlert, ElButton } from 'element-plus';
3535
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
36-
import { IApplication, IChatMessage, IChatMessageState } from '@/operators';
36+
import { IApplication, IChatMessage, IChatMessageState } from '@/models';
3737
import CopyToClipboard from '../common/CopyToClipboard.vue';
3838
import {
3939
ERROR_CODE_API_ERROR,
@@ -48,6 +48,7 @@ import {
4848
} from '@/constants';
4949
import message from '@/i18n/zh/common/message';
5050
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
51+
5152
interface IData {
5253
copied: boolean;
5354
messageState: typeof IChatMessageState;

src/components/chat/ModelSelector.vue

+9-10
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,27 @@
4949
import { defineComponent } from 'vue';
5050
import { ElDropdown, ElButton, ElDropdownItem } from 'element-plus';
5151
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
52+
import { IChatModel } from '@/models';
5253
import {
53-
CHAT_MODEL_CHATGPT,
54-
CHAT_MODEL_CHATGPT4,
55-
CHAT_MODEL_CHATGPT4_BROWSING,
56-
CHAT_MODEL_CHATGPT4_VISION,
57-
CHAT_MODEL_CHATGPT_16K,
58-
CHAT_MODEL_CHATGPT_BROWSING
59-
} from '@/operators/chat/constants';
60-
import { IChatModel } from '@/operators';
54+
CHAT_MODEL_GPT_3_5,
55+
CHAT_MODEL_GPT_3_5_BROWSING,
56+
CHAT_MODEL_GPT_4,
57+
CHAT_MODEL_GPT_4_BROWSING,
58+
CHAT_MODEL_GPT_4_VISION
59+
} from '@/constants';
6160
6261
const GROUPS = [
6362
{
6463
label: '3.5',
6564
value: 'base',
6665
icon: 'fa-solid fa-bolt',
67-
options: [CHAT_MODEL_CHATGPT, CHAT_MODEL_CHATGPT_16K, CHAT_MODEL_CHATGPT_BROWSING]
66+
options: [CHAT_MODEL_GPT_3_5, CHAT_MODEL_GPT_3_5_BROWSING]
6867
},
6968
{
7069
label: '4.0',
7170
value: 'plus',
7271
icon: 'fa-solid fa-wand-magic-sparkles',
73-
options: [CHAT_MODEL_CHATGPT4, CHAT_MODEL_CHATGPT4_BROWSING, CHAT_MODEL_CHATGPT4_VISION]
72+
options: [CHAT_MODEL_GPT_4, CHAT_MODEL_GPT_4_BROWSING, CHAT_MODEL_GPT_4_VISION]
7473
}
7574
];
7675

src/components/chat/SidePanel.vue

+19-7
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ import { ElSkeleton, ElInput } from 'element-plus';
7070
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
7171
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
7272
import { chatOperator } from '@/operators';
73-
import { IChatConversation } from '@/operators/chat/models';
74-
import { Status } from '@/store/common/models';
73+
import { IChatConversation } from '@/models';
74+
import { Status } from '@/models';
7575
7676
export default defineComponent({
7777
name: 'SidePanel',
@@ -89,11 +89,14 @@ export default defineComponent({
8989
conversations() {
9090
return this.$store.state.chat.conversations;
9191
},
92-
applications() {
93-
return this.$store.state.chat.applications;
92+
application() {
93+
return this.$store.state.chat.application;
9494
},
9595
loading() {
96-
return this.$store.state.chat.getConversationsStatus === Status.Request;
96+
return this.$store.state.chat.status.getConversations === Status.Request;
97+
},
98+
token() {
99+
return this.application?.credentials?.[0].token;
97100
}
98101
},
99102
methods: {
@@ -103,11 +106,20 @@ export default defineComponent({
103106
});
104107
},
105108
async onConfirm(conversation: IChatConversation) {
109+
const token = this.token;
110+
if (!token) {
111+
console.error('Token is not found');
112+
return;
113+
}
106114
if (conversation?.deleting) {
107-
await chatOperator.deleteConversation(conversation.id);
115+
await chatOperator.deleteConversation(conversation.id, {
116+
token
117+
});
108118
await this.$store.dispatch('chat/getConversations');
109119
} else if (conversation?.editing) {
110-
await chatOperator.updateConversation(conversation);
120+
await chatOperator.updateConversation(conversation, {
121+
token
122+
});
111123
await this.$store.dispatch('chat/getConversations');
112124
} else {
113125
conversation.editing = true;

src/components/chatdoc/Conversations.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ import { defineComponent } from 'vue';
6969
import { ElSkeleton, ElInput } from 'element-plus';
7070
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
7171
import { ROUTE_CHATDOC_CONVERSATION, ROUTE_CHATDOC_CONVERSATION_NEW } from '@/router/constants';
72-
import { IChatdocRepository, chatdocOperator, IChatdocConversation } from '@/operators';
72+
import { chatdocOperator } from '@/operators';
73+
import { IChatdocRepository, IChatdocConversation } from '@/models';
7374
7475
export default defineComponent({
7576
name: 'SidePanel',
@@ -93,8 +94,8 @@ export default defineComponent({
9394
conversations() {
9495
return this.repository?.conversations;
9596
},
96-
applications() {
97-
return this.$store.state.chatdoc.applications;
97+
application() {
98+
return this.$store.state.chatdoc.application;
9899
}
99100
},
100101
methods: {

src/components/chatdoc/InputBox.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
<script lang="ts">
2828
import { defineComponent } from 'vue';
29-
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
29+
import { ElInput } from 'element-plus';
3030
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
31-
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
31+
import { IChatModel } from '@/models';
3232
3333
export default defineComponent({
3434
name: 'InputBox',

src/components/chatdoc/Message.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import AnsweringMark from './AnsweringMark.vue';
2727
import copy from 'copy-to-clipboard';
2828
import { ElAlert, ElButton } from 'element-plus';
2929
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
30-
import { IChatdocMessage, IChatdocMessageState } from '@/operators';
30+
import { IChatdocMessage, IChatdocMessageState } from '@/models';
3131
import CopyToClipboard from '../common/CopyToClipboard.vue';
3232
import {
3333
ERROR_CODE_API_ERROR,

0 commit comments

Comments
 (0)