Add Hermes JSON paste parser to admin request page
This commit is contained in:
parent
1ad02023c2
commit
f3d81832d5
1 changed files with 30 additions and 2 deletions
|
|
@ -53,7 +53,12 @@ pre{background:#111827;padding:.8rem;border-radius:.5rem;overflow:auto;white-spa
|
|||
<div class="section">
|
||||
<h2>1. Generate Suno Prompt</h2>
|
||||
<button type="button" onclick="copyPromptForHermes()">Copy customer info for Hermes</button>
|
||||
<p class="copy-hint">Paste the result from Hermes into the fields below, then click Save.</p>
|
||||
<p class="copy-hint">Paste the result from Hermes into the box below, then click Apply to fill Style and Lyrics.</p>
|
||||
<label for="hermes_json">Paste Hermes JSON result here</label>
|
||||
<textarea id="hermes_json" rows="6" placeholder='{"title": "...", "style": "...", "lyrics": "..."}'></textarea>
|
||||
<div class="actions">
|
||||
<button type="button" class="secondary" onclick="applyHermesJson()">Apply JSON to fields</button>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="save_prompt">
|
||||
<label for="suno_style">Suno Style</label>
|
||||
|
|
@ -117,7 +122,30 @@ function copyPromptForHermes() {
|
|||
extra_requests: {{ req.extra_requests | tojson }}
|
||||
};
|
||||
const text = "Please write a Suno Custom Mode prompt for this customer. Return ONLY a JSON object with keys: title, style, lyrics.\n\nCustomer data:\n" + JSON.stringify(data, null, 2);
|
||||
navigator.clipboard.writeText(text).then(() => alert("Copied! Paste into Hermes, then paste Hermes JSON result back into the Style/Lyrics fields."));
|
||||
navigator.clipboard.writeText(text).then(() => alert("Copied! Paste into Hermes, then paste Hermes JSON result into the box above and click Apply."));
|
||||
}
|
||||
|
||||
function applyHermesJson() {
|
||||
const raw = document.getElementById('hermes_json').value.trim();
|
||||
if (!raw) {
|
||||
alert("Paste Hermes JSON first.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
if (parsed.style) {
|
||||
document.getElementById('suno_style').value = parsed.style;
|
||||
}
|
||||
if (parsed.lyrics) {
|
||||
document.getElementById('suno_lyrics').value = parsed.lyrics;
|
||||
}
|
||||
const msg = [];
|
||||
if (parsed.title) msg.push('Title: ' + parsed.title);
|
||||
msg.push('Style and lyrics applied.');
|
||||
alert(msg.join('\n'));
|
||||
} catch (e) {
|
||||
alert("Invalid JSON: " + e.message);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue