Update api.ts: ditModel fields, updateSong normalization, formatInput response, LoRA endpoint paths
This commit is contained in:
+62
-11
@@ -106,6 +106,7 @@ export interface Song {
|
|||||||
user_id?: string;
|
user_id?: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
creator?: string;
|
creator?: string;
|
||||||
|
ditModel?: string;
|
||||||
generation_params?: any;
|
generation_params?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +156,46 @@ export const songsApi = {
|
|||||||
createSong: (song: Partial<Song>, token: string): Promise<{ song: Song }> =>
|
createSong: (song: Partial<Song>, token: string): Promise<{ song: Song }> =>
|
||||||
api('/api/songs', { method: 'POST', body: song, token }),
|
api('/api/songs', { method: 'POST', body: song, token }),
|
||||||
|
|
||||||
updateSong: (id: string, updates: Partial<Song>, token: string): Promise<{ song: Song }> =>
|
updateSong: async (id: string, updates: Partial<Song>, token: string): Promise<{ song: any }> => {
|
||||||
api(`/api/songs/${id}`, { method: 'PATCH', body: updates, token }),
|
const result = await api(`/api/songs/${id}`, { method: 'PATCH', body: updates, token }) as { song: any };
|
||||||
|
const s = result.song;
|
||||||
|
const rawUrl = s.audio_url || s.audioUrl;
|
||||||
|
const resolvedUrl = getAudioUrl(rawUrl, s.id);
|
||||||
|
|
||||||
|
return {
|
||||||
|
song: {
|
||||||
|
id: s.id,
|
||||||
|
title: s.title,
|
||||||
|
lyrics: s.lyrics,
|
||||||
|
style: s.style,
|
||||||
|
caption: s.caption,
|
||||||
|
cover_url: s.cover_url,
|
||||||
|
coverUrl: s.cover_url || s.coverUrl || `https://picsum.photos/seed/${s.id}/400/400`,
|
||||||
|
duration: s.duration && s.duration > 0 ? `${Math.floor(s.duration / 60)}:${String(Math.floor(s.duration % 60)).padStart(2, '0')}` : '0:00',
|
||||||
|
createdAt: new Date(s.created_at || s.createdAt),
|
||||||
|
created_at: s.created_at,
|
||||||
|
tags: s.tags || [],
|
||||||
|
audioUrl: resolvedUrl,
|
||||||
|
audio_url: resolvedUrl,
|
||||||
|
isPublic: s.is_public ?? s.isPublic,
|
||||||
|
is_public: s.is_public ?? s.isPublic,
|
||||||
|
likeCount: s.like_count || s.likeCount || 0,
|
||||||
|
like_count: s.like_count || s.likeCount || 0,
|
||||||
|
viewCount: s.view_count || s.viewCount || 0,
|
||||||
|
view_count: s.view_count || s.viewCount || 0,
|
||||||
|
userId: s.user_id || s.userId,
|
||||||
|
user_id: s.user_id || s.userId,
|
||||||
|
creator: s.creator,
|
||||||
|
creator_avatar: s.creator_avatar,
|
||||||
|
ditModel: s.dit_model || s.ditModel,
|
||||||
|
isGenerating: s.isGenerating,
|
||||||
|
queuePosition: s.queuePosition,
|
||||||
|
bpm: s.bpm,
|
||||||
|
key_scale: s.key_scale,
|
||||||
|
time_signature: s.time_signature,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
deleteSong: (id: string, token: string): Promise<{ success: boolean }> =>
|
deleteSong: (id: string, token: string): Promise<{ success: boolean }> =>
|
||||||
api(`/api/songs/${id}`, { method: 'DELETE', token }),
|
api(`/api/songs/${id}`, { method: 'DELETE', token }),
|
||||||
@@ -206,6 +245,9 @@ export interface GenerationParams {
|
|||||||
style: string;
|
style: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
// Model Selection
|
||||||
|
ditModel?: string;
|
||||||
|
|
||||||
// Common
|
// Common
|
||||||
instrumental: boolean;
|
instrumental: boolean;
|
||||||
vocalLanguage?: string;
|
vocalLanguage?: string;
|
||||||
@@ -264,6 +306,7 @@ export interface GenerationParams {
|
|||||||
trackName?: string;
|
trackName?: string;
|
||||||
completeTrackClasses?: string[];
|
completeTrackClasses?: string[];
|
||||||
isFormatCaption?: boolean;
|
isFormatCaption?: boolean;
|
||||||
|
loraLoaded?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GenerationJob {
|
export interface GenerationJob {
|
||||||
@@ -321,27 +364,35 @@ export const generateApi = {
|
|||||||
lmModel?: string;
|
lmModel?: string;
|
||||||
lmBackend?: string;
|
lmBackend?: string;
|
||||||
}, token: string): Promise<{
|
}, token: string): Promise<{
|
||||||
success: boolean;
|
|
||||||
caption?: string;
|
caption?: string;
|
||||||
lyrics?: string;
|
lyrics?: string;
|
||||||
bpm?: number;
|
bpm?: number;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
key_scale?: string;
|
key_scale?: string;
|
||||||
language?: string;
|
vocal_language?: string;
|
||||||
time_signature?: string;
|
time_signature?: string;
|
||||||
status_message?: string;
|
status_message?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
}> => api('/api/generate/format', { method: 'POST', body: params, token }),
|
}> => api('/api/generate/format', { method: 'POST', body: params, token }),
|
||||||
|
|
||||||
// LoRA management (requires ACE-Step training fork)
|
// LoRA Inference (requires ACE-Step training fork)
|
||||||
loadLora: (params: { lora_path: string }, token: string): Promise<{ message: string }> =>
|
loadLora: (params: {
|
||||||
api('/api/generate/lora/load', { method: 'POST', body: params, token }),
|
lora_path: string;
|
||||||
|
}, token: string): Promise<{
|
||||||
|
message: string;
|
||||||
|
lora_path: string;
|
||||||
|
}> => api('/api/lora/load', { method: 'POST', body: params, token }),
|
||||||
|
|
||||||
unloadLora: (token: string): Promise<{ message: string }> =>
|
unloadLora: (token: string): Promise<{
|
||||||
api('/api/generate/lora/unload', { method: 'POST', token }),
|
message: string;
|
||||||
|
}> => api('/api/lora/unload', { method: 'POST', token }),
|
||||||
|
|
||||||
setLoraScale: (params: { scale: number }, token: string): Promise<{ message: string }> =>
|
setLoraScale: (params: {
|
||||||
api('/api/generate/lora/scale', { method: 'POST', body: params, token }),
|
scale: number;
|
||||||
|
}, token: string): Promise<{
|
||||||
|
message: string;
|
||||||
|
scale: number;
|
||||||
|
}> => api('/api/lora/scale', { method: 'POST', body: params, token }),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Users API
|
// Users API
|
||||||
|
|||||||
Reference in New Issue
Block a user