This commit is contained in:
HCode authored and GitHub committed 2025-02-19 15:01:06 +00:00
1 parent 1203ef569b
commit 5d8902e566
40 files changed
+2416 -1

No files matched your search

+112
View File
@@ -0,0 +1,112 @@
import axios, { AxiosResponse } from 'axios';
import { IFluxGenerateRequest, IFluxGenerateResponse, IFluxTaskResponse, IFluxTasksResponse } from '@/models';
import { BASE_URL_API } from '@/constants';
class FluxOperator {
async task(id: string, options: { token: string }): Promise<AxiosResponse<IFluxTaskResponse>> {
return await axios.post(
`/flux/tasks`,
{
action: 'retrieve',
id: id
},
{
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: `Bearer ${options.token}`,
'x-record-exempt': 'true'
},
baseURL: BASE_URL_API
}
);
}
async tasks(
filter: {
ids?: string[];
applicationId?: string;
userId?: string;
type?: string;
limit?: number;
offset?: number;
createdAtMax?: number;
createdAtMin?: number;
},
options: { token: string }
): Promise<AxiosResponse<IFluxTasksResponse>> {
return await axios.post(
`/flux/tasks`,
{
action: 'retrieve_batch',
...(filter.ids
? {
ids: filter.ids
}
: {}),
...(filter.applicationId
? {
application_id: filter.applicationId
}
: {}),
...(filter.userId
? {
user_id: filter.userId
}
: {}),
...(filter.type
? {
type: filter.type
}
: {}),
...(filter.limit !== undefined
? {
limit: filter.limit
}
: {}),
...(filter.offset !== undefined
? {
offset: filter.offset
}
: {}),
...(filter.createdAtMax !== undefined
? {
created_at_max: filter.createdAtMax
}
: {}),
...(filter.createdAtMin !== undefined
? {
created_at_min: filter.createdAtMin
}
: {})
},
{
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: `Bearer ${options.token}`,
'x-record-exempt': 'true'
},
baseURL: BASE_URL_API
}
);
}
async generate(
data: IFluxGenerateRequest,
options: {
token: string;
}
): Promise<AxiosResponse<IFluxGenerateResponse>> {
return await axios.post('/flux/images', data, {
headers: {
authorization: `Bearer ${options.token}`,
'content-type': 'application/json',
accept: 'application/x-ndjson'
},
baseURL: BASE_URL_API
});
}
}
export const fluxOperator = new FluxOperator();
+1
View File
@@ -14,6 +14,7 @@ export * from './credential';
export * from './qrart';
export * from './luma';
export * from './pika';
export * from './flux';
export * from './hailuo';
export * from './headshots';
export * from './site';