Migrate new service (#1)
This commit is contained in:
1 parent
f13ca37d63
commit
28da0263dc
109 files changed
+1160
-1053
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"comment": "migrate to new architecture",
|
||||
"packageName": "@acedatacloud/hub",
|
||||
"email": "cqc@cuiqingcai.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -1,29 +1,30 @@
|
||||
<template>
|
||||
<el-dialog :model-value="visible" width="500px" center @close="$emit('update:visible', false)">
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
width="500px"
|
||||
:title="$t('application.message.confirmApplying')"
|
||||
center
|
||||
@close="$emit('update:visible', false)"
|
||||
>
|
||||
<div class="content">
|
||||
<el-descriptions :column="1">
|
||||
<el-descriptions-item :label="$t('application.field.name')">
|
||||
{{ object?.title }}
|
||||
{{ service?.title }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('application.field.freeAmount')">
|
||||
<span v-if="type === applicationType.API">
|
||||
{{ object?.free_amount }}{{ $t(`api.unit.${object?.unit}`) }}
|
||||
</span>
|
||||
<span> {{ service?.free_amount }} {{ $t(`service.unit.${service?.unit}`) }} </span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<p class="description">
|
||||
{{ $t('application.message.applyDescription') }}
|
||||
</p>
|
||||
<el-divider class="my-2" />
|
||||
<div class="policy">
|
||||
<el-checkbox v-model="checked" size="large" class="policy-checkbox" />
|
||||
<span class="policy-title"> {{ $t('application.message.readPolicy') }} </span>
|
||||
<span class="policy-title highlight" @click="showPolicy = true"> {{ $t('application.message.policy') }} </span>
|
||||
<span class="policy-title highlight" @click="showPolicy = true">
|
||||
{{ $t('application.message.policy') }}</span
|
||||
>
|
||||
<application-policy v-model.visible="showPolicy" />
|
||||
</div>
|
||||
<el-button type="primary" class="btn btn-apply" @click="onApply">
|
||||
{{ $t('common.button.applyForFree') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="onApply">{{ $t('common.button.apply') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -31,11 +32,10 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElDescriptions, ElDescriptionsItem, ElDivider, ElCheckbox, ElButton, ElMessage } from 'element-plus';
|
||||
import { IApi, IApplicationType } from '@/operators';
|
||||
import { IService } from '@/models';
|
||||
import ApplicationPolicy from './Policy.vue';
|
||||
|
||||
interface IData {
|
||||
applicationType: typeof IApplicationType;
|
||||
checked: boolean;
|
||||
showPolicy: boolean;
|
||||
}
|
||||
@@ -52,12 +52,8 @@ export default defineComponent({
|
||||
ApplicationPolicy
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object as () => IApi | undefined,
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: Object as () => IApplicationType,
|
||||
service: {
|
||||
type: Object as () => IService,
|
||||
required: true
|
||||
},
|
||||
visible: {
|
||||
@@ -69,8 +65,7 @@ export default defineComponent({
|
||||
emits: ['update:visible', 'apply'],
|
||||
data(): IData {
|
||||
return {
|
||||
applicationType: IApplicationType,
|
||||
checked: true,
|
||||
checked: false,
|
||||
showPolicy: false
|
||||
};
|
||||
},
|
||||
@@ -90,18 +85,8 @@ export default defineComponent({
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
padding: 10px 40px;
|
||||
|
||||
.description {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btn-apply {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.policy {
|
||||
margin-bottom: 10px;
|
||||
|
||||
.policy-checkbox {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
</div>
|
||||
<div v-else-if="application" class="status">
|
||||
<span class="info">
|
||||
{{ $t('common.message.usedCount') }}: {{ application?.used_amount }} {{ $t('common.message.remainingCount') }}:
|
||||
{{ application?.remaining_amount }}
|
||||
{{ $t('common.message.usedAmount') }}: {{ application?.used_amount?.toFixed(6) }}
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
</span>
|
||||
<span class="actions">
|
||||
<el-button size="small" type="primary" @click="onBuyMore(application)">{{
|
||||
@@ -17,7 +18,7 @@
|
||||
}}</el-button>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="needApply && api" class="text-center info">
|
||||
<div v-if="needApply && service" class="text-center info">
|
||||
<span class="mr-2">{{ $t('chat.message.notApplied') }}</span>
|
||||
<span>
|
||||
<el-button type="primary" class="btn btn-apply" size="small" @click="confirming = true">
|
||||
@@ -25,43 +26,40 @@
|
||||
</el-button>
|
||||
</span>
|
||||
<span class="ml-1">{{ $t('chat.message.tryForFree') }}</span>
|
||||
<application-confirm v-model.visible="confirming" :object="api" :type="applicationType.API" @apply="onApply" />
|
||||
<application-confirm v-if="service" v-model.visible="confirming" :service="service" @apply="onApply" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApplication, IApplicationDetailResponse, applicationOperator } from '@/operators';
|
||||
import { applicationOperator } from '@/operators';
|
||||
import { ElButton, ElMessage, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import ApplicationConfirm from '@/components/application/Confirm.vue';
|
||||
import { IApplicationType } from '@/operators';
|
||||
import { apiOperator } from '@/operators/api/operator';
|
||||
import { IApiDetailResponse, IApi } from '@/operators/api';
|
||||
import { IApplicationType, IApplication, IApplicationDetailResponse, IService } from '@/models';
|
||||
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
|
||||
|
||||
export interface IData {
|
||||
confirming: boolean;
|
||||
applicationType: typeof IApplicationType;
|
||||
api: IApi | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiStatus',
|
||||
name: 'ApplicationStatus',
|
||||
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem },
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication | undefined,
|
||||
required: true
|
||||
},
|
||||
apiId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
initializing: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
service: {
|
||||
type: Object as () => IService | undefined,
|
||||
required: true
|
||||
},
|
||||
needApply: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -71,8 +69,7 @@ export default defineComponent({
|
||||
data(): IData {
|
||||
return {
|
||||
confirming: this.needApply,
|
||||
applicationType: IApplicationType,
|
||||
api: undefined
|
||||
applicationType: IApplicationType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -88,20 +85,9 @@ export default defineComponent({
|
||||
if (val) {
|
||||
this.confirming = val;
|
||||
}
|
||||
},
|
||||
apiId() {
|
||||
this.onFetchApi();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchApi();
|
||||
},
|
||||
methods: {
|
||||
onFetchApi() {
|
||||
apiOperator.get(this.apiId).then(({ data: data }: { data: IApiDetailResponse }) => {
|
||||
this.api = data;
|
||||
});
|
||||
},
|
||||
onBuyMore(application: IApplication) {
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
@@ -114,7 +100,7 @@ export default defineComponent({
|
||||
applicationOperator
|
||||
.create({
|
||||
type: IApplicationType.API,
|
||||
api_id: this.apiId
|
||||
service_id: this.service?.id
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
ElMessage.success(this.$t('application.message.applySuccessfully'));
|
||||
@@ -50,8 +50,9 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
|
||||
import { IChatModel } from '@/models';
|
||||
import { getBaseUrlData } from '@/utils';
|
||||
import { CHAT_MODEL_GPT_4_VISION } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InputBox',
|
||||
@@ -96,7 +97,7 @@ export default defineComponent({
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
},
|
||||
canUpload() {
|
||||
return [CHAT_MODEL_CHATGPT4_VISION.name].includes(this.model.name);
|
||||
return [CHAT_MODEL_GPT_4_VISION.name].includes(this.model.name);
|
||||
},
|
||||
model(): IChatModel {
|
||||
return this.$store.state.chat.model;
|
||||
|
||||
@@ -73,6 +73,7 @@ import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import IntroductionItem from './IntroductionItem.vue';
|
||||
import { ElRow, ElCol } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConversationIntroduction',
|
||||
components: {
|
||||
|
||||
@@ -33,7 +33,7 @@ import AnsweringMark from './AnsweringMark.vue';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { ElAlert, ElButton } from 'element-plus';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { IApplication, IChatMessage, IChatMessageState } from '@/operators';
|
||||
import { IApplication, IChatMessage, IChatMessageState } from '@/models';
|
||||
import CopyToClipboard from '../common/CopyToClipboard.vue';
|
||||
import {
|
||||
ERROR_CODE_API_ERROR,
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
} from '@/constants';
|
||||
import message from '@/i18n/zh/common/message';
|
||||
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
|
||||
|
||||
interface IData {
|
||||
copied: boolean;
|
||||
messageState: typeof IChatMessageState;
|
||||
|
||||
@@ -49,28 +49,27 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDropdown, ElButton, ElDropdownItem } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IChatModel } from '@/models';
|
||||
import {
|
||||
CHAT_MODEL_CHATGPT,
|
||||
CHAT_MODEL_CHATGPT4,
|
||||
CHAT_MODEL_CHATGPT4_BROWSING,
|
||||
CHAT_MODEL_CHATGPT4_VISION,
|
||||
CHAT_MODEL_CHATGPT_16K,
|
||||
CHAT_MODEL_CHATGPT_BROWSING
|
||||
} from '@/operators/chat/constants';
|
||||
import { IChatModel } from '@/operators';
|
||||
CHAT_MODEL_GPT_3_5,
|
||||
CHAT_MODEL_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_GPT_4,
|
||||
CHAT_MODEL_GPT_4_BROWSING,
|
||||
CHAT_MODEL_GPT_4_VISION
|
||||
} from '@/constants';
|
||||
|
||||
const GROUPS = [
|
||||
{
|
||||
label: '3.5',
|
||||
value: 'base',
|
||||
icon: 'fa-solid fa-bolt',
|
||||
options: [CHAT_MODEL_CHATGPT, CHAT_MODEL_CHATGPT_16K, CHAT_MODEL_CHATGPT_BROWSING]
|
||||
options: [CHAT_MODEL_GPT_3_5, CHAT_MODEL_GPT_3_5_BROWSING]
|
||||
},
|
||||
{
|
||||
label: '4.0',
|
||||
value: 'plus',
|
||||
icon: 'fa-solid fa-wand-magic-sparkles',
|
||||
options: [CHAT_MODEL_CHATGPT4, CHAT_MODEL_CHATGPT4_BROWSING, CHAT_MODEL_CHATGPT4_VISION]
|
||||
options: [CHAT_MODEL_GPT_4, CHAT_MODEL_GPT_4_BROWSING, CHAT_MODEL_GPT_4_VISION]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ import { ElSkeleton, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
|
||||
import { chatOperator } from '@/operators';
|
||||
import { IChatConversation } from '@/operators/chat/models';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { IChatConversation } from '@/models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SidePanel',
|
||||
@@ -89,11 +89,14 @@ export default defineComponent({
|
||||
conversations() {
|
||||
return this.$store.state.chat.conversations;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chat.applications;
|
||||
application() {
|
||||
return this.$store.state.chat.application;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.chat.getConversationsStatus === Status.Request;
|
||||
return this.$store.state.chat.status.getConversations === Status.Request;
|
||||
},
|
||||
token() {
|
||||
return this.application?.credentials?.[0].token;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -103,11 +106,20 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
async onConfirm(conversation: IChatConversation) {
|
||||
const token = this.token;
|
||||
if (!token) {
|
||||
console.error('Token is not found');
|
||||
return;
|
||||
}
|
||||
if (conversation?.deleting) {
|
||||
await chatOperator.deleteConversation(conversation.id);
|
||||
await chatOperator.deleteConversation(conversation.id, {
|
||||
token
|
||||
});
|
||||
await this.$store.dispatch('chat/getConversations');
|
||||
} else if (conversation?.editing) {
|
||||
await chatOperator.updateConversation(conversation);
|
||||
await chatOperator.updateConversation(conversation, {
|
||||
token
|
||||
});
|
||||
await this.$store.dispatch('chat/getConversations');
|
||||
} else {
|
||||
conversation.editing = true;
|
||||
|
||||
@@ -69,7 +69,8 @@ import { defineComponent } from 'vue';
|
||||
import { ElSkeleton, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CHATDOC_CONVERSATION, ROUTE_CHATDOC_CONVERSATION_NEW } from '@/router/constants';
|
||||
import { IChatdocRepository, chatdocOperator, IChatdocConversation } from '@/operators';
|
||||
import { chatdocOperator } from '@/operators';
|
||||
import { IChatdocRepository, IChatdocConversation } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SidePanel',
|
||||
@@ -93,8 +94,8 @@ export default defineComponent({
|
||||
conversations() {
|
||||
return this.repository?.conversations;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chatdoc.applications;
|
||||
application() {
|
||||
return this.$store.state.chatdoc.application;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
|
||||
import { ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
|
||||
import { IChatModel } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InputBox',
|
||||
|
||||
@@ -27,7 +27,7 @@ import AnsweringMark from './AnsweringMark.vue';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { ElAlert, ElButton } from 'element-plus';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { IChatdocMessage, IChatdocMessageState } from '@/operators';
|
||||
import { IChatdocMessage, IChatdocMessageState } from '@/models';
|
||||
import CopyToClipboard from '../common/CopyToClipboard.vue';
|
||||
import {
|
||||
ERROR_CODE_API_ERROR,
|
||||
|
||||
@@ -69,8 +69,8 @@ import { defineComponent } from 'vue';
|
||||
import { ElSkeleton, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
|
||||
import { chatdocOperator, IChatdocRepository } from '@/operators';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { IChatdocRepository } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SidePanel',
|
||||
|
||||
@@ -88,7 +88,6 @@ import {
|
||||
ROUTE_MIDJOURNEY_HISTORY,
|
||||
ROUTE_MIDJOURNEY_INDEX
|
||||
} from '@/router/constants';
|
||||
import HelpEntry from './HelpEntry2.vue';
|
||||
import Chevron from './Chevron.vue';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiPrice',
|
||||
props: {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElAlert } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FinalPrompt',
|
||||
components: {
|
||||
|
||||
+8
-12
@@ -3,7 +3,7 @@
|
||||
<el-button
|
||||
v-for="(option, optionKey) in options"
|
||||
:key="optionKey"
|
||||
:class="{ button: true, active: option.name === channel.name }"
|
||||
:class="{ button: true, active: option.name === mode.name }"
|
||||
@click="onSelect(option)"
|
||||
>
|
||||
<font-awesome-icon :class="{ icon: true, [option.name]: true }" :icon="option.icon" />
|
||||
@@ -18,12 +18,8 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import {
|
||||
IMidjourneyChannel,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
MIDJOURNEY_CHANNEL_TURBO
|
||||
} from '@/operators';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
import { IMidjourneyMode } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModelSelector',
|
||||
@@ -34,17 +30,17 @@ export default defineComponent({
|
||||
emits: ['update:modelValue', 'select'],
|
||||
data() {
|
||||
return {
|
||||
options: [MIDJOURNEY_CHANNEL_FAST, MIDJOURNEY_CHANNEL_RELAX, MIDJOURNEY_CHANNEL_TURBO]
|
||||
options: [MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
channel() {
|
||||
return this.$store.state.midjourney.channel;
|
||||
mode() {
|
||||
return this.$store.state.midjourney.mode;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSelect(option: IMidjourneyChannel) {
|
||||
this.$store.dispatch('midjourney/setChannel', option);
|
||||
onSelect(option: IMidjourneyMode) {
|
||||
this.$store.dispatch('midjourney/setMode', option);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -13,7 +13,6 @@
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import model from '@/i18n/zh/midjourney/model';
|
||||
|
||||
const DEFAULT_STYLE = '';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div v-else-if="tasks.length > 0" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="false" :model-value="task" :applications="applications" @custom="$emit('custom', $event)" />
|
||||
<task-preview :full="false" :model-value="task" @custom="$emit('custom', $event)" />
|
||||
</div>
|
||||
<el-button type="primary" class="btn mb-4" @click="onLoadHistory">{{ $t('midjourney.button.history') }}</el-button>
|
||||
</div>
|
||||
@@ -25,7 +25,7 @@ import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import { ROUTE_MIDJOURNEY_HISTORY } from '@/router';
|
||||
import { ElButton, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskBriefList',
|
||||
@@ -44,17 +44,18 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.midjourney.getImagineTasksStatus === Status.Request;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="tasks" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="true" :model-value="task" :applications="applications" @custom="onCustom($event)" />
|
||||
<task-preview :full="true" :model-value="task" @custom="onCustom($event)" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="tasks">
|
||||
@@ -23,8 +23,12 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import { ElRow, ElCol, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/models';
|
||||
|
||||
interface IData {
|
||||
job: number | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskFullList',
|
||||
@@ -36,9 +40,9 @@ export default defineComponent({
|
||||
ElCard
|
||||
},
|
||||
emits: ['update:modelValue', 'custom'],
|
||||
data() {
|
||||
data(): IData {
|
||||
return {
|
||||
job: 0
|
||||
job: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -55,13 +59,13 @@ export default defineComponent({
|
||||
return 12;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.midjourney.getImagineTasksStatus === Status.Request;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -74,6 +78,7 @@ export default defineComponent({
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-tag v-if="channel" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [channel.name]: true }" :icon="channel?.icon" />
|
||||
{{ channel?.displayName }}
|
||||
<el-tag v-if="mode" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [mode.name]: true }" :icon="mode.icon" />
|
||||
{{ mode?.displayName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,8 +45,8 @@
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('midjourney.field.failureReason') }}:
|
||||
{{ modelValue?.response?.detail }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.detail!" class="btn-copy" />
|
||||
{{ modelValue?.response?.error?.message }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.error?.message!" class="btn-copy" />
|
||||
</p>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
@@ -56,7 +56,6 @@
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
|
||||
<div v-else :class="{ content: true, full: full }">
|
||||
<el-image
|
||||
v-if="modelValue?.response?.image_url"
|
||||
@@ -92,9 +91,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<p class="datetime">
|
||||
<p v-if="modelValue?.created_at" class="datetime">
|
||||
<font-awesome-icon icon="fa-regular fa-clock" class="mr-1" />
|
||||
{{ $dayjs.format(modelValue?.created_at) }}
|
||||
{{ $dayjs.format(new Date(parseFloat(modelValue?.created_at) * 1000)) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,17 +102,15 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElTag, ElButton, ElTooltip, ElSkeleton, ElAlert } from 'element-plus';
|
||||
import { IApplication, IMidjourneyImagineTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/operators';
|
||||
import {
|
||||
API_ID_MIDJOURNEY_FAST,
|
||||
API_ID_MIDJOURNEY_RELAX,
|
||||
API_ID_MIDJOURNEY_TURBO,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
MIDJOURNEY_CHANNEL_TURBO
|
||||
} from '@/operators/midjourney/constants';
|
||||
IMidjourneyImagineTask,
|
||||
MidjourneyImagineAction,
|
||||
MidjourneyImagineMode,
|
||||
MidjourneyImagineState
|
||||
} from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
|
||||
interface IData {
|
||||
midjourneyImagineState: typeof MidjourneyImagineState;
|
||||
@@ -138,10 +135,6 @@ export default defineComponent({
|
||||
type: Object as () => IMidjourneyImagineTask | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Object as () => IApplication[] | undefined,
|
||||
required: true
|
||||
},
|
||||
full: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -153,22 +146,26 @@ export default defineComponent({
|
||||
midjourneyImagineState: MidjourneyImagineState,
|
||||
actionMapping: {
|
||||
[MidjourneyImagineAction.GENERATE]: 'Generate',
|
||||
[MidjourneyImagineAction.UPSAMPLE1]: 'U1',
|
||||
[MidjourneyImagineAction.UPSAMPLE2]: 'U2',
|
||||
[MidjourneyImagineAction.UPSAMPLE3]: 'U3',
|
||||
[MidjourneyImagineAction.UPSAMPLE4]: 'U4',
|
||||
[MidjourneyImagineAction.UPSCALE1]: 'U1',
|
||||
[MidjourneyImagineAction.UPSCALE2]: 'U2',
|
||||
[MidjourneyImagineAction.UPSCALE3]: 'U3',
|
||||
[MidjourneyImagineAction.UPSCALE4]: 'U4',
|
||||
[MidjourneyImagineAction.VARIATION1]: 'V1',
|
||||
[MidjourneyImagineAction.VARIATION2]: 'V2',
|
||||
[MidjourneyImagineAction.VARIATION3]: 'V3',
|
||||
[MidjourneyImagineAction.VARIATION4]: 'V4',
|
||||
[MidjourneyImagineAction.HIGH_VARIATION]: 'Vary (Strong)',
|
||||
[MidjourneyImagineAction.LOW_VARIATION]: 'Vary (Subtle)',
|
||||
[MidjourneyImagineAction.VARIATION_STRONG]: 'Vary (Strong)',
|
||||
[MidjourneyImagineAction.VARIATION_SUBTLE]: 'Vary (Subtle)',
|
||||
[MidjourneyImagineAction.UPSCALE_CREATIVE]: 'Upscale (Creative)',
|
||||
[MidjourneyImagineAction.UPSCALE_SUBTLE]: 'Upscale (Subtle)',
|
||||
[MidjourneyImagineAction.ZOOM_OUT_2X]: 'Zoom Out 2x',
|
||||
[MidjourneyImagineAction.ZOOM_OUT_1_5X]: 'Zoom Out 1.5x',
|
||||
[MidjourneyImagineAction.UPSAMPLE_2X]: 'Upsample 2x',
|
||||
[MidjourneyImagineAction.UPSAMPLE_4X]: 'Upsample 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_2X]: 'Redo Upsample 2x',
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_4X]: 'Redo Upsample 4x',
|
||||
[MidjourneyImagineAction.UPSCALE_2X]: 'Upscale 2x',
|
||||
[MidjourneyImagineAction.UPSCALE_4X]: 'Upscale 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_2X]: 'Redo Upscale 2x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_4X]: 'Redo Upscale 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_SUBTLE]: 'Redo Upscale (Subtle)',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_CREATIVE]: 'Redo Upscale (Creative)',
|
||||
[MidjourneyImagineAction.SQUARE]: 'Make Square',
|
||||
[MidjourneyImagineAction.PAN_LEFT]: '⬅️',
|
||||
[MidjourneyImagineAction.PAN_UP]: '⬆️',
|
||||
@@ -178,22 +175,26 @@ export default defineComponent({
|
||||
},
|
||||
descriptionMapping: {
|
||||
[MidjourneyImagineAction.GENERATE]: this.$t('midjourney.description.generate'),
|
||||
[MidjourneyImagineAction.UPSAMPLE1]: this.$t('midjourney.description.upsample1'),
|
||||
[MidjourneyImagineAction.UPSAMPLE2]: this.$t('midjourney.description.upsample2'),
|
||||
[MidjourneyImagineAction.UPSAMPLE3]: this.$t('midjourney.description.upsample3'),
|
||||
[MidjourneyImagineAction.UPSAMPLE4]: this.$t('midjourney.description.upsample4'),
|
||||
[MidjourneyImagineAction.UPSCALE1]: this.$t('midjourney.description.upscale1'),
|
||||
[MidjourneyImagineAction.UPSCALE2]: this.$t('midjourney.description.upscale2'),
|
||||
[MidjourneyImagineAction.UPSCALE3]: this.$t('midjourney.description.upscale3'),
|
||||
[MidjourneyImagineAction.UPSCALE4]: this.$t('midjourney.description.upscale4'),
|
||||
[MidjourneyImagineAction.VARIATION1]: this.$t('midjourney.description.variation1'),
|
||||
[MidjourneyImagineAction.VARIATION2]: this.$t('midjourney.description.variation2'),
|
||||
[MidjourneyImagineAction.VARIATION3]: this.$t('midjourney.description.variation3'),
|
||||
[MidjourneyImagineAction.VARIATION4]: this.$t('midjourney.description.variation4'),
|
||||
[MidjourneyImagineAction.HIGH_VARIATION]: this.$t('midjourney.description.high_variation'),
|
||||
[MidjourneyImagineAction.LOW_VARIATION]: this.$t('midjourney.description.low_variation'),
|
||||
[MidjourneyImagineAction.VARIATION_STRONG]: this.$t('midjourney.description.variation_strong'),
|
||||
[MidjourneyImagineAction.VARIATION_SUBTLE]: this.$t('midjourney.description.variation_subtle'),
|
||||
[MidjourneyImagineAction.ZOOM_OUT_2X]: this.$t('midjourney.description.zoom_out_2x'),
|
||||
[MidjourneyImagineAction.ZOOM_OUT_1_5X]: this.$t('midjourney.description.zoom_out_1_5x'),
|
||||
[MidjourneyImagineAction.UPSAMPLE_2X]: this.$t('midjourney.description.upsample_2x'),
|
||||
[MidjourneyImagineAction.UPSAMPLE_4X]: this.$t('midjourney.description.upsample_4x'),
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_2X]: this.$t('midjourney.description.redo_upsample_2x'),
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_4X]: this.$t('midjourney.description.redo_upsample_4x'),
|
||||
[MidjourneyImagineAction.UPSCALE_2X]: this.$t('midjourney.description.upscale_2x'),
|
||||
[MidjourneyImagineAction.UPSCALE_4X]: this.$t('midjourney.description.upscale_4x'),
|
||||
[MidjourneyImagineAction.UPSCALE_SUBTLE]: this.$t('midjourney.description.upscale_subtle'),
|
||||
[MidjourneyImagineAction.UPSCALE_CREATIVE]: this.$t('midjourney.description.upscale_creative'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_2X]: this.$t('midjourney.description.redo_upscale_2x'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_4X]: this.$t('midjourney.description.redo_upscale_4x'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_SUBTLE]: this.$t('midjourney.description.redo_upscale_subtle'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_CREATIVE]: this.$t('midjourney.description.redo_upscale_creative'),
|
||||
[MidjourneyImagineAction.SQUARE]: this.$t('midjourney.description.square'),
|
||||
[MidjourneyImagineAction.PAN_LEFT]: this.$t('midjourney.description.pan_left'),
|
||||
[MidjourneyImagineAction.PAN_UP]: this.$t('midjourney.description.pan_up'),
|
||||
@@ -205,19 +206,19 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.applications?.find((application) => {
|
||||
return application.id === this.modelValue?.request?.application_id;
|
||||
});
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
channel() {
|
||||
if (this.application?.api_id === API_ID_MIDJOURNEY_FAST) {
|
||||
return MIDJOURNEY_CHANNEL_FAST;
|
||||
} else if (this.application?.api_id === API_ID_MIDJOURNEY_RELAX) {
|
||||
return MIDJOURNEY_CHANNEL_RELAX;
|
||||
} else if (this.application?.api_id === API_ID_MIDJOURNEY_TURBO) {
|
||||
return MIDJOURNEY_CHANNEL_TURBO;
|
||||
mode() {
|
||||
switch (this.modelValue?.mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -233,6 +234,16 @@ export default defineComponent({
|
||||
link.href = url;
|
||||
link.download = url.split('/').pop() as string;
|
||||
link.click();
|
||||
},
|
||||
getModeIcon(mode: MidjourneyImagineMode): string | undefined {
|
||||
switch (mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST.icon;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO.icon;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX.icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage, orderOperator } from '@/operators';
|
||||
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage } from '@/models';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ROUTE_CONSOLE_ORDER_DETAIL } from '@/router';
|
||||
@@ -92,17 +92,12 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
price() {
|
||||
if (this.application?.type === IApplicationType.API) {
|
||||
if (this.application.api?.price && this.form.amount) {
|
||||
return this.form.amount * this.application.api?.price;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
package() {
|
||||
if (this.application?.type === IApplicationType.API) {
|
||||
if (this.application.api?.packages && this.form.packageId) {
|
||||
const filterPackages = this.application.api?.packages.filter((item) => item.id === this.form.packageId);
|
||||
if (this.application.service?.packages && this.form.packageId) {
|
||||
const filterPackages = this.application.service?.packages.filter((item) => item.id === this.form.packageId);
|
||||
if (filterPackages.length > 0) {
|
||||
return filterPackages[0];
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
|
||||
import { orderOperator } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog } from 'element-plus';
|
||||
import { IOrder, IOrderDetailResponse, OrderState } from '@/models';
|
||||
|
||||
interface IData {
|
||||
refreshTimer: number | undefined;
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
|
||||
import { orderOperator } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElRow, ElCol } from 'element-plus';
|
||||
import QrCode from 'vue-qrcode';
|
||||
import { IOrder, IOrderDetailResponse, OrderState } from '@/models';
|
||||
|
||||
interface IData {
|
||||
refreshTimer: number | undefined;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { IChatModel } from '@/models';
|
||||
|
||||
export const ROLE_SYSTEM = 'system';
|
||||
export const ROLE_ASSISTANT = 'assistant';
|
||||
export const ROLE_USER = 'user';
|
||||
|
||||
export const CHAT_MODEL_NAME_GPT_3_5 = 'gpt-3.5';
|
||||
export const CHAT_MODEL_NAME_GPT_3_5_BROWSING = 'gpt-3.5-browsing';
|
||||
export const CHAT_MODEL_NAME_GPT_4 = 'gpt-4';
|
||||
export const CHAT_MODEL_NAME_GPT_4_BROWSING = 'gpt-4-browsing';
|
||||
export const CHAT_MODEL_NAME_GPT_4_VISION = 'gpt-4-vision';
|
||||
|
||||
export const CHAT_SERVICE_ID = 'b1fbcc32-e218-4253-9dc3-4fe600a1bfb9';
|
||||
|
||||
export const CHAT_MODEL_GPT_3_5: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_3_5,
|
||||
displayName: '3.5 - 标准',
|
||||
description: '3.5 标准模型,输入约 8 千汉字'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_3_5_BROWSING: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_3_5_BROWSING,
|
||||
displayName: '3.5 - 联网',
|
||||
description: '3.5 联网模型,额外支持实时联网搜索问答'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4,
|
||||
displayName: '4.0 - 标准',
|
||||
description: '4.0 标准模型,输入约 4 千汉字'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4_BROWSING: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4_BROWSING,
|
||||
displayName: '4.0 - 联网',
|
||||
description: '4.0 联网模型,支持实时联网搜索问答'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4_VISION: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4_VISION,
|
||||
displayName: '4.0 - 视觉',
|
||||
description: '4.0 视觉模型,支持图片输入和识别'
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export const CHATDOC_SERVICE_ID = '5d732942-4d44-48be-958e-dd8474d8aa8d';
|
||||
@@ -1,4 +1,4 @@
|
||||
export const BASE_URL_DATA = 'https://platform.acedata.cloud';
|
||||
export const BASE_URL_PLATFORM = 'https://platform.acedata.cloud';
|
||||
export const BASE_URL_HUB = 'https://hub.acedata.cloud';
|
||||
export const BASE_URL_AUTH = 'https://auth.acedata.cloud';
|
||||
export const BASE_URL_API = 'https://api.acedata.cloud';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from './errorCode';
|
||||
export * from './endpoint';
|
||||
export * from './role';
|
||||
export * from './action';
|
||||
export * from './chat';
|
||||
export * from './chatdoc';
|
||||
export * from './midjourney';
|
||||
@@ -0,0 +1,26 @@
|
||||
import i18n from '@/i18n';
|
||||
import { IMidjourneyMode } from '@/models';
|
||||
|
||||
export const MIDJOURNEY_MODE_NAME_FAST = 'fast';
|
||||
export const MIDJOURNEY_MODE_NAME_RELAX = 'relax';
|
||||
export const MIDJOURNEY_MODE_NAME_TURBO = 'turbo';
|
||||
|
||||
export const MIDJOURNEY_SERVICE_ID = 'd87e5e99-b797-4ade-9e73-b896896b0461';
|
||||
|
||||
export const MIDJOURNEY_MODE_FAST: IMidjourneyMode = {
|
||||
icon: 'fa-solid fa-wind',
|
||||
name: MIDJOURNEY_MODE_NAME_FAST,
|
||||
displayName: i18n.global.t('midjourney.button.fast')
|
||||
};
|
||||
|
||||
export const MIDJOURNEY_MODE_RELAX: IMidjourneyMode = {
|
||||
icon: 'fa-solid fa-mug-saucer',
|
||||
name: MIDJOURNEY_MODE_NAME_RELAX,
|
||||
displayName: i18n.global.t('midjourney.button.relax')
|
||||
};
|
||||
|
||||
export const MIDJOURNEY_MODE_TURBO: IMidjourneyMode = {
|
||||
icon: 'fa-solid fa-bolt',
|
||||
name: MIDJOURNEY_MODE_NAME_TURBO,
|
||||
displayName: i18n.global.t('midjourney.button.turbo')
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
export const ROLE_SYSTEM = 'system';
|
||||
export const ROLE_ASSISTANT = 'assistant';
|
||||
export const ROLE_USER = 'user';
|
||||
@@ -7,6 +7,6 @@ export default {
|
||||
startPrice: '起',
|
||||
helpWechat: '技术客服微信',
|
||||
helpWechat2: '业务客服微信',
|
||||
remainingCount: '剩余次数',
|
||||
usedCount: '使用次数'
|
||||
remainingAmount: '剩余积分',
|
||||
usedAmount: '使用积分'
|
||||
};
|
||||
@@ -23,10 +23,10 @@ export default {
|
||||
uploadReferences: '上传图片作为生成的参考,支持最多 5 张图片。如果上传的图片数量超过 1 张,将会自动融合',
|
||||
raw: '启用此开关后,生成的图像将使用 Midjourney 模型,生成原始风格的图片',
|
||||
generate: '点击此按钮开始生成图片',
|
||||
upsample1: '放大第一张图片',
|
||||
upsample2: '放大第二张图片',
|
||||
upsample3: '放大第三张图片',
|
||||
upsample4: '放大第四张图片',
|
||||
upscale1: '放大第一张图片',
|
||||
upscale2: '放大第二张图片',
|
||||
upscale3: '放大第三张图片',
|
||||
upscale4: '放大第四张图片',
|
||||
variation1: '微调第一张图片',
|
||||
variation2: '微调第二张图片',
|
||||
variation3: '微调第三张图片',
|
||||
@@ -43,10 +43,10 @@ export default {
|
||||
pan_right: '向右平移',
|
||||
zoom_in_2x: '放大 2 倍',
|
||||
zoom_in_1_5x: '放大 1.5 倍',
|
||||
upsample_2x: '放大 2 倍',
|
||||
upsample_4x: '放大 4 倍',
|
||||
redo_upsample_2x: '重新放大 2 倍',
|
||||
redo_upsample_4x: '重新放大 4 倍',
|
||||
upscale_2x: '放大 2 倍',
|
||||
upscale_4x: '放大 4 倍',
|
||||
redo_upscale_2x: '重新放大 2 倍',
|
||||
redo_upscale_4x: '重新放大 4 倍',
|
||||
download: '下载',
|
||||
prompt: '输入指令如果添加额外参数,其会覆盖默认预设参数,如添加 --stylize 200,最终指令会强制使用 --stylize 200'
|
||||
};
|
||||
@@ -37,12 +37,16 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
await this.onGetApplications();
|
||||
await this.onGetService();
|
||||
await this.onGetApplication();
|
||||
await this.onGetConversations();
|
||||
},
|
||||
methods: {
|
||||
async onGetApplications() {
|
||||
await this.$store.dispatch('chat/getApplications');
|
||||
async onGetService() {
|
||||
await this.$store.dispatch('chat/getService');
|
||||
},
|
||||
async onGetApplication() {
|
||||
await this.$store.dispatch('chat/getApplication');
|
||||
},
|
||||
async onGetConversations() {
|
||||
await this.$store.dispatch('chat/getConversations');
|
||||
|
||||
@@ -25,7 +25,7 @@ import { defineComponent } from 'vue';
|
||||
import { ElMenu, ElMenuItem } from 'element-plus';
|
||||
import { ROUTE_CHATDOC_CONVERSATION_NEW, ROUTE_CHATDOC_MANAGE } from '@/router';
|
||||
import { RouteLocationRaw } from 'vue-router';
|
||||
import { IChatdocRepository } from '@/operators';
|
||||
import { IChatdocRepository } from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
interface IMenuItem {
|
||||
@@ -92,12 +92,16 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.getService();
|
||||
await this.onGetApplications();
|
||||
await this.onGetRepositories();
|
||||
},
|
||||
methods: {
|
||||
async getService() {
|
||||
await this.$store.dispatch('chatdoc/getService');
|
||||
},
|
||||
async onGetApplications() {
|
||||
await this.$store.dispatch('chatdoc/getApplications');
|
||||
await this.$store.dispatch('chatdoc/getApplication');
|
||||
},
|
||||
async onGetRepositories() {
|
||||
await this.$store.dispatch('chatdoc/getRepositories');
|
||||
|
||||
@@ -41,6 +41,18 @@ export default defineComponent({
|
||||
drawer: false,
|
||||
drawer2: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
await this.onGetService();
|
||||
await this.onGetApplication();
|
||||
},
|
||||
methods: {
|
||||
async onGetService() {
|
||||
await this.$store.dispatch('midjourney/getService');
|
||||
},
|
||||
async onGetApplication() {
|
||||
await this.$store.dispatch('midjourney/getApplication');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IService } from './service';
|
||||
|
||||
export interface IForm {
|
||||
queries?: {
|
||||
[key: string]: string;
|
||||
@@ -53,28 +55,28 @@ export enum IApiUnit {
|
||||
COUNT = 'Count'
|
||||
}
|
||||
|
||||
export interface IApiPrice {
|
||||
data: any[];
|
||||
spans: [number, number, number, number][];
|
||||
columns: {
|
||||
key: string;
|
||||
label: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface IApi {
|
||||
id: string;
|
||||
path: string;
|
||||
endpoint: string;
|
||||
price?: number;
|
||||
unit?: IApiUnit;
|
||||
name?: string;
|
||||
title?: string;
|
||||
definition?: any;
|
||||
introduction?: string;
|
||||
applied_count?: number;
|
||||
application_id?: string;
|
||||
free_amount?: number;
|
||||
applied?: boolean;
|
||||
price?: IApiPrice;
|
||||
tags?: string[];
|
||||
request: IRequest;
|
||||
request_id: string;
|
||||
responses: IResponse[];
|
||||
response_ids: string[];
|
||||
document_id?: string;
|
||||
packages?: IPackage[];
|
||||
service?: IService;
|
||||
service_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
stage?: string;
|
||||
}
|
||||
|
||||
export interface IApiListResponse {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IApi } from '../api';
|
||||
import { IService } from './service';
|
||||
|
||||
export enum IApplicationType {
|
||||
API = 'Api'
|
||||
@@ -21,15 +21,13 @@ export interface ICredential {
|
||||
|
||||
export interface IApplication {
|
||||
id?: string;
|
||||
api?: IApi;
|
||||
type?: IApplicationType;
|
||||
api_id?: string;
|
||||
proxy_id?: string;
|
||||
api_key?: string;
|
||||
service_id?: string;
|
||||
service?: IService;
|
||||
user_id?: string;
|
||||
remaining_amount?: number;
|
||||
used_amount?: number;
|
||||
credential?: ICredential;
|
||||
credentials?: ICredential[];
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
File renamed without changes.
@@ -1,23 +1,20 @@
|
||||
import { ROLE_ASSISTANT, ROLE_SYSTEM, ROLE_USER } from '@/constants';
|
||||
import {
|
||||
CHAT_MODEL_NAME_CHATGPT,
|
||||
CHAT_MODEL_NAME_CHATGPT4,
|
||||
CHAT_MODEL_NAME_CHATGPT4_BROWSING,
|
||||
CHAT_MODEL_NAME_CHATGPT4_VISION,
|
||||
CHAT_MODEL_NAME_CHATGPT_16K,
|
||||
CHAT_MODEL_NAME_CHATGPT_BROWSING
|
||||
} from './constants';
|
||||
CHAT_MODEL_NAME_GPT_3_5,
|
||||
CHAT_MODEL_NAME_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_NAME_GPT_4,
|
||||
CHAT_MODEL_NAME_GPT_4_BROWSING,
|
||||
CHAT_MODEL_NAME_GPT_4_VISION
|
||||
} from '@/constants';
|
||||
|
||||
export type IChatModelName =
|
||||
| typeof CHAT_MODEL_NAME_CHATGPT
|
||||
| typeof CHAT_MODEL_NAME_CHATGPT4
|
||||
| typeof CHAT_MODEL_NAME_CHATGPT_16K
|
||||
| typeof CHAT_MODEL_NAME_CHATGPT_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_CHATGPT4_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_CHATGPT4_VISION;
|
||||
| typeof CHAT_MODEL_NAME_GPT_3_5
|
||||
| typeof CHAT_MODEL_NAME_GPT_3_5_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_GPT_4
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_VISION;
|
||||
|
||||
export interface IChatModel {
|
||||
apiId: string;
|
||||
name: IChatModelName;
|
||||
displayName: string;
|
||||
description: string;
|
||||
@@ -25,7 +22,7 @@ export interface IChatModel {
|
||||
|
||||
interface IError {
|
||||
code: string;
|
||||
detail?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export enum IChatMessageState {
|
||||
@@ -57,42 +54,36 @@ export interface IChatConversation {
|
||||
new?: boolean;
|
||||
}
|
||||
|
||||
export interface IChatAskOptions {
|
||||
stream?: (response: IChatAskResponse) => void;
|
||||
token: string;
|
||||
endpoint: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface IChatConversationOptions {
|
||||
endpoint: string;
|
||||
path: string;
|
||||
stream?: (response: IChatConversationResponse) => void;
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface IChatAskRequest {
|
||||
question: string;
|
||||
export interface IChatConversationRequest {
|
||||
id?: string;
|
||||
question?: string;
|
||||
references?: string[];
|
||||
stateful?: boolean;
|
||||
conversation_id?: string;
|
||||
messages?: IChatMessage[];
|
||||
action?: IChatConversationAction;
|
||||
model: IChatModelName;
|
||||
}
|
||||
|
||||
export interface IChatAskResponse {
|
||||
export interface IChatConversationResponse {
|
||||
answer: string;
|
||||
delta_answer: string;
|
||||
conversation_id?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface IChatConversationsResponse {
|
||||
items: IChatConversation[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
export enum IChatConversationAction {
|
||||
CHAT = 'chat',
|
||||
RETRIEVE = 'retrieve',
|
||||
UPDATE = 'update',
|
||||
DELETE = 'delete',
|
||||
RETRIEVE_BATCH = 'retrieve_batch'
|
||||
}
|
||||
|
||||
export interface IChatConversationRequest {
|
||||
action: IChatConversationAction;
|
||||
id: string;
|
||||
messages?: IChatMessage[];
|
||||
}
|
||||
|
||||
export type IChatConversationResponse = IChatConversation;
|
||||
@@ -65,7 +65,10 @@ export interface IChatdocRepositoryRequest extends IChatdocRepository {
|
||||
}
|
||||
|
||||
export interface IChatdocRepositoryResponse extends IChatdocRepository {}
|
||||
export type IChatdocRepositoriesResponse = IChatdocRepository[];
|
||||
export type IChatdocRepositoriesResponse = {
|
||||
items: IChatdocRepository[];
|
||||
count: number;
|
||||
};
|
||||
export type IChatdocDocumentsResponse = IChatdocDocument[];
|
||||
|
||||
export interface IChatdocChatResponse {
|
||||
@@ -0,0 +1,6 @@
|
||||
export enum Status {
|
||||
Request = 'Request',
|
||||
Success = 'Success',
|
||||
Error = 'Error',
|
||||
None = 'None'
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IOrder } from '../order';
|
||||
import { IOrder } from './order';
|
||||
|
||||
export interface IDistributionHistory {
|
||||
id: string;
|
||||
@@ -0,0 +1,12 @@
|
||||
export * from './common';
|
||||
export * from './api';
|
||||
export * from './application';
|
||||
export * from './auth';
|
||||
export * from './chat';
|
||||
export * from './chatdoc';
|
||||
export * from './distribution';
|
||||
export * from './midjourney';
|
||||
export * from './order';
|
||||
export * from './usage';
|
||||
export * from './user';
|
||||
export * from './service';
|
||||
@@ -1,6 +1,5 @@
|
||||
export interface IMidjourneyChannel {
|
||||
export interface IMidjourneyMode {
|
||||
icon: string;
|
||||
apiId: string;
|
||||
name: string;
|
||||
displayName: string;
|
||||
}
|
||||
@@ -21,16 +20,18 @@ export interface IMidjourneyPreset {
|
||||
|
||||
export enum MidjourneyImagineAction {
|
||||
GENERATE = 'generate',
|
||||
UPSAMPLE1 = 'upsample1',
|
||||
UPSAMPLE2 = 'upsample2',
|
||||
UPSAMPLE3 = 'upsample3',
|
||||
UPSAMPLE4 = 'upsample4',
|
||||
UPSCALE1 = 'upscale1',
|
||||
UPSCALE2 = 'upscale2',
|
||||
UPSCALE3 = 'upscale3',
|
||||
UPSCALE4 = 'upscale4',
|
||||
VARIATION1 = 'variation1',
|
||||
VARIATION2 = 'variation2',
|
||||
VARIATION3 = 'variation3',
|
||||
VARIATION4 = 'variation4',
|
||||
HIGH_VARIATION = 'high_variation',
|
||||
LOW_VARIATION = 'low_variation',
|
||||
VARIATION_STRONG = 'variation_strong',
|
||||
VARIATION_SUBTLE = 'variation_subtle',
|
||||
UPSCALE_SUBTLE = 'upscale_subtle',
|
||||
UPSCALE_CREATIVE = 'upscale_creative',
|
||||
ZOOM_OUT_2X = 'zoom_out_2x',
|
||||
ZOOM_OUT_1_5X = 'zoom_out_1_5x',
|
||||
SQUARE = 'square',
|
||||
@@ -39,10 +40,12 @@ export enum MidjourneyImagineAction {
|
||||
PAN_DOWN = 'pan_down',
|
||||
PAN_RIGHT = 'pan_right',
|
||||
REROLL = 'reroll',
|
||||
UPSAMPLE_2X = 'upsample_2x',
|
||||
UPSAMPLE_4X = 'upsample_4x',
|
||||
REDO_UPSAMPLE_2X = 'redo_upsample_2x',
|
||||
REDO_UPSAMPLE_4X = 'redo_upsample_4x'
|
||||
UPSCALE_2X = 'upscale_2x',
|
||||
UPSCALE_4X = 'upscale_4x',
|
||||
REDO_UPSCALE_2X = 'redo_upscale_2x',
|
||||
REDO_UPSCALE_4X = 'redo_upscale_4x',
|
||||
REDO_UPSCALE_SUBTLE = 'redo_upscale_subtle',
|
||||
REDO_UPSCALE_CREATIVE = 'redo_upscale_creative'
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineState {
|
||||
@@ -52,8 +55,15 @@ export enum MidjourneyImagineState {
|
||||
FAILED = 'failed'
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineMode {
|
||||
FAST = 'fast',
|
||||
RELAX = 'relax',
|
||||
TURBO = 'turbo'
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineRequest {
|
||||
action?: MidjourneyImagineAction;
|
||||
mode?: MidjourneyImagineMode;
|
||||
prompt?: string;
|
||||
image_id?: string;
|
||||
translation?: boolean;
|
||||
@@ -77,11 +87,19 @@ export interface IMidjourneyImagineResponse {
|
||||
export interface IMidjourneyImagineTask {
|
||||
id: string;
|
||||
created_at?: string;
|
||||
mode: MidjourneyImagineMode;
|
||||
request?: IMidjourneyImagineRequest;
|
||||
response?: IMidjourneyImagineResponse;
|
||||
state?: MidjourneyImagineState;
|
||||
}
|
||||
|
||||
export type IMidjourneyImagineTaskResponse = IMidjourneyImagineTask;
|
||||
|
||||
export interface IMidjourneyImagineTasksResponse {
|
||||
items: IMidjourneyImagineTask[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineOptions {
|
||||
stream?: (response: IMidjourneyImagineResponse) => void;
|
||||
token?: string;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IApplication } from '../application';
|
||||
import { IApplication } from './application';
|
||||
|
||||
export enum OrderState {
|
||||
PENDING = 'Pending',
|
||||
@@ -0,0 +1,28 @@
|
||||
import { IApi, IPackage } from './api';
|
||||
|
||||
export interface IService {
|
||||
id: string;
|
||||
title: string;
|
||||
unit?: string;
|
||||
price?: number;
|
||||
description?: string;
|
||||
free_amount?: number;
|
||||
applied_count?: number;
|
||||
applied?: boolean;
|
||||
tags?: string[];
|
||||
thumbnail?: string;
|
||||
introduction?: string;
|
||||
apis?: IApi[];
|
||||
api_ids?: string[];
|
||||
packages?: IPackage[];
|
||||
package_ids?: string[];
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IServiceListResponse {
|
||||
count: number;
|
||||
items: IService[];
|
||||
}
|
||||
|
||||
export type IServiceDetailResponse = IService;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IApi } from '../api';
|
||||
import { IApi } from './api';
|
||||
|
||||
export interface IApiUsage {
|
||||
id?: string;
|
||||
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IApi, IApiDetailResponse, IApiListResponse } from '../api/models';
|
||||
import { httpClient } from './common';
|
||||
import { IApi, IApiDetailResponse, IApiListResponse } from '@/models';
|
||||
|
||||
export interface IApiQuery {
|
||||
limit?: number;
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,13 +1,13 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IApplication, IApplicationDetailResponse, IApplicationListResponse, IApplicationType } from './models';
|
||||
import { httpClient } from './common';
|
||||
import { IApplication, IApplicationDetailResponse, IApplicationListResponse, IApplicationType } from '@/models';
|
||||
|
||||
export interface IApplicationQuery {
|
||||
user_id?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
type?: IApplicationType;
|
||||
api_id?: string | string[];
|
||||
service_id?: string;
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { ITokenResponse, IToken, IOAuthTokenRequest, IOAuthTokenResponse } from './models';
|
||||
import { httpClient } from './common';
|
||||
import { ITokenResponse, IToken, IOAuthTokenRequest, IOAuthTokenResponse } from '@/models';
|
||||
import { getBaseUrlAuth } from '@/utils';
|
||||
|
||||
class AuthOperator {
|
||||
@@ -0,0 +1,129 @@
|
||||
import axios, { AxiosProgressEvent, AxiosResponse } from 'axios';
|
||||
import {
|
||||
IChatConversation,
|
||||
IChatConversationAction,
|
||||
IChatConversationOptions,
|
||||
IChatConversationRequest,
|
||||
IChatConversationResponse,
|
||||
IChatConversationsResponse
|
||||
} from '@/models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class ChatOperator {
|
||||
async chatConversation(
|
||||
data: IChatConversationRequest,
|
||||
options: IChatConversationOptions
|
||||
): Promise<AxiosResponse<IChatConversationResponse>> {
|
||||
return await axios.post('/aichat/conversations', data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
accept: 'application/x-ndjson',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API,
|
||||
responseType: 'stream',
|
||||
onDownloadProgress: ({ event }: AxiosProgressEvent) => {
|
||||
const response = event.target.response;
|
||||
const lines = response.split('\r\n').filter((line: string) => !!line);
|
||||
const lastLine = lines[lines.length - 1];
|
||||
if (lastLine) {
|
||||
const jsonData = JSON.parse(lastLine);
|
||||
if (options?.stream) {
|
||||
options?.stream(jsonData as IChatConversationResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getConversation(
|
||||
id: string | undefined,
|
||||
options: IChatConversationOptions
|
||||
): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/aichat/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.RETRIEVE,
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async getConversations(
|
||||
filter: {
|
||||
ids?: string[];
|
||||
applicationId?: string;
|
||||
},
|
||||
options: IChatConversationOptions
|
||||
): Promise<AxiosResponse<IChatConversationsResponse>> {
|
||||
return await axios.post(
|
||||
`/aichat/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.RETRIEVE_BATCH,
|
||||
...(filter.ids
|
||||
? {
|
||||
ids: filter.ids
|
||||
}
|
||||
: {}),
|
||||
...(filter.applicationId
|
||||
? {
|
||||
application_id: filter.applicationId
|
||||
}
|
||||
: {})
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async deleteConversation(id: string, options: IChatConversationOptions): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/aichat/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.DELETE,
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async updateConversation(
|
||||
payload: IChatConversation,
|
||||
options: IChatConversationOptions
|
||||
): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/aichat/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.UPDATE,
|
||||
...payload
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const chatOperator = new ChatOperator();
|
||||
@@ -1,57 +0,0 @@
|
||||
import { IChatModel } from './models';
|
||||
|
||||
export const CHAT_MODEL_NAME_CHATGPT = 'chatgpt';
|
||||
export const CHAT_MODEL_NAME_CHATGPT4 = 'chatgpt4';
|
||||
export const CHAT_MODEL_NAME_CHATGPT_16K = 'chatgpt-16k';
|
||||
export const CHAT_MODEL_NAME_CHATGPT_BROWSING = 'chatgpt-browsing';
|
||||
export const CHAT_MODEL_NAME_CHATGPT4_BROWSING = 'chatgpt4-browsing';
|
||||
export const CHAT_MODEL_NAME_CHATGPT4_VISION = 'chatgpt4-vision';
|
||||
|
||||
export const API_ID_CHATGPT = '1d58971c-e3cd-4713-a3ce-854a731adb14';
|
||||
export const API_ID_CHATGPT_16K = 'bf93bb28-55a7-4428-ad82-156bf410f4e2';
|
||||
export const API_ID_CHATGPT_BROWSING = '12271e2e-794f-4079-a714-f68dd0df7808';
|
||||
export const API_ID_CHATGPT4 = '1c4e8fa3-362b-4e0a-b0fd-9ff9fc173b77';
|
||||
export const API_ID_CHATGPT4_BROWSING = 'a61de51b-d0d0-48a2-9a17-1d4986d5d497';
|
||||
export const API_ID_CHATGPT4_VISION = '098c6e4a-14ae-4ff1-8d2f-0968532a4638';
|
||||
|
||||
export const CHAT_MODEL_CHATGPT: IChatModel = {
|
||||
apiId: API_ID_CHATGPT,
|
||||
name: CHAT_MODEL_NAME_CHATGPT,
|
||||
displayName: '3.5 - 标准',
|
||||
description: '3.5 标准模型,输入约 2 千汉字'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_CHATGPT_16K: IChatModel = {
|
||||
apiId: API_ID_CHATGPT_16K,
|
||||
name: CHAT_MODEL_NAME_CHATGPT_16K,
|
||||
displayName: '3.5 - 16K',
|
||||
description: '3.5 16K 模型,输入约 8 千汉字'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_CHATGPT_BROWSING: IChatModel = {
|
||||
apiId: API_ID_CHATGPT_BROWSING,
|
||||
name: CHAT_MODEL_NAME_CHATGPT_BROWSING,
|
||||
displayName: '3.5 - 联网',
|
||||
description: '3.5 联网模型,额外支持实时联网搜索问答'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_CHATGPT4: IChatModel = {
|
||||
apiId: API_ID_CHATGPT4,
|
||||
name: CHAT_MODEL_NAME_CHATGPT4,
|
||||
displayName: '4.0 - 标准',
|
||||
description: '4.0 标准模型,输入约 4 千汉字'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_CHATGPT4_BROWSING: IChatModel = {
|
||||
apiId: API_ID_CHATGPT4_BROWSING,
|
||||
name: CHAT_MODEL_NAME_CHATGPT4_BROWSING,
|
||||
displayName: '4.0 - 联网',
|
||||
description: '4.0 联网模型,支持实时联网搜索问答'
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_CHATGPT4_VISION: IChatModel = {
|
||||
apiId: API_ID_CHATGPT4_VISION,
|
||||
name: CHAT_MODEL_NAME_CHATGPT4_VISION,
|
||||
displayName: '4.0 - 视觉',
|
||||
description: '4.0 视觉模型,支持图片输入和识别'
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
export * from './constants';
|
||||
@@ -1,100 +0,0 @@
|
||||
import axios, { AxiosProgressEvent, AxiosResponse } from 'axios';
|
||||
import {
|
||||
IChatAskOptions,
|
||||
IChatAskRequest,
|
||||
IChatAskResponse,
|
||||
IChatConversation,
|
||||
IChatConversationAction
|
||||
} from './models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class ChatOperator {
|
||||
async askQuestion(data: IChatAskRequest, options: IChatAskOptions): Promise<AxiosResponse<IChatAskResponse>> {
|
||||
return await axios.post(options.path, data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
accept: 'application/x-ndjson',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: options.endpoint,
|
||||
responseType: 'stream',
|
||||
onDownloadProgress: ({ event }: AxiosProgressEvent) => {
|
||||
const response = event.target.response;
|
||||
const lines = response.split('\r\n').filter((line: string) => !!line);
|
||||
const lastLine = lines[lines.length - 1];
|
||||
if (lastLine) {
|
||||
const jsonData = JSON.parse(lastLine);
|
||||
if (options?.stream) {
|
||||
options?.stream(jsonData as IChatAskResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getConversation(id: string | undefined): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.RETRIEVE,
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async getConversations(ids: string[]): Promise<AxiosResponse<IChatConversation[]>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.RETRIEVE_BATCH,
|
||||
ids: ids
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async deleteConversation(id: string): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.DELETE,
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async updateConversation(payload: IChatConversation): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.UPDATE,
|
||||
...payload
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const chatOperator = new ChatOperator();
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
IChatdocDocumentsResponse,
|
||||
IChatdocRepositoriesResponse,
|
||||
IChatdocRepositoryResponse
|
||||
} from './models';
|
||||
} from '@/models';
|
||||
import { ACTION_RETRIEVE_ALL, ACTION_UPDATE, BASE_URL_API } from '@/constants';
|
||||
import { ACTION_CREATE, ACTION_DELETE, ACTION_RETRIEVE, ACTION_RETRIEVE_BATCH } from '@/constants';
|
||||
|
||||
@@ -128,12 +128,24 @@ class ChatdocOperator {
|
||||
);
|
||||
}
|
||||
|
||||
async getRepositories(ids: string[]): Promise<AxiosResponse<IChatdocRepositoriesResponse>> {
|
||||
async getRepositories(filter: {
|
||||
ids?: string[];
|
||||
applicationId?: string;
|
||||
}): Promise<AxiosResponse<IChatdocRepositoriesResponse>> {
|
||||
return await axios.post(
|
||||
`/chatdoc/repositories`,
|
||||
{
|
||||
action: ACTION_RETRIEVE_BATCH,
|
||||
ids
|
||||
...(filter.ids
|
||||
? {
|
||||
ids: filter.ids
|
||||
}
|
||||
: {}),
|
||||
...(filter.applicationId
|
||||
? {
|
||||
application_id: filter.applicationId
|
||||
}
|
||||
: {})
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
@@ -1,4 +0,0 @@
|
||||
export const API_ID_CHATDOC_REPOSITORIES = 'e22e9e3f-5594-4c48-9284-c1847c22c65f';
|
||||
export const API_ID_CHATDOC_DOCUMENTS = 'afc7917f-d89f-4dc9-95c2-863936b02cad';
|
||||
export const API_ID_CHATDOC_CONVERSATIONS = 'afc7917f-d89f-4dc9-95c2-863936b02cad';
|
||||
export const API_ID_CHATDOC_CHAT = '099eafc8-8167-4557-b8f2-47867ca76e24';
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
File renamed without changes.
@@ -1,11 +1,11 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { httpClient } from './common';
|
||||
import {
|
||||
IDistributionHistoryListResponse,
|
||||
IDistributionLevelListResponse,
|
||||
IDistributionStatusDetailResponse,
|
||||
IDistributionStatusListResponse
|
||||
} from './models';
|
||||
} from '@/models';
|
||||
|
||||
export interface IDistributionHistoryQuery {
|
||||
user_id?: string;
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './operator';
|
||||
export * from './models';
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './instance';
|
||||
export * from './common';
|
||||
export * from './application';
|
||||
export * from './user';
|
||||
export * from './chat';
|
||||
@@ -8,3 +8,5 @@ export * from './api';
|
||||
export * from './order';
|
||||
export * from './distribution';
|
||||
export * from './chatdoc';
|
||||
export * from './auth';
|
||||
export * from './service';
|
||||
@@ -0,0 +1,87 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import {
|
||||
IMidjourneyImagineRequest,
|
||||
IMidjourneyImagineResponse,
|
||||
IMidjourneyImagineTask,
|
||||
IMidjourneyImagineTaskResponse,
|
||||
IMidjourneyImagineTasksResponse
|
||||
} from '@/models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class MidjourneyOperator {
|
||||
async task(id: string, options: { token: string }): Promise<AxiosResponse<IMidjourneyImagineTaskResponse>> {
|
||||
return await axios.post(
|
||||
`/midjourney/tasks`,
|
||||
{
|
||||
action: 'retrieve',
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async tasks(
|
||||
filter: { ids?: string[]; applicationId?: string; limit?: number; offset?: number },
|
||||
options: { token: string }
|
||||
): Promise<AxiosResponse<IMidjourneyImagineTasksResponse>> {
|
||||
return await axios.post(
|
||||
`/midjourney/tasks`,
|
||||
{
|
||||
action: 'retrieve_batch',
|
||||
...(filter.ids
|
||||
? {
|
||||
ids: filter.ids
|
||||
}
|
||||
: {}),
|
||||
...(filter.applicationId
|
||||
? {
|
||||
application_id: filter.applicationId
|
||||
}
|
||||
: {}),
|
||||
...(filter.limit !== undefined
|
||||
? {
|
||||
limit: filter.limit
|
||||
}
|
||||
: {}),
|
||||
...(filter.offset !== undefined
|
||||
? {
|
||||
offset: filter.offset
|
||||
}
|
||||
: {})
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async imagine(
|
||||
data: IMidjourneyImagineRequest,
|
||||
options: {
|
||||
token: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IMidjourneyImagineResponse>> {
|
||||
return await axios.post('/midjourney/imagine', data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'content-type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const midjourneyOperator = new MidjourneyOperator();
|
||||
@@ -1,31 +0,0 @@
|
||||
import i18n from '@/i18n';
|
||||
import { IMidjourneyChannel } from './models';
|
||||
|
||||
export const MIDJOURNEY_CHANNEL_NAME_FAST = 'fast';
|
||||
export const MIDJOURNEY_CHANNEL_NAME_RELAX = 'relax';
|
||||
export const MIDJOURNEY_CHANNEL_NAME_TURBO = 'turbo';
|
||||
|
||||
export const API_ID_MIDJOURNEY_FAST = '9a628863-8879-462b-bbee-5dc46505b733';
|
||||
export const API_ID_MIDJOURNEY_RELAX = 'c58713f3-fef7-4c18-824c-9f76b5a07a7f';
|
||||
export const API_ID_MIDJOURNEY_TURBO = '62ec82bd-7de3-427f-b71a-ab3551ac7677';
|
||||
|
||||
export const MIDJOURNEY_CHANNEL_FAST: IMidjourneyChannel = {
|
||||
icon: 'fa-solid fa-wind',
|
||||
apiId: API_ID_MIDJOURNEY_FAST,
|
||||
name: MIDJOURNEY_CHANNEL_NAME_FAST,
|
||||
displayName: i18n.global.t('midjourney.button.fast')
|
||||
};
|
||||
|
||||
export const MIDJOURNEY_CHANNEL_RELAX: IMidjourneyChannel = {
|
||||
icon: 'fa-solid fa-mug-saucer',
|
||||
apiId: API_ID_MIDJOURNEY_RELAX,
|
||||
name: MIDJOURNEY_CHANNEL_NAME_RELAX,
|
||||
displayName: i18n.global.t('midjourney.button.relax')
|
||||
};
|
||||
|
||||
export const MIDJOURNEY_CHANNEL_TURBO: IMidjourneyChannel = {
|
||||
icon: 'fa-solid fa-bolt',
|
||||
apiId: API_ID_MIDJOURNEY_TURBO,
|
||||
name: MIDJOURNEY_CHANNEL_NAME_TURBO,
|
||||
displayName: i18n.global.t('midjourney.button.turbo')
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './constants';
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,72 +0,0 @@
|
||||
import axios, { AxiosProgressEvent, AxiosResponse } from 'axios';
|
||||
import { IMidjourneyImagineRequest, IMidjourneyImagineResponse, IMidjourneyImagineTask } from './models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class MidjourneyOperator {
|
||||
async task(id: string): Promise<AxiosResponse<IMidjourneyImagineTask>> {
|
||||
return await axios.post(
|
||||
`/midjourney/tasks`,
|
||||
{
|
||||
action: 'retrieve',
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async tasks(ids: string[]): Promise<AxiosResponse<IMidjourneyImagineTask[]>> {
|
||||
return await axios.post(
|
||||
`/midjourney/tasks`,
|
||||
{
|
||||
action: 'retrieve_batch',
|
||||
ids: ids
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async imagine(
|
||||
data: IMidjourneyImagineRequest,
|
||||
options: {
|
||||
stream?: (response: IMidjourneyImagineResponse) => void;
|
||||
token: string;
|
||||
endpoint: string;
|
||||
path: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IMidjourneyImagineResponse>> {
|
||||
return await axios.post(options.path, data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
accept: 'application/x-ndjson',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: options.endpoint,
|
||||
responseType: 'stream',
|
||||
onDownloadProgress: ({ event }: AxiosProgressEvent) => {
|
||||
const response = event.target.response;
|
||||
const lines = response.split('\r\n').filter((line: string) => !!line);
|
||||
const lastLine = lines[lines.length - 1];
|
||||
if (lastLine) {
|
||||
const jsonData = JSON.parse(lastLine);
|
||||
if (options?.stream) {
|
||||
options?.stream(jsonData as IMidjourneyImagineResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const midjourneyOperator = new MidjourneyOperator();
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IOrder, IOrderDetailResponse, IOrderListResponse } from './models';
|
||||
import { httpClient } from './common';
|
||||
import { IOrder, IOrderDetailResponse, IOrderListResponse } from '@/models';
|
||||
|
||||
export interface IOrderQuery {
|
||||
user_id?: string;
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -0,0 +1,37 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from './common';
|
||||
import { IService, IServiceDetailResponse, IServiceListResponse } from '@/models';
|
||||
|
||||
export interface IServiceQuery {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
class ServiceOperator {
|
||||
key = 'services';
|
||||
|
||||
async getAll(query: IServiceQuery): Promise<AxiosResponse<IServiceListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const serviceOperator = new ServiceOperator();
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IApiUsageDetailResponse, IApiUsageListResponse } from './models';
|
||||
import { httpClient } from './common';
|
||||
import { IApiUsageDetailResponse, IApiUsageListResponse } from '@/models';
|
||||
|
||||
export interface IApiUsageQuery {
|
||||
user_id?: string;
|
||||
Whitespace-only changes.
@@ -1,2 +0,0 @@
|
||||
export * from './operator';
|
||||
export * from './models';
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IUserDetailResponse, IUser, IUserListResponse } from './models';
|
||||
import { httpClient } from './common';
|
||||
import { IUserDetailResponse, IUser, IUserListResponse } from '@/models';
|
||||
|
||||
export interface IInviteesQuery {
|
||||
offset?: number;
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IUser } from '@/operators';
|
||||
import { IToken } from '@/operators/auth/models';
|
||||
import { IUser, IToken } from '@/models';
|
||||
|
||||
interface IData {
|
||||
accessToken: string | undefined;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<layout>
|
||||
<template #chat>
|
||||
<model-selector class="model-selector" />
|
||||
<api-status
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:need-apply="needApply"
|
||||
:api-id="model.apiId"
|
||||
@refresh="$store.dispatch('chat/getApplications')"
|
||||
:service="service"
|
||||
@refresh="$store.dispatch('chat/getApplication')"
|
||||
/>
|
||||
<div class="dialogue">
|
||||
<introduction v-if="messages.length === 0" @draft="onDraft" />
|
||||
@@ -44,21 +44,21 @@ import {
|
||||
IChatModel,
|
||||
IApplication,
|
||||
IChatMessageState,
|
||||
IChatAskResponse,
|
||||
chatOperator,
|
||||
IChatConversationResponse,
|
||||
IChatConversation,
|
||||
IChatMessage
|
||||
} from '@/operators';
|
||||
} from '@/models';
|
||||
import InputBox from '@/components/chat/InputBox.vue';
|
||||
import ModelSelector from '@/components/chat/ModelSelector.vue';
|
||||
import { ERROR_CODE_CANCELED, ERROR_CODE_NOT_APPLIED, ERROR_CODE_UNKNOWN } from '@/constants/errorCode';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { Status } from '@/models';
|
||||
import { log } from '@/utils/log';
|
||||
import Introduction from '@/components/chat/Introduction.vue';
|
||||
import Layout from '@/layouts/Chat.vue';
|
||||
import { isJSONString } from '@/utils/is';
|
||||
import { chatOperator } from '@/operators';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
|
||||
export interface IData {
|
||||
question: string;
|
||||
@@ -74,7 +74,7 @@ export default defineComponent({
|
||||
Introduction,
|
||||
ModelSelector,
|
||||
Message,
|
||||
ApiStatus,
|
||||
ApplicationStatus,
|
||||
Layout
|
||||
},
|
||||
data(): IData {
|
||||
@@ -100,20 +100,20 @@ export default defineComponent({
|
||||
(conversation: IChatConversation) => conversation.id === this.conversationId
|
||||
);
|
||||
},
|
||||
service() {
|
||||
return this.$store.state.chat.service;
|
||||
},
|
||||
application() {
|
||||
return this.applications?.find((application: IApplication) => application.api?.id === this.model.apiId);
|
||||
return this.$store.state.chat.application;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.chat.getApplicationsStatus === Status.Success && !this.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chat.applications;
|
||||
return this.$store.state.chat.status.getApplication === Status.Success && !this.application;
|
||||
},
|
||||
conversations() {
|
||||
return this.$store.state.chat.conversations;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.chat.getApplicationsStatus === Status.Request;
|
||||
return this.$store.state.chat.status.getApplication === Status.Request;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -147,7 +147,7 @@ export default defineComponent({
|
||||
},
|
||||
async onModelChanged() {
|
||||
await this.onCreateNewConversation();
|
||||
await this.$store.dispatch('chat/getApplications');
|
||||
await this.$store.dispatch('chat/getApplication');
|
||||
},
|
||||
async onSubmit() {
|
||||
if (this.references.length > 0) {
|
||||
@@ -185,16 +185,14 @@ export default defineComponent({
|
||||
}, 0);
|
||||
},
|
||||
async onFetchAnswer() {
|
||||
const token = this.application?.credential?.token;
|
||||
const endpoint = this.application?.api?.endpoint;
|
||||
const path = this.application?.api?.path;
|
||||
const token = this.application?.credentials?.[0]?.token;
|
||||
const question = this.question;
|
||||
const references = this.references;
|
||||
log(this.onFetchAnswer, 'validated', question, references);
|
||||
// reset question and references
|
||||
this.question = '';
|
||||
this.references = [];
|
||||
if (!token || !endpoint || !question || !path) {
|
||||
if (!token || !question) {
|
||||
console.error('no token or endpoint or question');
|
||||
this.messages.push({
|
||||
error: {
|
||||
@@ -216,24 +214,23 @@ export default defineComponent({
|
||||
// request server to get answer
|
||||
this.answering = true;
|
||||
chatOperator
|
||||
.askQuestion(
|
||||
.chatConversation(
|
||||
{
|
||||
question,
|
||||
model: this.model.name,
|
||||
references,
|
||||
conversation_id: this.conversationId,
|
||||
id: this.conversationId,
|
||||
stateful: true
|
||||
},
|
||||
{
|
||||
token,
|
||||
endpoint,
|
||||
path,
|
||||
stream: (response: IChatAskResponse) => {
|
||||
stream: (response: IChatConversationResponse) => {
|
||||
this.messages[this.messages.length - 1] = {
|
||||
role: ROLE_ASSISTANT,
|
||||
content: response.answer,
|
||||
state: IChatMessageState.ANSWERING
|
||||
};
|
||||
conversationId = response.conversation_id;
|
||||
conversationId = response?.id;
|
||||
this.onScrollDown();
|
||||
}
|
||||
}
|
||||
@@ -256,7 +253,7 @@ export default defineComponent({
|
||||
}
|
||||
this.onScrollDown();
|
||||
await this.$store.dispatch('chat/getConversations');
|
||||
await this.$store.dispatch('chat/getApplications');
|
||||
await this.$store.dispatch('chat/getApplication');
|
||||
})
|
||||
.catch((error) => {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
@@ -268,7 +265,7 @@ export default defineComponent({
|
||||
code: ERROR_CODE_CANCELED
|
||||
};
|
||||
} else if (error?.response?.data) {
|
||||
let data = error?.response?.data;
|
||||
let data = error?.response?.data?.error;
|
||||
if (isJSONString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
<conversations class="side" />
|
||||
<div class="chat">
|
||||
<div class="status">
|
||||
<api-status
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:need-apply="needApply"
|
||||
:api-id="apiId"
|
||||
@refresh="$store.dispatch('chatdoc/getApplications')"
|
||||
:service="service"
|
||||
@refresh="$store.dispatch('chatdoc/getApplication')"
|
||||
/>
|
||||
</div>
|
||||
<div class="dialogue">
|
||||
@@ -40,14 +40,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import Layout from '@/layouts/Chatdoc.vue';
|
||||
import {
|
||||
IApplication,
|
||||
IChatdocChatResponse,
|
||||
IChatdocConversation,
|
||||
IChatdocMessageState,
|
||||
IChatdocRepository,
|
||||
chatdocOperator
|
||||
} from '@/operators';
|
||||
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';
|
||||
@@ -58,13 +51,13 @@ import {
|
||||
ROLE_ASSISTANT,
|
||||
ROLE_USER
|
||||
} from '@/constants';
|
||||
import { API_ID_CHATDOC_CHAT } from '@/operators/chatdoc/constants';
|
||||
import { log } from '@/utils';
|
||||
import { ROUTE_CHATDOC_CONVERSATION } from '@/router';
|
||||
import axios from 'axios';
|
||||
import { isJSONString } from '@/utils/is';
|
||||
import { Status } from '@/store/common/models';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { Status } from '@/models';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
import { IChatdocChatResponse, IChatdocConversation, IChatdocMessageState, IChatdocRepository } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ChatdocChat',
|
||||
@@ -73,7 +66,7 @@ export default defineComponent({
|
||||
Conversations,
|
||||
Message,
|
||||
InputBox,
|
||||
ApiStatus
|
||||
ApplicationStatus
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -81,7 +74,6 @@ export default defineComponent({
|
||||
repositoryId: this.$route.params.repositoryId.toString(),
|
||||
answering: false,
|
||||
question: ''
|
||||
// references: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -107,19 +99,16 @@ export default defineComponent({
|
||||
return this.$route.params.conversationId?.toString();
|
||||
},
|
||||
application() {
|
||||
return this.applications?.find((application: IApplication) => application.api?.id === API_ID_CHATDOC_CHAT);
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chatdoc.applications;
|
||||
return this.$store.state.chatdoc.application;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.chatdoc.getApplicationsStatus === Status.Success && !this.application;
|
||||
return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.chatdoc.getApplicationsStatus === Status.Request;
|
||||
return this.$store.state.chatdoc.status.getApplication === Status.Request;
|
||||
},
|
||||
apiId() {
|
||||
return API_ID_CHATDOC_CHAT;
|
||||
service() {
|
||||
return this.$store.state.chatdoc.service;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
@@ -153,14 +142,12 @@ export default defineComponent({
|
||||
}, 0);
|
||||
},
|
||||
async onFetchAnswer() {
|
||||
const token = this.application?.credential?.token;
|
||||
const endpoint = this.application?.api?.endpoint;
|
||||
const path = this.application?.api?.path;
|
||||
const token = this.application?.credentials?.[0]?.token;
|
||||
const question = this.question;
|
||||
log(this.onFetchAnswer, 'validated', question);
|
||||
// reset question and references
|
||||
this.question = '';
|
||||
if (!token || !endpoint || !question || !path) {
|
||||
if (!token || !question) {
|
||||
console.error('no token or endpoint or question');
|
||||
this.messages.push({
|
||||
error: {
|
||||
|
||||
+13
-19
@@ -9,12 +9,12 @@
|
||||
{{ $t('chatdoc.message.introductionForRepository') }}
|
||||
</div>
|
||||
<div class="status">
|
||||
<api-status
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:need-apply="needApply"
|
||||
:api-id="apiId"
|
||||
@refresh="$store.dispatch('chatdoc/getApplications')"
|
||||
:service="service"
|
||||
@refresh="$store.dispatch('chatdoc/getApplication')"
|
||||
/>
|
||||
</div>
|
||||
<el-row class="repositories" :gutter="15">
|
||||
@@ -63,13 +63,12 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import Layout from '@/layouts/Chatdoc.vue';
|
||||
import { ElCard, ElRow, ElCol, ElDropdown, ElDropdownItem, ElDropdownMenu, ElMessage } from 'element-plus';
|
||||
import { IApplication, IChatdocRepository } from '@/operators';
|
||||
import { IChatdocRepository } from '@/models';
|
||||
import { ROUTE_CHATDOC_MANAGE } from '@/router';
|
||||
import CreateRepository from '@/components/chatdoc/CreateRepository.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { API_ID_CHATDOC_REPOSITORIES } from '@/operators/chatdoc/constants';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ChatdocKnowledge',
|
||||
@@ -83,31 +82,26 @@ export default defineComponent({
|
||||
ElDropdown,
|
||||
ElDropdownItem,
|
||||
ElDropdownMenu,
|
||||
ApiStatus
|
||||
ApplicationStatus
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
apiId() {
|
||||
return API_ID_CHATDOC_REPOSITORIES;
|
||||
},
|
||||
repositories() {
|
||||
return this.$store.state.chatdoc.repositories;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.chatdoc.getApplicationsStatus === Status.Success && !this.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chatdoc.applications;
|
||||
return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application;
|
||||
},
|
||||
application() {
|
||||
return this.applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_REPOSITORIES
|
||||
);
|
||||
return this.$store.state.chatdoc.application;
|
||||
},
|
||||
service() {
|
||||
return this.$store.state.chatdoc.service;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.chatdoc.getApplicationsStatus === Status.Request;
|
||||
return this.$store.state.chatdoc.status.getApplication === Status.Request;
|
||||
}
|
||||
},
|
||||
async mounted() {},
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
{{ $t('chatdoc.message.introductionForKnowledge') }}
|
||||
</div>
|
||||
<div class="status">
|
||||
<api-status
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:need-apply="needApply"
|
||||
:api-id="apiId"
|
||||
@refresh="$store.dispatch('chatdoc/getApplications')"
|
||||
:service="service"
|
||||
@refresh="$store.dispatch('chatdoc/getApplication')"
|
||||
/>
|
||||
</div>
|
||||
<div class="operations">
|
||||
@@ -64,12 +64,11 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import Layout from '@/layouts/Chatdoc.vue';
|
||||
import { IApplication, IChatdocRepository } from '@/operators';
|
||||
import { IApplication, IChatdocRepository } from '@/models';
|
||||
import { ElButton, ElTag, ElTable, ElTableColumn, ElMessage } from 'element-plus';
|
||||
import UploadDocument from '@/components/chatdoc/UploadDocument.vue';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { API_ID_CHATDOC_DOCUMENTS } from '@/operators/chatdoc/constants';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { Status } from '@/models';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ChatdocKnowledge',
|
||||
@@ -78,7 +77,7 @@ export default defineComponent({
|
||||
ElButton,
|
||||
ElTable,
|
||||
ElTag,
|
||||
ApiStatus,
|
||||
ApplicationStatus,
|
||||
ElTableColumn,
|
||||
UploadDocument
|
||||
},
|
||||
@@ -96,19 +95,16 @@ export default defineComponent({
|
||||
return this.repository?.documents;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.chatdoc.getApplicationsStatus === Status.Success && !this.application;
|
||||
return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chatdoc.applications;
|
||||
service() {
|
||||
return this.$store.state.chatdoc.service;
|
||||
},
|
||||
application() {
|
||||
return this.applications?.find((application: IApplication) => application.api?.id === API_ID_CHATDOC_DOCUMENTS);
|
||||
return this.$store.state.chatdoc.application;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.chatdoc.getApplicationsStatus === Status.Request;
|
||||
},
|
||||
apiId() {
|
||||
return API_ID_CHATDOC_DOCUMENTS;
|
||||
return this.$store.state.chatdoc.status.getApplication === Status.Request;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { applicationOperator, IApplication, IApplicationDetailResponse } from '@/operators';
|
||||
import { applicationOperator } from '@/operators';
|
||||
import CreateOrder from '@/components/order/Create.vue';
|
||||
import { ElRow, ElCol, ElCard, ElSkeleton } from 'element-plus';
|
||||
import { IApplication, IApplicationDetailResponse } from '@/models';
|
||||
|
||||
interface IData {
|
||||
application: IApplication | undefined;
|
||||
|
||||
@@ -69,17 +69,12 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import {
|
||||
applicationOperator,
|
||||
IApplication,
|
||||
IApplicationListResponse,
|
||||
IApplicationType,
|
||||
ICredentialType
|
||||
} from '@/operators';
|
||||
import { applicationOperator } from '@/operators';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { ElTable, ElRow, ElCol, ElTableColumn, ElButton, ElCard } from 'element-plus';
|
||||
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router/constants';
|
||||
import { IApplication, IApplicationListResponse, IApplicationType, ICredentialType } from '@/models';
|
||||
|
||||
interface IData {
|
||||
applications: IApplication[];
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
|
||||
import { orderOperator } from '@/operators/order';
|
||||
import {
|
||||
ElRow,
|
||||
ElCol,
|
||||
@@ -143,7 +143,7 @@ import {
|
||||
} from 'element-plus';
|
||||
import WechatPayOrder from '@/components/order/WechatPay.vue';
|
||||
import StripePayOrder from '@/components/order/StripePay.vue';
|
||||
import { IApplicationType } from '@/operators';
|
||||
import { IApplicationType, IOrder, IOrderDetailResponse, OrderState } from '@/models';
|
||||
|
||||
enum PayWay {
|
||||
WechatPay = 'WechatPay',
|
||||
|
||||
@@ -99,10 +99,11 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IOrder, IOrderListResponse, orderOperator, OrderState } from '@/operators/order';
|
||||
import { orderOperator } from '@/operators/order';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { ElRow, ElCol, ElTable, ElTableColumn, ElButton, ElTag, ElCard } from 'element-plus';
|
||||
import { IOrder, IOrderListResponse, OrderState } from '@/models';
|
||||
|
||||
interface IData {
|
||||
orders: IOrder[];
|
||||
|
||||
@@ -71,7 +71,8 @@ import { defineComponent } from 'vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { ElRow, ElCol, ElTable, ElTableColumn, ElCard } from 'element-plus';
|
||||
import { distributionHistoryOperator, IDistributionHistory, IDistributionStatus } from '@/operators/distribution';
|
||||
import { distributionHistoryOperator } from '@/operators/distribution';
|
||||
import { IDistributionHistory, IDistributionStatus } from '@/models';
|
||||
|
||||
interface IData {
|
||||
distributionHistories: IDistributionHistory[];
|
||||
|
||||
@@ -197,16 +197,12 @@ import {
|
||||
ElTooltip,
|
||||
ElSkeleton
|
||||
} from 'element-plus';
|
||||
import {
|
||||
distributionLevelOperator,
|
||||
distributionStatusOperator,
|
||||
IDistributionLevel,
|
||||
IDistributionStatus
|
||||
} from '@/operators';
|
||||
import { distributionLevelOperator, distributionStatusOperator } from '@/operators';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IUser, userOperator } from '@/operators';
|
||||
import { userOperator } from '@/operators';
|
||||
import QrCode from 'vue-qrcode';
|
||||
import { ROUTE_DISTRIBUTION_HISTORY, ROUTE_DISTRIBUTION_INVITEES } from '@/router';
|
||||
import { IDistributionLevel, IDistributionStatus, IUser } from '@/models';
|
||||
|
||||
interface IData {
|
||||
invitees: IUser[];
|
||||
|
||||
@@ -58,7 +58,8 @@ import { defineComponent } from 'vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { ElRow, ElCol, ElTable, ElTableColumn, ElCard, ElSwitch } from 'element-plus';
|
||||
import { IUser, userOperator } from '@/operators';
|
||||
import { userOperator } from '@/operators';
|
||||
import { IUser } from '@/models';
|
||||
|
||||
interface IData {
|
||||
invitees: IUser[];
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="history">
|
||||
<channel-selector class="mb-4" />
|
||||
<api-status
|
||||
<mode-selector class="mb-4" />
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
:api-id="channel.apiId"
|
||||
:service="service"
|
||||
@refresh="onGetApplications"
|
||||
/>
|
||||
<task-full-list @custom="onCustom" />
|
||||
@@ -19,15 +19,15 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import PresetPanel from '@/components/midjourney/PresetPanel.vue';
|
||||
import { ElMessage, ElButton } from 'element-plus';
|
||||
import ChannelSelector from '@/components/midjourney/ChannelSelector.vue';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { MidjourneyImagineAction, midjourneyOperator, IMidjourneyImagineRequest, IApplication } from '@/operators';
|
||||
import ModeSelector from '@/components/midjourney/ModeSelector.vue';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
import { midjourneyOperator } from '@/operators';
|
||||
import TaskFullList from '@/components/midjourney/tasks/TaskFullList.vue';
|
||||
import { ROUTE_MIDJOURNEY_INDEX } from '@/router';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { Status } from '@/models';
|
||||
import { MidjourneyImagineAction, IMidjourneyImagineRequest, IApplication } from '@/models';
|
||||
|
||||
interface IData {
|
||||
prompt: string;
|
||||
@@ -41,8 +41,8 @@ export default defineComponent({
|
||||
name: 'MidjourneyIndex',
|
||||
components: {
|
||||
TaskFullList,
|
||||
ChannelSelector,
|
||||
ApiStatus,
|
||||
ModeSelector,
|
||||
ApplicationStatus,
|
||||
ElButton,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
@@ -54,23 +54,20 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
channel() {
|
||||
return this.$store.state.midjourney.channel;
|
||||
mode() {
|
||||
return this.$store.state.midjourney.mode;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.midjourney.getApplicationsStatus === Status.Request;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.midjourney.getApplicationsStatus === Status.Success && !this.application;
|
||||
service() {
|
||||
return this.$store.state.midjourney.service;
|
||||
},
|
||||
application() {
|
||||
if (this.applications && this.applications.length > 0) {
|
||||
return this.applications.filter((item: IApplication) => item.api_id === this.channel.apiId)[0];
|
||||
}
|
||||
return undefined;
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Success && !this.application;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
@@ -83,21 +80,17 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
async onGetApplications() {
|
||||
await this.$store.dispatch('midjourney/getApplications');
|
||||
await this.$store.dispatch('midjourney/getApplication');
|
||||
},
|
||||
async onStartTask(request: IMidjourneyImagineRequest) {
|
||||
const token = this.application?.credential?.token;
|
||||
const endpoint = this.application?.api?.endpoint;
|
||||
const path = this.application?.api?.path;
|
||||
if (!token || !endpoint || !path) {
|
||||
console.error('no token or endpoint or question');
|
||||
const token = this.application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
console.error('no token found');
|
||||
return;
|
||||
}
|
||||
midjourneyOperator
|
||||
.imagine(request, {
|
||||
token,
|
||||
endpoint,
|
||||
path
|
||||
token
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success(this.$t('midjourney.message.startTaskSuccess'));
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<preset-panel />
|
||||
</template>
|
||||
<template #operation>
|
||||
<channel-selector class="mb-4" />
|
||||
<api-status
|
||||
<mode-selector class="mb-4" />
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:api-id="channel.apiId"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplications"
|
||||
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<template #results>
|
||||
<task-brief-list :applications="applications" @custom="onCustom" />
|
||||
<task-brief-list @custom="onCustom" />
|
||||
</template>
|
||||
</layout>
|
||||
</template>
|
||||
@@ -38,21 +38,15 @@ import PromptInput from '@/components/midjourney/PromptInput.vue';
|
||||
import ElementsSelector from '@/components/midjourney/ElementsSelector.vue';
|
||||
import IgnoreSelector from '@/components/midjourney/IgnoreSelector.vue';
|
||||
import { ElButton, ElMessage } from 'element-plus';
|
||||
import ChannelSelector from '@/components/midjourney/ChannelSelector.vue';
|
||||
import ModeSelector from '@/components/midjourney/ModeSelector.vue';
|
||||
import ReferenceImage from '@/components/midjourney/ReferenceImage.vue';
|
||||
import {
|
||||
IApplication,
|
||||
MidjourneyImagineAction,
|
||||
applicationOperator,
|
||||
midjourneyOperator,
|
||||
IMidjourneyImagineRequest,
|
||||
IApplicationDetailResponse
|
||||
} from '@/operators';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { applicationOperator, midjourneyOperator } from '@/operators';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
import TaskBriefList from '@/components/midjourney/tasks/TaskBriefList.vue';
|
||||
import FinalPrompt from '@/components/midjourney/FinalPrompt.vue';
|
||||
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { MidjourneyImagineMode, Status } from '@/models';
|
||||
import { IMidjourneyImagineRequest, IApplicationDetailResponse, IApplication, MidjourneyImagineAction } from '@/models';
|
||||
|
||||
interface IData {
|
||||
prompt: string;
|
||||
@@ -66,14 +60,14 @@ const CALLBACK_URL = 'https://webhook.acedata.cloud/midjourney';
|
||||
export default defineComponent({
|
||||
name: 'MidjourneyIndex',
|
||||
components: {
|
||||
ChannelSelector,
|
||||
ModeSelector,
|
||||
ReferenceImage,
|
||||
PresetPanel,
|
||||
PromptInput,
|
||||
ElementsSelector,
|
||||
IgnoreSelector,
|
||||
ElButton,
|
||||
ApiStatus,
|
||||
ApplicationStatus,
|
||||
TaskBriefList,
|
||||
FinalPrompt,
|
||||
Layout
|
||||
@@ -87,26 +81,23 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
channel() {
|
||||
return this.$store.state.midjourney.channel;
|
||||
service() {
|
||||
return this.$store.state.midjourney.service;
|
||||
},
|
||||
mode() {
|
||||
return this.$store.state.midjourney.mode;
|
||||
},
|
||||
preset() {
|
||||
return this.$store.state.midjourney.preset;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.midjourney.getApplicationsStatus === Status.Request;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.midjourney.getApplicationsStatus === Status.Success && !this.application;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Success && !this.application;
|
||||
},
|
||||
application() {
|
||||
if (this.applications && this.applications.length > 0) {
|
||||
return this.applications.filter((item: IApplication) => item.api_id === this.channel.apiId)[0];
|
||||
}
|
||||
return undefined;
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
finalPrompt(): string {
|
||||
let content = '';
|
||||
@@ -173,21 +164,17 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
async onGetApplications() {
|
||||
await this.$store.dispatch('midjourney/getApplications');
|
||||
await this.$store.dispatch('midjourney/getApplication');
|
||||
},
|
||||
async onStartTask(request: IMidjourneyImagineRequest) {
|
||||
const token = this.application?.credential?.token;
|
||||
const endpoint = this.application?.api?.endpoint;
|
||||
const path = this.application?.api?.path;
|
||||
if (!token || !endpoint || !path) {
|
||||
console.error('no token or endpoint or question');
|
||||
const token = this.application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
console.error('no token specified');
|
||||
return;
|
||||
}
|
||||
midjourneyOperator
|
||||
.imagine(request, {
|
||||
token,
|
||||
endpoint,
|
||||
path
|
||||
token
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success(this.$t('midjourney.message.startTaskSuccess'));
|
||||
@@ -206,6 +193,7 @@ export default defineComponent({
|
||||
},
|
||||
async onGenerate() {
|
||||
const request = {
|
||||
mode: this.mode.name as MidjourneyImagineMode,
|
||||
prompt: this.finalPrompt,
|
||||
action: MidjourneyImagineAction.GENERATE,
|
||||
translation: this.preset?.translation,
|
||||
|
||||
+81
-60
@@ -1,21 +1,10 @@
|
||||
import {
|
||||
CHAT_MODEL_CHATGPT,
|
||||
CHAT_MODEL_CHATGPT4,
|
||||
CHAT_MODEL_CHATGPT4_BROWSING,
|
||||
CHAT_MODEL_CHATGPT4_VISION,
|
||||
CHAT_MODEL_CHATGPT_16K,
|
||||
CHAT_MODEL_CHATGPT_BROWSING,
|
||||
IApplication,
|
||||
IChatConversation,
|
||||
IChatModel,
|
||||
apiUsageOperator,
|
||||
applicationOperator,
|
||||
chatOperator
|
||||
} from '@/operators';
|
||||
import { IRootState, Status } from '../common/models';
|
||||
import { applicationOperator, chatOperator, serviceOperator } from '@/operators';
|
||||
import { IRootState } from '../common/models';
|
||||
import { ActionContext } from 'vuex';
|
||||
import { log } from '@/utils/log';
|
||||
import { IChatState } from './models';
|
||||
import { IApplication, IChatConversation, IChatModel, IService, Status } from '@/models';
|
||||
import { CHAT_SERVICE_ID } from '@/constants';
|
||||
|
||||
export const resetAll = ({ commit }: ActionContext<IChatState, IRootState>): void => {
|
||||
commit('resetAll');
|
||||
@@ -25,8 +14,14 @@ export const setModel = async ({ commit }: any, payload: IChatModel): Promise<vo
|
||||
commit('setModel', payload);
|
||||
};
|
||||
|
||||
export const setApplications = async ({ commit }: any, payload: IApplication[]): Promise<void> => {
|
||||
commit('setApplications', payload);
|
||||
export const setApplication = async ({ commit }: any, payload: IApplication): Promise<void> => {
|
||||
log(setApplication, 'set application', payload);
|
||||
commit('setApplication', payload);
|
||||
};
|
||||
|
||||
export const setService = async ({ commit }: any, payload: IService): Promise<void> => {
|
||||
log(setService, 'set service', payload);
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setConversations = async ({ commit }: any, payload: IChatConversation[]): Promise<void> => {
|
||||
@@ -47,64 +42,90 @@ export const setConversation = async ({ commit, state }: any, payload: IChatConv
|
||||
log(setConversation, 'set conversation success', conversations);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
export const getService = async ({ commit, state }: ActionContext<IChatState, IRootState>): Promise<IService> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
log(getService, 'start to get service for chat');
|
||||
state.status.getService = Status.Request;
|
||||
serviceOperator
|
||||
.get(CHAT_SERVICE_ID)
|
||||
.then((response) => {
|
||||
state.status.getService = Status.Success;
|
||||
commit('setService', response.data);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
state.status.getService = Status.Error;
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const getApplication = async ({
|
||||
commit,
|
||||
state,
|
||||
rootState
|
||||
}: ActionContext<IChatState, IRootState>): Promise<IApplication[]> => {
|
||||
log(getApplications, 'start to get application for chat');
|
||||
commit('setGetApplicationsStatus', Status.Request);
|
||||
const { data: applications } = await applicationOperator.getAll({
|
||||
user_id: rootState.user.id,
|
||||
api_id: [
|
||||
CHAT_MODEL_CHATGPT.apiId,
|
||||
CHAT_MODEL_CHATGPT_16K.apiId,
|
||||
CHAT_MODEL_CHATGPT_BROWSING.apiId,
|
||||
CHAT_MODEL_CHATGPT4.apiId,
|
||||
CHAT_MODEL_CHATGPT4_BROWSING.apiId,
|
||||
CHAT_MODEL_CHATGPT4_VISION.apiId
|
||||
]
|
||||
}: ActionContext<IChatState, IRootState>): Promise<IApplication> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
log(getApplication, 'start to get application for chat');
|
||||
state.status.getApplication = Status.Request;
|
||||
applicationOperator
|
||||
.getAll({
|
||||
user_id: rootState.user.id,
|
||||
service_id: CHAT_SERVICE_ID
|
||||
})
|
||||
.then((response) => {
|
||||
state.status.getApplication = Status.Success;
|
||||
commit('setApplication', response.data.items[0]);
|
||||
resolve(response.data.items[0]);
|
||||
})
|
||||
.catch((error) => {
|
||||
state.status.getApplication = Status.Error;
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
log(getApplications, 'get application for chat success', applications);
|
||||
commit('setGetApplicationsStatus', Status.Success);
|
||||
commit('setApplications', applications?.items);
|
||||
return applications.items;
|
||||
};
|
||||
|
||||
export const getConversations = async ({
|
||||
commit,
|
||||
state,
|
||||
rootState
|
||||
state
|
||||
}: ActionContext<IChatState, IRootState>): Promise<IChatConversation[]> => {
|
||||
log(getConversations, 'start to get conversations');
|
||||
commit('setGetConversationsStatus', Status.Success);
|
||||
const {
|
||||
data: { items: apiUsages }
|
||||
} = await apiUsageOperator.getAll({
|
||||
user_id: rootState.user.id,
|
||||
// @ts-ignore
|
||||
application_id: state.applications?.map((application) => application.id),
|
||||
offset: 0,
|
||||
limit: 50,
|
||||
ordering: '-created_at'
|
||||
return new Promise(async (resolve, reject) => {
|
||||
state.status.getConversations = Status.Request;
|
||||
const application = state.application;
|
||||
log(getConversations, 'application', application);
|
||||
const token = application?.credentials?.[0].token;
|
||||
if (!token) {
|
||||
state.status.getConversations = Status.Error;
|
||||
return reject(new Error('Token not found'));
|
||||
}
|
||||
chatOperator
|
||||
.getConversations(
|
||||
{
|
||||
applicationId: state.application?.id
|
||||
},
|
||||
{
|
||||
token
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
log(getConversations, 'get conversations success', response.data?.items);
|
||||
commit('setConversations', response.data.items);
|
||||
resolve(response.data.items);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
log(getConversations, 'get api usages success', apiUsages);
|
||||
commit('setGetConversationsStatus', Status.Success);
|
||||
// de duplicate conversations using id
|
||||
const conversationIds: string[] = apiUsages.map((apiUsage) => apiUsage.metadata?.conversation_id).filter((id) => id);
|
||||
const uniqueConversationIds = [...new Set(conversationIds)];
|
||||
log(getConversations, 'get unique conversation ids', uniqueConversationIds);
|
||||
const conversations = (await chatOperator.getConversations(uniqueConversationIds)).data;
|
||||
log(getConversations, 'get conversations success', conversations);
|
||||
commit('setConversations', conversations);
|
||||
return conversations;
|
||||
};
|
||||
|
||||
export default {
|
||||
resetAll,
|
||||
setModel,
|
||||
setApplications,
|
||||
getService,
|
||||
setService,
|
||||
setApplication,
|
||||
getApplication,
|
||||
setConversation,
|
||||
setConversations,
|
||||
getApplications,
|
||||
getConversations
|
||||
};
|
||||
@@ -1,10 +1,13 @@
|
||||
import { IApplication, IChatConversation, IChatModel } from '@/operators';
|
||||
import { Status } from '../common/models';
|
||||
import { IApplication, IChatConversation, IChatModel, IService, Status } from '@/models';
|
||||
|
||||
export interface IChatState {
|
||||
model: IChatModel;
|
||||
applications: IApplication[] | undefined;
|
||||
getApplicationsStatus: Status | undefined;
|
||||
application: IApplication | undefined;
|
||||
service: IService | undefined;
|
||||
conversations: IChatConversation[] | undefined;
|
||||
getConversationsStatus: Status | undefined;
|
||||
status: {
|
||||
getService: Status;
|
||||
getApplication: Status;
|
||||
getConversations: Status;
|
||||
};
|
||||
}
|
||||
@@ -1,39 +1,31 @@
|
||||
import { IApplication, IChatConversation, IChatModel } from '@/operators';
|
||||
import { IApplication, IChatConversation, IChatModel, IService } from '@/models';
|
||||
import { IChatState } from './models';
|
||||
import { Status } from '../common/models';
|
||||
|
||||
export const resetAll = (state: IChatState): void => {
|
||||
state.applications = [];
|
||||
state.getApplicationsStatus = Status.None;
|
||||
state.conversations = [];
|
||||
state.getConversationsStatus = Status.None;
|
||||
state.application = undefined;
|
||||
state.conversations = undefined;
|
||||
};
|
||||
|
||||
export const setModel = (state: IChatState, payload: IChatModel): void => {
|
||||
state.model = payload;
|
||||
};
|
||||
|
||||
export const setApplications = (state: IChatState, payload: IApplication[]): void => {
|
||||
state.applications = payload;
|
||||
export const setApplication = (state: IChatState, payload: IApplication): void => {
|
||||
state.application = payload;
|
||||
};
|
||||
|
||||
export const setGetApplicationsStatus = (state: IChatState, payload: Status): void => {
|
||||
state.getApplicationsStatus = payload;
|
||||
export const setService = (state: IChatState, payload: IService): void => {
|
||||
state.service = payload;
|
||||
};
|
||||
|
||||
export const setConversations = (state: IChatState, payload: IChatConversation[]): void => {
|
||||
state.conversations = payload;
|
||||
};
|
||||
|
||||
export const setGetConversationsStatus = (state: IChatState, payload: Status): void => {
|
||||
state.getConversationsStatus = payload;
|
||||
};
|
||||
|
||||
export default {
|
||||
setModel,
|
||||
setApplications,
|
||||
setGetApplicationsStatus,
|
||||
setService,
|
||||
setConversations,
|
||||
setGetConversationsStatus,
|
||||
setApplication,
|
||||
resetAll
|
||||
};
|
||||
@@ -1 +1 @@
|
||||
export default ['chat.applications', 'chat.conversations', 'chat.model'];
|
||||
export default ['chat.application', 'chat.service', 'chat.conversations', 'chat.model'];
|
||||
@@ -1,12 +1,15 @@
|
||||
import { CHAT_MODEL_CHATGPT } from '@/operators';
|
||||
import { CHAT_MODEL_GPT_3_5 } from '@/constants';
|
||||
import { IChatState } from './models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default (): IChatState => {
|
||||
return {
|
||||
model: CHAT_MODEL_CHATGPT,
|
||||
applications: undefined,
|
||||
getApplicationsStatus: undefined,
|
||||
model: CHAT_MODEL_GPT_3_5,
|
||||
application: undefined,
|
||||
conversations: undefined,
|
||||
getConversationsStatus: undefined
|
||||
status: {
|
||||
getApplication: Status.None,
|
||||
getConversations: Status.None
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,38 +1,44 @@
|
||||
import { IApplication, apiUsageOperator, applicationOperator } from '@/operators';
|
||||
import { IRootState, Status } from '../common/models';
|
||||
import { IRootState } from '../common/models';
|
||||
import { ActionContext } from 'vuex';
|
||||
import { log } from '@/utils/log';
|
||||
import { IChatdocState } from './models';
|
||||
import { IChatdocConversation, IChatdocDocument, IChatdocRepository } from '@/operators/chatdoc/models';
|
||||
import { chatdocOperator } from '@/operators/chatdoc/operator';
|
||||
import {
|
||||
API_ID_CHATDOC_CHAT,
|
||||
API_ID_CHATDOC_DOCUMENTS,
|
||||
API_ID_CHATDOC_REPOSITORIES
|
||||
} from '@/operators/chatdoc/constants';
|
||||
IApplication,
|
||||
IChatdocConversation,
|
||||
IChatdocDocument,
|
||||
IChatdocRepositoriesResponse,
|
||||
IChatdocRepository,
|
||||
IService,
|
||||
Status
|
||||
} from '@/models';
|
||||
import { chatdocOperator, applicationOperator, serviceOperator } from '@/operators';
|
||||
import { CHATDOC_SERVICE_ID } from '@/constants';
|
||||
|
||||
export const setApplications = async ({ commit }: any, payload: IApplication[]): Promise<void> => {
|
||||
commit('setApplications', payload);
|
||||
export const setApplication = async ({ commit }: any, payload: IApplication): Promise<void> => {
|
||||
commit('setApplication', payload);
|
||||
};
|
||||
|
||||
export const setService = async ({ commit }: any, payload: IService): Promise<void> => {
|
||||
log(setService, 'set service', payload);
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setRepository = async ({ commit }: any, payload: { repository: IChatdocRepository }): Promise<void> => {
|
||||
commit('setRepository', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
export const getApplication = async ({
|
||||
commit,
|
||||
rootState
|
||||
}: ActionContext<IChatdocState, IRootState>): Promise<IApplication[]> => {
|
||||
log(getApplications, 'start to get application for chat');
|
||||
commit('setGetApplicationsStatus', Status.Request);
|
||||
}: ActionContext<IChatdocState, IRootState>): Promise<IApplication> => {
|
||||
log(getApplication, 'start to get application for chat');
|
||||
const { data: applications } = await applicationOperator.getAll({
|
||||
user_id: rootState.user.id,
|
||||
api_id: [API_ID_CHATDOC_REPOSITORIES, API_ID_CHATDOC_CHAT, API_ID_CHATDOC_DOCUMENTS]
|
||||
service_id: CHATDOC_SERVICE_ID
|
||||
});
|
||||
log(getApplications, 'get application for chat success', applications);
|
||||
commit('setGetApplicationsStatus', Status.Success);
|
||||
commit('setApplications', applications?.items);
|
||||
return applications.items;
|
||||
log(getApplication, 'get application for chat success', applications);
|
||||
commit('setApplication', applications?.items?.[0]);
|
||||
return applications.items?.[0];
|
||||
};
|
||||
|
||||
export const resetAll = ({ commit }: ActionContext<IChatdocState, IRootState>): void => {
|
||||
@@ -44,24 +50,18 @@ export const getRepositories = async ({
|
||||
state
|
||||
}: ActionContext<IChatdocState, IRootState>): Promise<IChatdocRepository[]> => {
|
||||
log(getRepositories, 'start to get repositories');
|
||||
commit('setGetRepositoriesStatus', Status.Request);
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_REPOSITORIES
|
||||
);
|
||||
const application = state.application;
|
||||
console.log('application', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
commit('setRepositories', undefined);
|
||||
return [];
|
||||
return Promise.reject('no token');
|
||||
}
|
||||
const repositories = (
|
||||
await chatdocOperator.getAllRepositories({
|
||||
token
|
||||
})
|
||||
).data;
|
||||
commit('setGetRepositoriesStatus', Status.Success);
|
||||
).data.items;
|
||||
log(getRepositories, 'get repositories success', repositories);
|
||||
commit('setRepositories', repositories);
|
||||
return repositories;
|
||||
@@ -74,13 +74,9 @@ export const deleteRepository = async (
|
||||
}
|
||||
): Promise<IChatdocRepository> => {
|
||||
log(deleteRepository, 'start to delete repository');
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_REPOSITORIES
|
||||
);
|
||||
const application = state.application;
|
||||
console.log('application', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
return Promise.reject('no token');
|
||||
}
|
||||
@@ -100,13 +96,9 @@ export const deleteDocument = async (
|
||||
}
|
||||
): Promise<IChatdocDocument> => {
|
||||
log(deleteDocument, 'start to delete document');
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_DOCUMENTS
|
||||
);
|
||||
const application = state.application;
|
||||
console.log('application', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
return Promise.reject('no token');
|
||||
}
|
||||
@@ -119,6 +111,24 @@ export const deleteDocument = async (
|
||||
return document;
|
||||
};
|
||||
|
||||
export const getService = async ({ commit, state }: ActionContext<IChatdocState, IRootState>): Promise<IService> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
log(getService, 'start to get service for chatdoc');
|
||||
state.status.getService = Status.Request;
|
||||
serviceOperator
|
||||
.get(CHATDOC_SERVICE_ID)
|
||||
.then((response) => {
|
||||
state.status.getService = Status.Success;
|
||||
commit('setService', response.data);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
state.status.getService = Status.Error;
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const createRepository = async (
|
||||
{ state }: ActionContext<IChatdocState, IRootState>,
|
||||
payload: {
|
||||
@@ -127,13 +137,9 @@ export const createRepository = async (
|
||||
}
|
||||
): Promise<IChatdocRepository> => {
|
||||
log(createRepository, 'start to create repository');
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_REPOSITORIES
|
||||
);
|
||||
const application = state.application;
|
||||
console.log('application', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
return Promise.reject('no token');
|
||||
}
|
||||
@@ -155,13 +161,9 @@ export const createDocument = async (
|
||||
}
|
||||
): Promise<IChatdocDocument> => {
|
||||
log(createDocument, 'start to create document');
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_DOCUMENTS
|
||||
);
|
||||
const application = state.application;
|
||||
console.log('application', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
return Promise.reject('no token');
|
||||
}
|
||||
@@ -179,13 +181,9 @@ export const getDocuments = async (
|
||||
payload: { repositoryId: string }
|
||||
): Promise<IChatdocDocument[]> => {
|
||||
log(getRepositories, 'start to get documents');
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_DOCUMENTS
|
||||
);
|
||||
const application = state.application;
|
||||
console.log('application for getDocuments', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
commit('setRepository', {
|
||||
id: payload.repositoryId,
|
||||
@@ -211,11 +209,9 @@ export const getConversations = async (
|
||||
payload: { repositoryId: string }
|
||||
): Promise<IChatdocConversation[]> => {
|
||||
log(getConversations, 'start to get conversations');
|
||||
const applications = state.applications;
|
||||
console.log('applications', applications);
|
||||
const application = applications?.find((application: IApplication) => application.api?.id === API_ID_CHATDOC_CHAT);
|
||||
const application = state.application;
|
||||
console.log('application for getConversations', application);
|
||||
const token = application?.credential?.token;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
commit('setRepository', {
|
||||
id: payload.repositoryId,
|
||||
@@ -237,12 +233,8 @@ export const getRepository = async (
|
||||
payload: { id: string }
|
||||
): Promise<IChatdocRepository> => {
|
||||
log(getRepository, 'start to get repository');
|
||||
// commit('setGetRepositoryStatus', Status.Request);
|
||||
const applications = state.applications;
|
||||
const application = applications?.find(
|
||||
(application: IApplication) => application.api?.id === API_ID_CHATDOC_REPOSITORIES
|
||||
);
|
||||
const token = application?.credential?.token;
|
||||
const application = state.application;
|
||||
const token = application?.credentials?.[0]?.token;
|
||||
if (!token) {
|
||||
commit('setRepository', { id: payload.id });
|
||||
return Promise.reject('no token');
|
||||
@@ -252,16 +244,17 @@ export const getRepository = async (
|
||||
token
|
||||
})
|
||||
).data;
|
||||
// commit('setGetRepositoryStatus', Status.Success);
|
||||
log(getRepository, 'get repository success', repository);
|
||||
commit('setRepository', repository);
|
||||
return repository;
|
||||
};
|
||||
|
||||
export default {
|
||||
setService,
|
||||
getService,
|
||||
createRepository,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setApplication,
|
||||
getApplication,
|
||||
getRepositories,
|
||||
deleteRepository,
|
||||
getRepository,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { IApplication } from '@/operators';
|
||||
import { Status } from '../common/models';
|
||||
import { IChatdocRepository } from '@/operators/chatdoc/models';
|
||||
import { IApplication, IChatdocRepository, IService, Status } from '@/models';
|
||||
|
||||
export interface IChatdocState {
|
||||
applications: IApplication[] | undefined;
|
||||
getApplicationsStatus: Status | undefined;
|
||||
service: IService | undefined;
|
||||
application: IApplication | undefined;
|
||||
repositories: IChatdocRepository[] | undefined;
|
||||
getRepositoriesStatus: Status | undefined;
|
||||
status: {
|
||||
getService: Status;
|
||||
getApplication: Status;
|
||||
getRepositories: Status;
|
||||
};
|
||||
}
|
||||
@@ -1,21 +1,18 @@
|
||||
import { IApplication, IChatConversation, IChatModel } from '@/operators';
|
||||
import { IApplication, IChatdocRepository, IService } from '@/models';
|
||||
import { IChatdocState } from './models';
|
||||
import { Status } from '../common/models';
|
||||
import { IChatdocRepository } from '@/operators/chatdoc/models';
|
||||
import { log } from '@/utils';
|
||||
|
||||
export const resetAll = (state: IChatdocState): void => {
|
||||
state.applications = [];
|
||||
state.getApplicationsStatus = Status.None;
|
||||
state.application = undefined;
|
||||
state.repositories = [];
|
||||
};
|
||||
|
||||
export const setApplications = (state: IChatdocState, payload: IApplication[]): void => {
|
||||
state.applications = payload;
|
||||
export const setService = (state: IChatdocState, payload: IService): void => {
|
||||
state.service = payload;
|
||||
};
|
||||
|
||||
export const setGetApplicationsStatus = (state: IChatdocState, payload: Status): void => {
|
||||
state.getApplicationsStatus = payload;
|
||||
export const setApplication = (state: IChatdocState, payload: IApplication): void => {
|
||||
state.application = payload;
|
||||
};
|
||||
|
||||
export const setRepositories = (state: IChatdocState, payload: IChatdocRepository[]): void => {
|
||||
@@ -60,15 +57,10 @@ export const setRepository = (state: IChatdocState, payload: IChatdocRepository)
|
||||
};
|
||||
};
|
||||
|
||||
export const setGetRepositoriesStatus = (state: IChatdocState, payload: Status): void => {
|
||||
state.getRepositoriesStatus = payload;
|
||||
};
|
||||
|
||||
export default {
|
||||
setApplications,
|
||||
setGetApplicationsStatus,
|
||||
setService,
|
||||
setApplication,
|
||||
setRepositories,
|
||||
setRepository,
|
||||
setGetRepositoriesStatus,
|
||||
resetAll
|
||||
};
|
||||
@@ -1 +1 @@
|
||||
export default ['chatdoc.repositories', 'chatdoc.applications'];
|
||||
export default ['chatdoc.repositories', 'chatdoc.service', 'chatdoc.application'];
|
||||
@@ -1,10 +1,15 @@
|
||||
import { Status } from '@/models';
|
||||
import { IChatdocState } from './models';
|
||||
|
||||
export default (): IChatdocState => {
|
||||
return {
|
||||
applications: undefined,
|
||||
getApplicationsStatus: undefined,
|
||||
service: undefined,
|
||||
application: undefined,
|
||||
repositories: undefined,
|
||||
getRepositoriesStatus: undefined
|
||||
status: {
|
||||
getService: Status.None,
|
||||
getApplication: Status.None,
|
||||
getRepositories: Status.None
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,8 +1,7 @@
|
||||
import { ActionContext } from 'vuex';
|
||||
import { IRootState, IToken } from '../common/models';
|
||||
import { IUser, userOperator } from '@/operators';
|
||||
import { IRootState } from '../common/models';
|
||||
import { userOperator, oauthOperator } from '@/operators';
|
||||
import { log } from '@/utils/log';
|
||||
import { oauthOperator } from '@/operators/auth/operator';
|
||||
|
||||
export const resetAll = ({ commit }: ActionContext<IRootState, IRootState>) => {
|
||||
commit('resetToken');
|
||||
|
||||
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user