Skip to content

Commit

Permalink
update chatdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Mar 5, 2024
1 parent 9151fc7 commit 249711f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
32 changes: 28 additions & 4 deletions src/components/midjourney/tasks/TaskPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<div class="right">
<el-tag v-if="mode" type="info" class="channel">
<font-awesome-icon :class="{ icon: true, [mode.name]: true }" :icon="mode?.icon" />
<font-awesome-icon :class="{ icon: true, [mode.name]: true }" :icon="mode.icon" />
{{ mode?.displayName }}
</el-tag>
</div>
Expand Down Expand Up @@ -56,7 +56,6 @@
</p>
</el-alert>
</div>

<div v-else :class="{ content: true, full: full }">
<el-image
v-if="modelValue?.response?.image_url"
Expand Down Expand Up @@ -103,9 +102,15 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElImage, ElTag, ElButton, ElTooltip, ElSkeleton, ElAlert } from 'element-plus';
import { IMidjourneyImagineTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/models';
import {
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;
Expand Down Expand Up @@ -200,7 +205,16 @@ export default defineComponent({
return this.$store.state.midjourney.application;
},
mode() {
return this.$store.state.midjourney.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;
}
}
},
methods: {
Expand All @@ -216,6 +230,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;
}
}
}
});
Expand Down
6 changes: 5 additions & 1 deletion src/layouts/Chatdoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -92,10 +92,14 @@ 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/getApplication');
},
Expand Down
5 changes: 4 additions & 1 deletion src/models/chatdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/models/midjourney.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface IMidjourneyImagineResponse {
export interface IMidjourneyImagineTask {
id: string;
created_at?: string;
mode: MidjourneyImagineMode;
request?: IMidjourneyImagineRequest;
response?: IMidjourneyImagineResponse;
state?: MidjourneyImagineState;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/midjourney/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
</template>
<template #results>
<task-brief-list :applications="applications" @custom="onCustom" />
<task-brief-list @custom="onCustom" />
</template>
</layout>
</template>
Expand Down Expand Up @@ -169,7 +169,7 @@ export default defineComponent({
async onStartTask(request: IMidjourneyImagineRequest) {
const token = this.application?.credentials?.[0]?.token;
if (!token) {
console.error('no token or endpoint or question');
console.error('no token specified');
return;
}
midjourneyOperator
Expand Down
14 changes: 11 additions & 3 deletions src/store/chatdoc/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import { IRootState } from '../common/models';
import { ActionContext } from 'vuex';
import { log } from '@/utils/log';
import { IChatdocState } from './models';
import { IApplication, IChatdocConversation, IChatdocDocument, IChatdocRepository, IService, Status } from '@/models';
import {
IApplication,
IChatdocConversation,
IChatdocDocument,
IChatdocRepositoriesResponse,
IChatdocRepository,
IService,
Status
} from '@/models';
import { chatdocOperator, applicationOperator, serviceOperator } from '@/operators';
import { CHATDOC_SERVICE_ID } from '@/constants';

Expand Down Expand Up @@ -47,13 +55,13 @@ export const getRepositories = async ({
const token = application?.credentials?.[0]?.token;
if (!token) {
commit('setRepositories', undefined);
return [];
return Promise.reject('no token');
}
const repositories = (
await chatdocOperator.getAllRepositories({
token
})
).data;
).data.items;
log(getRepositories, 'get repositories success', repositories);
commit('setRepositories', repositories);
return repositories;
Expand Down

0 comments on commit 249711f

Please sign in to comment.