From 30732c0b647f30a183bf280cdc881191e91f0acd Mon Sep 17 00:00:00 2001 From: "Troll (Hermes Agent)" Date: Fri, 31 Jul 2026 21:38:38 +0000 Subject: [PATCH] Single-paste Hermes response with title extraction and copy buttons --- app.py | 1 + models.py | 1 + templates/admin/request.html | 63 +++++++++++++++++++++++++----------- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/app.py b/app.py index 0998c1d..ac16906 100644 --- a/app.py +++ b/app.py @@ -196,6 +196,7 @@ def admin_request(rid): if action == 'save_prompt': update_request(rid, + suno_title=request.form.get('suno_title', '').strip(), suno_style=request.form.get('suno_style', '').strip(), suno_lyrics=request.form.get('suno_lyrics', '').strip(), status='prompt_ready' diff --git a/models.py b/models.py index 996a9a4..7a5a1e3 100644 --- a/models.py +++ b/models.py @@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS requests ( style_genre TEXT, extra_requests TEXT, status TEXT DEFAULT 'pending', + suno_title TEXT, suno_style TEXT, suno_lyrics TEXT, song_a_path TEXT, diff --git a/templates/admin/request.html b/templates/admin/request.html index e19c8fb..e2bb916 100644 --- a/templates/admin/request.html +++ b/templates/admin/request.html @@ -53,25 +53,31 @@ pre{background:#111827;padding:.8rem;border-radius:.5rem;overflow:auto;white-spa

1. Generate Suno Prompt

-

Paste the Style block and Lyrics block from Hermes into the boxes below, then click Apply.

+

Paste Hermes response into the box below. It will auto-extract Title, Style, and Lyrics.

- - - - - + +
- +
+ + + + + +
+ + +
@@ -127,24 +133,43 @@ function copyPromptForHermes() { style_genre: {{ req.style_genre | tojson }}, extra_requests: {{ req.extra_requests | tojson }} }; - const text = `Please write a Suno Custom Mode prompt for this customer.\n\nCustomer data:\nName: ${data.name}\nHobbies: ${data.hobbies || '-'}\nNotable facts: ${data.notable_facts || '-'}\nStyle / genre: ${data.style_genre || '-'}\nExtra requests: ${data.extra_requests || '-'}\n\nReply with exactly this format (no JSON):\n\nStyle:\n[the style description here]\n\nLyrics:\n[the lyrics here, with metatags]`; - navigator.clipboard.writeText(text).then(() => alert("Copied! Paste Hermes response into the Style and Lyrics boxes, then click Apply.")); + const text = `Please write a Suno Custom Mode prompt for this customer. Suggest a song title too.\n\nCustomer data:\nName: ${data.name}\nHobbies: ${data.hobbies || '-'}\nNotable facts: ${data.notable_facts || '-'}\nStyle / genre: ${data.style_genre || '-'}\nExtra requests: ${data.extra_requests || '-'}\n\nReply with exactly this format:\n\nTitle: [suggested title]\n\nStyle:\n[the style description here]\n\nLyrics:\n[the lyrics here, with metatags]`; + navigator.clipboard.writeText(text).then(() => alert("Copied! Paste Hermes response into the box above and click Extract.")); } -function applyPastedBlocks() { - const styleBlock = document.getElementById('pasted_style').value.trim(); - const lyricsBlock = document.getElementById('pasted_lyrics').value.trim(); - if (!styleBlock && !lyricsBlock) { - alert("Paste Style and/or Lyrics first."); +function extractHermesResponse() { + const raw = document.getElementById('hermes_response').value; + if (!raw.trim()) { + alert("Paste Hermes response first."); return; } - if (styleBlock) { - document.getElementById('suno_style').value = styleBlock; + + const titleMatch = raw.match(/^[\s]*Title:\s*([\s\S]*?)(?=\n\s*Style:|\n\s*Lyrics:|$)/im); + const styleMatch = raw.match(/^[\s]*Style:\s*([\s\S]*?)(?=\n\s*Lyrics:|$)/im); + const lyricsMatch = raw.match(/^[\s]*Lyrics:\s*([\s\S]*?)$/im); + + if (titleMatch) { + document.getElementById('suno_title').value = titleMatch[1].trim(); } - if (lyricsBlock) { - document.getElementById('suno_lyrics').value = lyricsBlock; + if (styleMatch) { + document.getElementById('suno_style').value = styleMatch[1].trim(); } - alert("Style and lyrics applied."); + if (lyricsMatch) { + document.getElementById('suno_lyrics').value = lyricsMatch[1].trim(); + } + + if (!styleMatch && !lyricsMatch) { + alert("Could not find Style or Lyrics sections. Make sure the response uses the exact format."); + } else { + alert("Title, Style, and Lyrics extracted. Use Copy buttons to paste into Suno."); + } +} + +function copyToClipboard(elementId, label) { + const el = document.getElementById(elementId); + el.select(); + el.setSelectionRange(0, 99999); + navigator.clipboard.writeText(el.value).then(() => alert(label + " copied!")); }