update history

This commit is contained in:
AceDataCloud committed 2023-10-08 16:07:37 +08:00
1 parent ac78a5ea6f
commit 96708de3a4
12 files changed
+407 -95

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
export const ENDPOINT_API = 'https://api.zhishuyun.com';
export const ENDPOINT_DATA = 'https://data.zhishuyun.com';
+1
View File
@@ -4,3 +4,4 @@ export * from './user';
export * from './api';
export * from './chat';
export * from './midjourney';
export * from './usage';
+32 -6
View File
@@ -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;
}
+25 -2
View File
@@ -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: {
View File
Whitespace-only changes.
+2
View File
@@ -0,0 +1,2 @@
export * from './operator';
export * from './models';
+19
View File
@@ -0,0 +1,19 @@
import { IApi } from '../api';
export interface IApiUsage {
id?: string;
api?: IApi;
api_id?: string;
application_id?: string;
trace_id?: string;
metadata?: any;
created_at?: string;
updated_at?: string;
}
export interface IApiUsageListResponse {
count: number;
items: IApiUsage[];
}
export type IApiUsageDetailResponse = IApiUsage;
+27
View File
@@ -0,0 +1,27 @@
import { AxiosResponse } from 'axios';
import { httpClient } from '../instance';
import { IApiUsageDetailResponse, IApiUsageListResponse } from './models';
export interface IApiUsageQuery {
user_id?: string;
offset?: number;
limit?: number;
application_id?: string;
ordering?: string;
}
class ApiUsageOperator {
key = 'usage/apis';
async getAll(query: IApiUsageQuery): Promise<AxiosResponse<IApiUsageListResponse>> {
return await httpClient.get(`/${this.key}/`, {
params: query
});
}
async get(id: string): Promise<AxiosResponse<IApiUsageDetailResponse>> {
return await httpClient.get(`/${this.key}/${id}`);
}
}
export const apiUsageOperator = new ApiUsageOperator();