Add pika (#167)
This commit is contained in:
1 parent
ff0f3002d3
commit
5ebea7ef0c
160 files changed
+10841
-3375
No files matched your search
@@ -13,6 +13,7 @@ export * from './service';
|
||||
export * from './credential';
|
||||
export * from './qrart';
|
||||
export * from './luma';
|
||||
export * from './pika';
|
||||
export * from './headshots';
|
||||
export * from './site';
|
||||
export * from './suno';
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import { IPikaGenerateRequest, IPikaGenerateResponse, IPikaTaskResponse, IPikaTasksResponse } from '@/models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class PikaOperator {
|
||||
async task(id: string, options: { token: string }): Promise<AxiosResponse<IPikaTaskResponse>> {
|
||||
return await axios.post(
|
||||
`/pika/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<IPikaTasksResponse>> {
|
||||
return await axios.post(
|
||||
`/pika/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: IPikaGenerateRequest,
|
||||
options: {
|
||||
token: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IPikaGenerateResponse>> {
|
||||
return await axios.post('/pika/videos', data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'content-type': 'application/json',
|
||||
accept: 'application/x-ndjson'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const pikaOperator = new PikaOperator();
|
||||
+13
-1
@@ -32,7 +32,14 @@ class SunoOperator {
|
||||
}
|
||||
|
||||
async tasks(
|
||||
filter: { ids?: string[]; applicationId?: string; userId?: string; limit?: number; offset?: number },
|
||||
filter: {
|
||||
ids?: string[];
|
||||
applicationId?: string;
|
||||
userId?: string;
|
||||
type?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
},
|
||||
options: { token: string }
|
||||
): Promise<AxiosResponse<ISunoTasksResponse>> {
|
||||
return await axios.post(
|
||||
@@ -49,6 +56,11 @@ class SunoOperator {
|
||||
user_id: filter.userId
|
||||
}
|
||||
: {}),
|
||||
...(filter.type
|
||||
? {
|
||||
type: filter.type
|
||||
}
|
||||
: {}),
|
||||
...(filter.applicationId
|
||||
? {
|
||||
application_id: filter.applicationId
|
||||
|
||||
Reference in new issue
Block a user