Skip to content

Commit

Permalink
migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Mar 3, 2024
1 parent 2e5f9be commit 9151fc7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/models/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export interface IChatConversationResponse {
id?: string;
}

export interface IChatConversationsResponse {
items: IChatConversation[];
count: number;
}

export enum IChatConversationAction {
CHAT = 'chat',
RETRIEVE = 'retrieve',
Expand Down
7 changes: 7 additions & 0 deletions src/models/midjourney.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/operators/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
IChatConversationAction,
IChatConversationOptions,
IChatConversationRequest,
IChatConversationResponse
IChatConversationResponse,
IChatConversationsResponse
} from '@/models';
import { BASE_URL_API } from '@/constants';

Expand Down Expand Up @@ -61,7 +62,7 @@ class ChatOperator {
applicationId?: string;
},
options: IChatConversationOptions
): Promise<AxiosResponse<IChatConversation[]>> {
): Promise<AxiosResponse<IChatConversationsResponse>> {
return await axios.post(
`/aichat/conversations`,
{
Expand Down
12 changes: 9 additions & 3 deletions src/operators/midjourney.ts
Original file line number Diff line number Diff line change
@@ -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<AxiosResponse<IMidjourneyImagineTask>> {
async task(id: string, options: { token: string }): Promise<AxiosResponse<IMidjourneyImagineTaskResponse>> {
return await axios.post(
`/midjourney/tasks`,
{
Expand All @@ -24,7 +30,7 @@ class MidjourneyOperator {
async tasks(
filter: { ids?: string[]; applicationId?: string; limit?: number; offset?: number },
options: { token: string }
): Promise<AxiosResponse<IMidjourneyImagineTask[]>> {
): Promise<AxiosResponse<IMidjourneyImagineTasksResponse>> {
return await axios.post(
`/midjourney/tasks`,
{
Expand Down
12 changes: 3 additions & 9 deletions src/pages/chatdoc/Manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/store/chat/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/store/midjourney/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/store/midjourney/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface IMidjourneyState {
status: {
getService: Status;
getApplication: Status;
getImagineTasks: Status;
};
}

0 comments on commit 9151fc7

Please sign in to comment.