112 lines
2.8 KiB
TypeScript
112 lines
2.8 KiB
TypeScript
export type BaseOptions = {
|
||
/** OpenAI API Key */
|
||
apiKey: string;
|
||
/** 模型名称 */
|
||
model: string;
|
||
/** 自定义 baseURL */
|
||
baseURL?: string;
|
||
};
|
||
|
||
/**
|
||
* 图片生成请求体。
|
||
*/
|
||
export interface IImageGenerateRequest {
|
||
/** 图片提示词 */
|
||
prompt?: string;
|
||
}
|
||
|
||
/**
|
||
* 图片生成成功后返回给前端的数据。
|
||
*/
|
||
export interface IImageGenerateData {
|
||
/** 生成图片访问地址,前端当前优先展示这个地址 */
|
||
imageUrl: string;
|
||
/** 上游返回的修订提示词,可能为空 */
|
||
revisedPrompt?: string;
|
||
}
|
||
|
||
/**
|
||
* 生图任务状态。
|
||
*/
|
||
export type ImageGenerationStatus =
|
||
| "QUEUED"
|
||
| "RUNNING"
|
||
| "SUCCEEDED"
|
||
| "FAILED";
|
||
|
||
/**
|
||
* 生图历史列表项。
|
||
*/
|
||
export interface IImageHistoryItem {
|
||
/** 生图记录 ID,BigInt 会以字符串返回 */
|
||
id: string;
|
||
/** NewAPI 用户 ID */
|
||
userId: number;
|
||
/** 用户输入的生图提示词 */
|
||
prompt: string;
|
||
/** 生图状态 */
|
||
status: ImageGenerationStatus;
|
||
/** 生图模型 */
|
||
model: string;
|
||
/** 生图开始时间,ISO 字符串 */
|
||
startedAt: string;
|
||
/** 生图结束时间,ISO 字符串,未结束时为 null */
|
||
endedAt: string | null;
|
||
/** 生图耗时,单位毫秒 */
|
||
durationMs: number | null;
|
||
/** NewAPI 上游返回的图片访问地址 */
|
||
imageUrl: string | null;
|
||
/** Lsky 图床归档后的图片访问地址;为空且没有错误提示时表示仍在归档中 */
|
||
hostedImageUrl: string | null;
|
||
/** 上游返回的修订提示词,可能为空 */
|
||
revisedPrompt: string | null;
|
||
/** 面向前端的本地泛化错误提示;为空且 hostedImageUrl 也为空时表示仍在归档中 */
|
||
errorMessage: string | null;
|
||
/** 记录创建时间,ISO 字符串 */
|
||
createdAt: string;
|
||
}
|
||
|
||
/**
|
||
* 生图历史详情。
|
||
*/
|
||
export interface IImageHistoryDetail extends IImageHistoryItem {
|
||
/** 图片 MIME 类型,可能为空 */
|
||
imageMimeType: string | null;
|
||
/** 内部响应不向前端透出,当前固定为 null */
|
||
upstreamResponse: unknown;
|
||
/** 内部图床响应不向前端透出,当前固定为 null */
|
||
hostedResponse: unknown;
|
||
}
|
||
|
||
/**
|
||
* 生图历史分页响应。
|
||
*/
|
||
export interface IImageHistoryListData {
|
||
/** 当前页码 */
|
||
page: number;
|
||
/** 每页数量 */
|
||
pageSize: number;
|
||
/** 当前用户未删除记录总数 */
|
||
total: number;
|
||
/** 当前页历史记录 */
|
||
items: IImageHistoryItem[];
|
||
}
|
||
|
||
/**
|
||
* 全局生图统计响应。
|
||
*/
|
||
export interface IImageGenerationStatsData {
|
||
/** 总生图请求数,包含成功和失败 */
|
||
totalRequests: number;
|
||
/** 成功生图请求数 */
|
||
successRequests: number;
|
||
/** 失败生图请求数 */
|
||
failedRequests: number;
|
||
/** 排队中请求数,预留异步任务使用 */
|
||
queuedRequests: number;
|
||
/** 进行中请求数 */
|
||
runningRequests: number;
|
||
/** 成功生成图片总数 */
|
||
totalImages: number;
|
||
}
|