Migrate new service (#1)
This commit is contained in:
1 parent
f13ca37d63
commit
28da0263dc
109 files changed
+1160
-1053
No files matched your search
@@ -0,0 +1,87 @@
|
||||
import { IService } from './service';
|
||||
|
||||
export interface IForm {
|
||||
queries?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
body?: {
|
||||
[key: string]: string | object | boolean | number | object[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface ISchema {
|
||||
properties?: {
|
||||
[key: string]: ISchema;
|
||||
};
|
||||
items?: ISchema[];
|
||||
enum?: (string | number)[];
|
||||
type: 'object' | 'array' | 'string' | 'number' | 'boolean';
|
||||
title: string;
|
||||
optional?: boolean;
|
||||
example?: string | number;
|
||||
}
|
||||
|
||||
export interface IRequest {
|
||||
id: string;
|
||||
body: ISchema;
|
||||
headers: ISchema;
|
||||
queries: ISchema;
|
||||
params: ISchema;
|
||||
method: 'GET' | 'POST' | 'HEAD' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
|
||||
}
|
||||
|
||||
export interface IResponse {
|
||||
id: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
example?: string;
|
||||
is_success: boolean;
|
||||
error_code?: string;
|
||||
status_code: number;
|
||||
body: ISchema;
|
||||
headers: ISchema;
|
||||
}
|
||||
|
||||
export interface IPackage {
|
||||
id: string;
|
||||
amount: number;
|
||||
price: number;
|
||||
}
|
||||
|
||||
export enum IApiUnit {
|
||||
COUNT = 'Count'
|
||||
}
|
||||
|
||||
export interface IApiPrice {
|
||||
data: any[];
|
||||
spans: [number, number, number, number][];
|
||||
columns: {
|
||||
key: string;
|
||||
label: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface IApi {
|
||||
id: string;
|
||||
name?: string;
|
||||
title?: string;
|
||||
definition?: any;
|
||||
introduction?: string;
|
||||
price?: IApiPrice;
|
||||
tags?: string[];
|
||||
service?: IService;
|
||||
service_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
stage?: string;
|
||||
}
|
||||
|
||||
export interface IApiListResponse {
|
||||
count: number;
|
||||
items: IApi[];
|
||||
}
|
||||
|
||||
export type IApiDetailResponse = IApi;
|
||||
@@ -0,0 +1,40 @@
|
||||
import { IService } from './service';
|
||||
|
||||
export enum IApplicationType {
|
||||
API = 'Api'
|
||||
}
|
||||
|
||||
export enum ICredentialType {
|
||||
TOKEN = 'Token',
|
||||
IDENTITY = 'Identity'
|
||||
}
|
||||
|
||||
export interface ICredential {
|
||||
type: ICredentialType;
|
||||
name?: string;
|
||||
token?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IApplication {
|
||||
id?: string;
|
||||
type?: IApplicationType;
|
||||
service_id?: string;
|
||||
service?: IService;
|
||||
user_id?: string;
|
||||
remaining_amount?: number;
|
||||
used_amount?: number;
|
||||
credentials?: ICredential[];
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IApplicationListResponse {
|
||||
count: number;
|
||||
items: IApplication[];
|
||||
}
|
||||
|
||||
export type IApplicationDetailResponse = IApplication;
|
||||
@@ -0,0 +1,16 @@
|
||||
export interface IToken {
|
||||
access?: string;
|
||||
refresh?: string;
|
||||
}
|
||||
|
||||
export interface ITokenResponse extends IToken {}
|
||||
|
||||
export interface IOAuthTokenRequest {
|
||||
code: string;
|
||||
}
|
||||
|
||||
export interface IOAuthTokenResponse {
|
||||
access_token: string;
|
||||
expires_in: number;
|
||||
refresh_token: string;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { ROLE_ASSISTANT, ROLE_SYSTEM, ROLE_USER } from '@/constants';
|
||||
import {
|
||||
CHAT_MODEL_NAME_GPT_3_5,
|
||||
CHAT_MODEL_NAME_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_NAME_GPT_4,
|
||||
CHAT_MODEL_NAME_GPT_4_BROWSING,
|
||||
CHAT_MODEL_NAME_GPT_4_VISION
|
||||
} from '@/constants';
|
||||
|
||||
export type IChatModelName =
|
||||
| typeof CHAT_MODEL_NAME_GPT_3_5
|
||||
| typeof CHAT_MODEL_NAME_GPT_3_5_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_GPT_4
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_VISION;
|
||||
|
||||
export interface IChatModel {
|
||||
name: IChatModelName;
|
||||
displayName: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
interface IError {
|
||||
code: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export enum IChatMessageState {
|
||||
PENDING = 'pending',
|
||||
ANSWERING = 'answering',
|
||||
FINISHED = 'finished',
|
||||
FAILED = 'failed'
|
||||
}
|
||||
|
||||
export interface IChatMessageContentItem {
|
||||
type: string;
|
||||
text?: string;
|
||||
image_url?: string;
|
||||
}
|
||||
|
||||
export interface IChatMessage {
|
||||
state?: IChatMessageState;
|
||||
content?: string | IChatMessageContentItem[];
|
||||
role?: typeof ROLE_SYSTEM | typeof ROLE_ASSISTANT | typeof ROLE_USER;
|
||||
error?: IError;
|
||||
}
|
||||
|
||||
export interface IChatConversation {
|
||||
id: string;
|
||||
messages: IChatMessage[];
|
||||
title?: string;
|
||||
deleting?: boolean;
|
||||
editing?: boolean;
|
||||
new?: boolean;
|
||||
}
|
||||
|
||||
export interface IChatConversationOptions {
|
||||
stream?: (response: IChatConversationResponse) => void;
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface IChatConversationRequest {
|
||||
id?: string;
|
||||
question?: string;
|
||||
references?: string[];
|
||||
stateful?: boolean;
|
||||
messages?: IChatMessage[];
|
||||
action?: IChatConversationAction;
|
||||
model: IChatModelName;
|
||||
}
|
||||
|
||||
export interface IChatConversationResponse {
|
||||
answer: string;
|
||||
delta_answer: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface IChatConversationsResponse {
|
||||
items: IChatConversation[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
export enum IChatConversationAction {
|
||||
CHAT = 'chat',
|
||||
RETRIEVE = 'retrieve',
|
||||
UPDATE = 'update',
|
||||
DELETE = 'delete',
|
||||
RETRIEVE_BATCH = 'retrieve_batch'
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { ACTION_CREATE, ACTION_DELETE, ACTION_UPDATE, ROLE_ASSISTANT, ROLE_SYSTEM, ROLE_USER } from '@/constants';
|
||||
|
||||
export interface IError {
|
||||
code: string;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
export interface IChatdocRepository {
|
||||
id: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
deleting?: boolean;
|
||||
editing?: boolean;
|
||||
documents?: IChatdocDocument[];
|
||||
conversations?: IChatdocConversation[];
|
||||
}
|
||||
|
||||
export interface IChatdocDocument {
|
||||
id: string;
|
||||
repository_id: string;
|
||||
file_url: string;
|
||||
file_name: string;
|
||||
}
|
||||
|
||||
export interface IChatdocConversation {
|
||||
id: string;
|
||||
repository_id: string;
|
||||
messages: IChatdocMessage[];
|
||||
editing?: boolean;
|
||||
deleting?: boolean;
|
||||
}
|
||||
|
||||
export interface IChatdocMessage {
|
||||
content?: string;
|
||||
error?: IError;
|
||||
state?: IChatdocMessageState;
|
||||
role?: typeof ROLE_SYSTEM | typeof ROLE_ASSISTANT | typeof ROLE_USER;
|
||||
}
|
||||
|
||||
export enum IChatdocMessageState {
|
||||
PENDING = 'pending',
|
||||
ANSWERING = 'answering',
|
||||
FINISHED = 'finished',
|
||||
FAILED = 'failed'
|
||||
}
|
||||
|
||||
export interface IChatdocChatRequest {
|
||||
repository_id: string;
|
||||
messages: IChatdocMessage[];
|
||||
temperature?: number;
|
||||
knowledge_fallback?: boolean;
|
||||
}
|
||||
|
||||
export interface IChatdocDocumentRequest extends IChatdocDocument {
|
||||
action: typeof ACTION_CREATE | typeof ACTION_UPDATE | typeof ACTION_DELETE;
|
||||
callback_url?: string;
|
||||
}
|
||||
|
||||
export interface IChatdocDocumentResponse extends IChatdocDocument {}
|
||||
|
||||
export type IChatdocConversationsResponse = IChatdocConversation[];
|
||||
|
||||
export interface IChatdocRepositoryRequest extends IChatdocRepository {
|
||||
action: typeof ACTION_CREATE | typeof ACTION_UPDATE | typeof ACTION_DELETE;
|
||||
}
|
||||
|
||||
export interface IChatdocRepositoryResponse extends IChatdocRepository {}
|
||||
export type IChatdocRepositoriesResponse = {
|
||||
items: IChatdocRepository[];
|
||||
count: number;
|
||||
};
|
||||
export type IChatdocDocumentsResponse = IChatdocDocument[];
|
||||
|
||||
export interface IChatdocChatResponse {
|
||||
answer: string;
|
||||
delta_answer: string;
|
||||
repository_id?: string;
|
||||
conversation_id?: string;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export enum Status {
|
||||
Request = 'Request',
|
||||
Success = 'Success',
|
||||
Error = 'Error',
|
||||
None = 'None'
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { IOrder } from './order';
|
||||
|
||||
export interface IDistributionHistory {
|
||||
id: string;
|
||||
user_id: string;
|
||||
invitee_id: string;
|
||||
order?: IOrder;
|
||||
order_id?: string;
|
||||
price: number;
|
||||
reward: number;
|
||||
percentage: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDistributionLevel {
|
||||
id: string;
|
||||
level: number;
|
||||
threshold: number;
|
||||
percentage: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDistributionStatus {
|
||||
id: string;
|
||||
user_id: string;
|
||||
price: number;
|
||||
reward: number;
|
||||
level_id?: string;
|
||||
level?: IDistributionLevel;
|
||||
percentage: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDistributionStatusListResponse {
|
||||
count: number;
|
||||
items: IDistributionStatus[];
|
||||
}
|
||||
|
||||
export type IDistributionStatusDetailResponse = IDistributionStatus;
|
||||
|
||||
export interface IDistributionHistoryListResponse {
|
||||
count: number;
|
||||
items: IDistributionHistory[];
|
||||
}
|
||||
|
||||
export type IDistributionHistoryDetailResponse = IDistributionHistory;
|
||||
|
||||
export interface IDistributionLevelListResponse {
|
||||
count: number;
|
||||
items: IDistributionLevel[];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export * from './common';
|
||||
export * from './api';
|
||||
export * from './application';
|
||||
export * from './auth';
|
||||
export * from './chat';
|
||||
export * from './chatdoc';
|
||||
export * from './distribution';
|
||||
export * from './midjourney';
|
||||
export * from './order';
|
||||
export * from './usage';
|
||||
export * from './user';
|
||||
export * from './service';
|
||||
@@ -0,0 +1,108 @@
|
||||
export interface IMidjourneyMode {
|
||||
icon: string;
|
||||
name: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export interface IMidjourneyPreset {
|
||||
model?: string;
|
||||
ratio?: string;
|
||||
version?: string;
|
||||
stylize?: number;
|
||||
chaos?: number;
|
||||
advanced?: boolean;
|
||||
quality?: string;
|
||||
weird?: number;
|
||||
iw?: number;
|
||||
style?: string;
|
||||
translation?: boolean;
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineAction {
|
||||
GENERATE = 'generate',
|
||||
UPSCALE1 = 'upscale1',
|
||||
UPSCALE2 = 'upscale2',
|
||||
UPSCALE3 = 'upscale3',
|
||||
UPSCALE4 = 'upscale4',
|
||||
VARIATION1 = 'variation1',
|
||||
VARIATION2 = 'variation2',
|
||||
VARIATION3 = 'variation3',
|
||||
VARIATION4 = 'variation4',
|
||||
VARIATION_STRONG = 'variation_strong',
|
||||
VARIATION_SUBTLE = 'variation_subtle',
|
||||
UPSCALE_SUBTLE = 'upscale_subtle',
|
||||
UPSCALE_CREATIVE = 'upscale_creative',
|
||||
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',
|
||||
UPSCALE_2X = 'upscale_2x',
|
||||
UPSCALE_4X = 'upscale_4x',
|
||||
REDO_UPSCALE_2X = 'redo_upscale_2x',
|
||||
REDO_UPSCALE_4X = 'redo_upscale_4x',
|
||||
REDO_UPSCALE_SUBTLE = 'redo_upscale_subtle',
|
||||
REDO_UPSCALE_CREATIVE = 'redo_upscale_creative'
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineState {
|
||||
PENDING = 'pending',
|
||||
GENERATING = 'generating',
|
||||
FINISHED = 'finished',
|
||||
FAILED = 'failed'
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineMode {
|
||||
FAST = 'fast',
|
||||
RELAX = 'relax',
|
||||
TURBO = 'turbo'
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineRequest {
|
||||
action?: MidjourneyImagineAction;
|
||||
mode?: MidjourneyImagineMode;
|
||||
prompt?: string;
|
||||
image_id?: string;
|
||||
translation?: boolean;
|
||||
callback_url?: string;
|
||||
application_id?: string;
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineResponse {
|
||||
task_id: string;
|
||||
progress: number;
|
||||
image_id: string;
|
||||
image_url: string;
|
||||
trace_id: string;
|
||||
raw_image_url: string;
|
||||
actions: MidjourneyImagineAction[];
|
||||
code?: string;
|
||||
detail?: string;
|
||||
success?: boolean;
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineTask {
|
||||
id: string;
|
||||
created_at?: string;
|
||||
mode: MidjourneyImagineMode;
|
||||
request?: IMidjourneyImagineRequest;
|
||||
response?: IMidjourneyImagineResponse;
|
||||
state?: MidjourneyImagineState;
|
||||
}
|
||||
|
||||
export type IMidjourneyImagineTaskResponse = IMidjourneyImagineTask;
|
||||
|
||||
export interface IMidjourneyImagineTasksResponse {
|
||||
items: IMidjourneyImagineTask[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface IMidjourneyImagineOptions {
|
||||
stream?: (response: IMidjourneyImagineResponse) => void;
|
||||
token?: string;
|
||||
endpoint?: string;
|
||||
path?: string;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { IApplication } from './application';
|
||||
|
||||
export enum OrderState {
|
||||
PENDING = 'Pending',
|
||||
PAID = 'Paid',
|
||||
EXPIRED = 'Expired',
|
||||
FAILED = 'Failed'
|
||||
}
|
||||
|
||||
export interface IOrder {
|
||||
id?: string;
|
||||
description?: string;
|
||||
state?: OrderState;
|
||||
price?: number;
|
||||
amount?: number;
|
||||
user_id?: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
application?: IApplication;
|
||||
application_id?: string;
|
||||
wechatpay_url?: string;
|
||||
pay_id?: string;
|
||||
pay_url?: string;
|
||||
alipay_url?: string;
|
||||
pay_way?: string;
|
||||
}
|
||||
|
||||
export interface IOrderListResponse {
|
||||
count: number;
|
||||
items: IOrder[];
|
||||
}
|
||||
|
||||
export type IOrderDetailResponse = IOrder;
|
||||
@@ -0,0 +1,28 @@
|
||||
import { IApi, IPackage } from './api';
|
||||
|
||||
export interface IService {
|
||||
id: string;
|
||||
title: string;
|
||||
unit?: string;
|
||||
price?: number;
|
||||
description?: string;
|
||||
free_amount?: number;
|
||||
applied_count?: number;
|
||||
applied?: boolean;
|
||||
tags?: string[];
|
||||
thumbnail?: string;
|
||||
introduction?: string;
|
||||
apis?: IApi[];
|
||||
api_ids?: string[];
|
||||
packages?: IPackage[];
|
||||
package_ids?: string[];
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IServiceListResponse {
|
||||
count: number;
|
||||
items: IService[];
|
||||
}
|
||||
|
||||
export type IServiceDetailResponse = IService;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,20 @@
|
||||
export interface IUser {
|
||||
id?: string;
|
||||
username?: string;
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
email?: string;
|
||||
nickname?: string;
|
||||
gender?: number;
|
||||
city?: string;
|
||||
province?: string;
|
||||
country?: string;
|
||||
avatar?: string;
|
||||
}
|
||||
|
||||
export interface IUserListResponse {
|
||||
count: number;
|
||||
items: IUser[];
|
||||
}
|
||||
|
||||
export interface IUserDetailResponse extends IUser {}
|
||||
Reference in new issue
Block a user