update history
This commit is contained in:
1 parent
ac78a5ea6f
commit
96708de3a4
12 files changed
+407
-95
No files matched your search
@@ -15,7 +15,24 @@ export interface IMidjourneyPreset {
|
||||
|
||||
export enum MidjourneyImagineAction {
|
||||
GENERATE = 'generate',
|
||||
UPSAMPLE1 = 'upsample1'
|
||||
UPSAMPLE1 = 'upsample1',
|
||||
UPSAMPLE2 = 'upsample2',
|
||||
UPSAMPLE3 = 'upsample3',
|
||||
UPSAMPLE4 = 'upsample4',
|
||||
VARIATION1 = 'variation1',
|
||||
VARIATION2 = 'variation2',
|
||||
VARIATION3 = 'variation3',
|
||||
VARIATION4 = 'variation4',
|
||||
HIGH_VARIATION = 'high_variation',
|
||||
LOW_VARIATION = 'low_variation',
|
||||
ZOOM_OUT_2X = 'zoom_out_2x',
|
||||
ZOOM_OUT_1_5X = 'zoom_out_1_5x',
|
||||
SQUARE = 'square',
|
||||
PAN_LEFT = 'pan_left',
|
||||
PAN_UP = 'pan_up',
|
||||
PAN_DOWN = 'pan_down',
|
||||
PAN_RIGHT = 'pan_right',
|
||||
REROLL = 'reroll'
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineState {
|
||||
@@ -26,8 +43,8 @@ export enum MidjourneyImagineState {
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineRequest {
|
||||
action: MidjourneyImagineAction;
|
||||
prompt: string;
|
||||
action?: MidjourneyImagineAction;
|
||||
prompt?: string;
|
||||
image_id?: string;
|
||||
}
|
||||
|
||||
@@ -37,11 +54,20 @@ export interface IMidjourneyImagineResponse {
|
||||
image_id: string;
|
||||
image_url: string;
|
||||
actions: MidjourneyImagineAction[];
|
||||
code?: string;
|
||||
detail?: string;
|
||||
success?: boolean;
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineTask {
|
||||
request?: IMidjourneyImagineRequest;
|
||||
response?: IMidjourneyImagineResponse;
|
||||
state?: MidjourneyImagineState;
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineOptions {
|
||||
stream?: (response: IMidjourneyImagineResponse) => void;
|
||||
token: string;
|
||||
endpoint: string;
|
||||
path: string;
|
||||
token?: string;
|
||||
endpoint?: string;
|
||||
path?: string;
|
||||
}
|
||||
@@ -1,10 +1,33 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import { IMidjourneyImagineOptions, IMidjourneyImagineRequest, IMidjourneyImagineResponse } from './models';
|
||||
import { IMidjourneyImagineRequest, IMidjourneyImagineResponse, IMidjourneyImagineTask } from './models';
|
||||
import { ENDPOINT_API } from '../common/contants';
|
||||
|
||||
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: ENDPOINT_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async imagine(
|
||||
data: IMidjourneyImagineRequest,
|
||||
options: IMidjourneyImagineOptions
|
||||
options: {
|
||||
stream: (response: IMidjourneyImagineResponse) => void;
|
||||
token: string;
|
||||
endpoint: string;
|
||||
path: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IMidjourneyImagineResponse>> {
|
||||
return await axios.post(options.path, data, {
|
||||
headers: {
|
||||
|
||||
Reference in new issue
Block a user