diff --git a/backend/src/text_gen.py b/backend/src/text_gen.py index b2fbc30..078b060 100644 --- a/backend/src/text_gen.py +++ b/backend/src/text_gen.py @@ -127,19 +127,18 @@ Output ONLY the prompt text. No numbers, no labels, no commentary.""" MAESTRO_COMPLETE_PROMPT = """You are Maestro, an expert music prompt writer for AI music generation models (specifically Google Lyria). -The user has started writing a prompt and wants you to turn it into a complete, polished prompt. Here is what they have so far: +The user has written the beginning of a prompt and wants you to continue it. Here is what they have: "{user_input}" -Rewrite and expand their idea into a single detailed, evocative music generation prompt. Your result should: -- Incorporate the user's existing words naturally — they should recognize their idea in the result -- Expand with specific details about genre, instrumentation, mood, tempo, structure, or production style -- Read as one complete, cohesive paragraph ready to use as-is -- Be between 2-4 sentences total +Continue and expand their idea. Add 2-3 sentences of specific musical detail — genre, instrumentation, mood, tempo, structure, production style. Your continuation will be appended directly after their text, so: -The output replaces what they wrote, so it must be a self-contained, finished prompt. +- Do NOT repeat or rephrase what they wrote +- Do NOT add a period if their text ends mid-sentence +- Start naturally as if picking up from where they left off +- Be vivid and specific — a producer should be able to generate from this -Output ONLY the completed prompt text. No numbers, no labels, no commentary.""" +Output ONLY your continuation text. No labels, no commentary, no quotes.""" MAESTRO_STRUCTURED_PROMPT = """You are Maestro, an expert music prompt writer for AI music generation models (specifically Google Lyria). diff --git a/frontend/src/components/Generator.tsx b/frontend/src/components/Generator.tsx index 96d1bec..f25bdec 100644 --- a/frontend/src/components/Generator.tsx +++ b/frontend/src/components/Generator.tsx @@ -188,10 +188,21 @@ export default function Generator({ onGenerate }: Props) { { - setPrompt(result) - if (mode === 'generate') { - setError('') + if (mode === 'complete') { + // Append continuation to existing prompt + setPrompt(prev => { + const trimmed = prev.trimEnd() + // If result starts lowercase, it flows from the input — just space + // If result starts uppercase, treat as new sentence — period + space + const startsLower = /^[a-z]/.test(result) + const separator = startsLower ? ' ' : '. ' + return trimmed + separator + result + }) + } else { + // Generate mode: replace empty prompt + setPrompt(result) } + setError('') }} onError={(msg) => setError(msg)} /> @@ -214,9 +225,19 @@ export default function Generator({ onGenerate }: Props) { prompt={Object.values(structuredPrompt).filter(Boolean).join(' ')} structured={isPro} onResult={(result, mode) => { - // Fallback: plain text mode for non-Pro, put result in 'additional' - setStructuredPrompt(prev => ({ ...prev, additional: result })) - if (mode === 'generate') setError('') + if (mode === 'complete') { + // Fallback: append to additional field + setStructuredPrompt(prev => { + const existing = prev.additional?.trim() || '' + const startsLower = /^[a-z]/.test(result) + const separator = startsLower ? ' ' : '. ' + return { ...prev, additional: existing + separator + result } + }) + } else { + // Generate: put in additional + setStructuredPrompt(prev => ({ ...prev, additional: result })) + } + setError('') }} onStructuredResult={(fields, mode) => { // Structured mode: merge fields into structuredPrompt, preserving user edits