Add hailuo (#168)
This commit is contained in:
1 parent
76313da5b1
commit
d3251fa84e
138 files changed
+9422
-3253
No files matched your search
@@ -0,0 +1,100 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import { IHailuoGenerateRequest, IHailuoGenerateResponse, IHailuoTaskResponse, IHailuoTasksResponse } from '@/models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class HailuoOperator {
|
||||
async task(id: string, options: { token: string }): Promise<AxiosResponse<IHailuoTaskResponse>> {
|
||||
return await axios.post(
|
||||
`/hailuo/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;
|
||||
},
|
||||
options: { token: string }
|
||||
): Promise<AxiosResponse<IHailuoTasksResponse>> {
|
||||
return await axios.post(
|
||||
`/hailuo/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
|
||||
}
|
||||
: {})
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'x-record-exempt': 'true'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async generate(
|
||||
data: IHailuoGenerateRequest,
|
||||
options: {
|
||||
token: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IHailuoGenerateResponse>> {
|
||||
return await axios.post('/hailuo/videos', data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'content-type': 'application/json',
|
||||
accept: 'application/x-ndjson'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const hailuoOperator = new HailuoOperator();
|
||||
@@ -14,6 +14,7 @@ export * from './credential';
|
||||
export * from './qrart';
|
||||
export * from './luma';
|
||||
export * from './pika';
|
||||
export * from './hailuo';
|
||||
export * from './headshots';
|
||||
export * from './site';
|
||||
export * from './suno';
|
||||
|
||||
Reference in new issue
Block a user