diff --git a/backend/src/ai/LocalAIApi.js b/backend/src/ai/LocalAIApi.js
index fd571ae..2b438e4 100644
--- a/backend/src/ai/LocalAIApi.js
+++ b/backend/src/ai/LocalAIApi.js
@@ -154,7 +154,10 @@ async function awaitResponse(aiRequestId, options = {}) {
const interval = Math.max(Number(options.interval ?? 5), 1);
const deadline = Date.now() + Math.max(timeout, interval) * 1000;
- while (true) {
+ let isComplete = false;
+ let finalResponse = null;
+
+ while (!isComplete && Date.now() < deadline) {
const statusResp = await fetchStatus(aiRequestId, {
headers: options.headers,
timeout: options.timeout_per_call,
@@ -165,14 +168,15 @@ async function awaitResponse(aiRequestId, options = {}) {
const data = statusResp.data || {};
if (data && typeof data === "object") {
if (data.status === "success") {
- return {
+ isComplete = true;
+ finalResponse = {
success: true,
status: 200,
data: data.response || data,
};
- }
- if (data.status === "failed") {
- return {
+ } else if (data.status === "failed") {
+ isComplete = true;
+ finalResponse = {
success: false,
status: 500,
error: String(data.error || "AI request failed"),
@@ -181,19 +185,24 @@ async function awaitResponse(aiRequestId, options = {}) {
}
}
} else {
- return statusResp;
+ isComplete = true;
+ finalResponse = statusResp;
}
- if (Date.now() >= deadline) {
- return {
- success: false,
- error: "timeout",
- message: "Timed out waiting for AI response.",
- };
+ if (!isComplete) {
+ await sleep(interval * 1000);
}
-
- await sleep(interval * 1000);
}
+
+ if (!finalResponse) {
+ return {
+ success: false,
+ error: "timeout",
+ message: "Timed out waiting for AI response.",
+ };
+ }
+
+ return finalResponse;
}
function extractText(response) {
@@ -306,7 +315,7 @@ function buildUrl(pathValue, baseUrl) {
}
function resolveStatusPath(aiRequestId, cfg) {
- const basePath = (cfg.responsesPath || "").replace(/\/+$/, "");
+ const basePath = (cfg.responsesPath || "").replace(///+$/, "");
if (!basePath) {
return `/ai-request/${encodeURIComponent(String(aiRequestId))}/status`;
}
@@ -481,4 +490,4 @@ module.exports = {
awaitResponse,
extractText,
decodeJsonFromResponse,
-};
+};
\ No newline at end of file
diff --git a/frontend/src/menuAside.ts b/frontend/src/menuAside.ts
index 61610b7..bd4ba5f 100644
--- a/frontend/src/menuAside.ts
+++ b/frontend/src/menuAside.ts
@@ -4,7 +4,7 @@ import { MenuAsideItem } from './interfaces'
const menuAside: MenuAsideItem[] = [
{
href: '/studio',
- label: 'Music Studio',
+ label: 'AI Music Generator Creator',
icon: icon.mdiMusicNotePlus,
},
{
diff --git a/frontend/src/pages/dashboard.tsx b/frontend/src/pages/dashboard.tsx
index 54b4d91..d4a5dcc 100644
--- a/frontend/src/pages/dashboard.tsx
+++ b/frontend/src/pages/dashboard.tsx
@@ -106,7 +106,7 @@ const Dashboard = () => {
main>
diff --git a/frontend/src/pages/studio/index.tsx b/frontend/src/pages/studio/index.tsx
index 297b7b5..8fdf992 100644
--- a/frontend/src/pages/studio/index.tsx
+++ b/frontend/src/pages/studio/index.tsx
@@ -17,7 +17,6 @@ import { SelectField } from '../../components/SelectField';
import BaseIcon from '../../components/BaseIcon';
import FormField from '../../components/FormField';
import NotificationBar from '../../components/NotificationBar';
-import axios from 'axios';
const StudioPage = () => {
const dispatch = useAppDispatch();
@@ -36,26 +35,26 @@ const StudioPage = () => {
const initialValues = {
song_title: '',
- generation_mode: 'manual_lyrics',
+ generation_mode: 'auto_lyrics',
lyrics_text: '',
- languageId: '',
- styleId: '',
- eraId: '',
- voiceId: '',
+ language: '',
+ style: '',
+ era: '',
+ voice: '',
};
const validate = (values: any) => {
const errors: any = {};
if (!values.song_title) errors.song_title = 'Required';
if (values.generation_mode === 'manual_lyrics' && !values.lyrics_text) errors.lyrics_text = 'Required';
- if (!values.languageId) errors.languageId = 'Required';
- if (!values.styleId) errors.styleId = 'Required';
- if (!values.eraId) errors.eraId = 'Required';
+ if (!values.language) errors.language = 'Required';
+ if (!values.style) errors.style = 'Required';
+ if (!values.era) errors.era = 'Required';
return errors;
};
const handleGenerateLyrics = async (values: any, setFieldValue: any) => {
- if (!values.song_title || !values.styleId || !values.eraId) {
+ if (!values.song_title || !values.style || !values.era) {
alert('Please provide a title, style, and era first.');
return;
}
@@ -81,9 +80,9 @@ const StudioPage = () => {
song_title: values.song_title,
generation_mode: values.generation_mode,
lyrics_text: values.lyrics_text,
- languageId: values.languageId,
- styleId: values.styleId,
- eraId: values.eraId,
+ language: values.language,
+ style: values.style,
+ era: values.era,
status: 'queued',
requested_at: new Date().toISOString(),
})).unwrap();
@@ -91,7 +90,7 @@ const StudioPage = () => {
const songId = songResult.id || songResult.data?.id;
await dispatch(createJob({
- songId: songId,
+ song: songId,
job_type: 'music_composition',
status: 'queued',
progress_percent: 0,
@@ -103,7 +102,7 @@ const StudioPage = () => {
setTimeout(() => setGenerationSuccess(false), 5000);
} catch (error) {
console.error('Failed to generate song:', error);
- alert('Failed to start generation. Please check the logs.');
+ alert('Failed to start generation. Please check the permissions and logs.');
} finally {
setIsGenerating(false);
}
@@ -150,7 +149,7 @@ const StudioPage = () => {
return (
<>