From 9151fc7937392786b16d1dc3a46395aa9adf27d8 Mon Sep 17 00:00:00 2001 From: Germey Date: Mon, 4 Mar 2024 02:15:36 +0800 Subject: [PATCH] migrate --- src/models/chat.ts | 5 +++++ src/models/midjourney.ts | 7 +++++++ src/operators/chat.ts | 5 +++-- src/operators/midjourney.ts | 12 +++++++++--- src/pages/chatdoc/Manage.vue | 12 +++--------- src/store/chat/actions.ts | 6 +++--- src/store/midjourney/actions.ts | 4 ++-- src/store/midjourney/models.ts | 1 + 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/models/chat.ts b/src/models/chat.ts index f7668eef..d624bf8b 100644 --- a/src/models/chat.ts +++ b/src/models/chat.ts @@ -75,6 +75,11 @@ export interface IChatConversationResponse { id?: string; } +export interface IChatConversationsResponse { + items: IChatConversation[]; + count: number; +} + export enum IChatConversationAction { CHAT = 'chat', RETRIEVE = 'retrieve', diff --git a/src/models/midjourney.ts b/src/models/midjourney.ts index 3b3544f8..e8ecc640 100644 --- a/src/models/midjourney.ts +++ b/src/models/midjourney.ts @@ -90,6 +90,13 @@ export interface IMidjourneyImagineTask { state?: MidjourneyImagineState; } +export type IMidjourneyImagineTaskResponse = IMidjourneyImagineTask; + +export interface IMidjourneyImagineTasksResponse { + items: IMidjourneyImagineTask[]; + count: number; +} + export interface IMidjourneyImagineOptions { stream?: (response: IMidjourneyImagineResponse) => void; token?: string; diff --git a/src/operators/chat.ts b/src/operators/chat.ts index 9f69a581..aea292b7 100644 --- a/src/operators/chat.ts +++ b/src/operators/chat.ts @@ -4,7 +4,8 @@ import { IChatConversationAction, IChatConversationOptions, IChatConversationRequest, - IChatConversationResponse + IChatConversationResponse, + IChatConversationsResponse } from '@/models'; import { BASE_URL_API } from '@/constants'; @@ -61,7 +62,7 @@ class ChatOperator { applicationId?: string; }, options: IChatConversationOptions - ): Promise> { + ): Promise> { return await axios.post( `/aichat/conversations`, { diff --git a/src/operators/midjourney.ts b/src/operators/midjourney.ts index 68d47fcc..2dd14582 100644 --- a/src/operators/midjourney.ts +++ b/src/operators/midjourney.ts @@ -1,9 +1,15 @@ import axios, { AxiosResponse } from 'axios'; -import { IMidjourneyImagineRequest, IMidjourneyImagineResponse, IMidjourneyImagineTask } from '@/models'; +import { + IMidjourneyImagineRequest, + IMidjourneyImagineResponse, + IMidjourneyImagineTask, + IMidjourneyImagineTaskResponse, + IMidjourneyImagineTasksResponse +} from '@/models'; import { BASE_URL_API } from '@/constants'; class MidjourneyOperator { - async task(id: string, options: { token: string }): Promise> { + async task(id: string, options: { token: string }): Promise> { return await axios.post( `/midjourney/tasks`, { @@ -24,7 +30,7 @@ class MidjourneyOperator { async tasks( filter: { ids?: string[]; applicationId?: string; limit?: number; offset?: number }, options: { token: string } - ): Promise> { + ): Promise> { return await axios.post( `/midjourney/tasks`, { diff --git a/src/pages/chatdoc/Manage.vue b/src/pages/chatdoc/Manage.vue index 53cedd2e..61d54bc0 100644 --- a/src/pages/chatdoc/Manage.vue +++ b/src/pages/chatdoc/Manage.vue @@ -95,22 +95,16 @@ export default defineComponent({ return this.repository?.documents; }, needApply() { - return this.$store.state.chatdoc.getApplicationStatus === Status.Success && !this.application; + return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application; }, service() { return this.$store.state.chatdoc.service; }, - applications() { - return this.$store.state.chatdoc.applications; - }, 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.getApplicationStatus === Status.Request; - }, - apiId() { - return API_ID_CHATDOC_DOCUMENTS; + return this.$store.state.chatdoc.status.getApplication === Status.Request; } }, async mounted() { diff --git a/src/store/chat/actions.ts b/src/store/chat/actions.ts index bd2ed0ad..8cd96e2a 100644 --- a/src/store/chat/actions.ts +++ b/src/store/chat/actions.ts @@ -108,9 +108,9 @@ export const getConversations = async ({ } ) .then((response) => { - log(getConversations, 'get conversations success', response.data); - commit('setConversations', response.data); - resolve(response.data); + log(getConversations, 'get conversations success', response.data?.items); + commit('setConversations', response.data.items); + resolve(response.data.items); }) .catch((error) => { reject(error); diff --git a/src/store/midjourney/actions.ts b/src/store/midjourney/actions.ts index 2e389378..ace42403 100644 --- a/src/store/midjourney/actions.ts +++ b/src/store/midjourney/actions.ts @@ -96,8 +96,8 @@ export const getImagineTasks = async ( } ) .then((response) => { - commit('setImagineTasks', response.data); - resolve(response.data); + commit('setImagineTasks', response.data.items); + resolve(response.data.items); }) .catch((error) => { return reject(error); diff --git a/src/store/midjourney/models.ts b/src/store/midjourney/models.ts index d36f3b14..d3fdfcbe 100644 --- a/src/store/midjourney/models.ts +++ b/src/store/midjourney/models.ts @@ -10,5 +10,6 @@ export interface IMidjourneyState { status: { getService: Status; getApplication: Status; + getImagineTasks: Status; }; }