fix: move punctuation logic to LLM - backend returns complete joined text
The frontend no longer does separator/punctuation logic. Both Maestro modes (generate and complete) now simply setPrompt(result). The LLM is instructed to return the user's exact words + continuation, properly joined. This is the right layer for text joining decisions.
This commit is contained in:
1 parent
b86b4e5011
commit
78c13ccf01
2 files changed
+7
-40
No files matched your search
@@ -187,23 +187,8 @@ export default function Generator({ onGenerate }: Props) {
|
||||
<label className="text-xs text-kithara-muted">Prompt</label>
|
||||
<MaestroButton
|
||||
prompt={prompt}
|
||||
onResult={(result, mode) => {
|
||||
if (mode === 'complete') {
|
||||
// Append continuation to existing prompt
|
||||
setPrompt(prev => {
|
||||
const trimmed = prev.trimEnd()
|
||||
const endsWithPunct = /[.!?,;:]$/.test(trimmed)
|
||||
const startsLower = /^[a-z]/.test(result)
|
||||
// Already punctuated? Just space.
|
||||
// Flows naturally (lowercase)? Just space.
|
||||
// Otherwise: period + space for a new sentence.
|
||||
const separator = (endsWithPunct || startsLower) ? ' ' : '. '
|
||||
return trimmed + separator + result
|
||||
})
|
||||
} else {
|
||||
// Generate mode: replace empty prompt
|
||||
setPrompt(result)
|
||||
}
|
||||
onResult={(_result, _mode) => {
|
||||
setPrompt(_result)
|
||||
setError('')
|
||||
}}
|
||||
onError={(msg) => setError(msg)}
|
||||
@@ -226,22 +211,7 @@ export default function Generator({ onGenerate }: Props) {
|
||||
<MaestroButton
|
||||
prompt={Object.values(structuredPrompt).filter(Boolean).join(' ')}
|
||||
structured={isPro}
|
||||
onResult={(result, mode) => {
|
||||
if (mode === 'complete') {
|
||||
// Fallback: append to additional field
|
||||
setStructuredPrompt(prev => {
|
||||
const existing = prev.additional?.trim() || ''
|
||||
const endsWithPunct = /[.!?,;:]$/.test(existing)
|
||||
const startsLower = /^[a-z]/.test(result)
|
||||
const separator = (endsWithPunct || startsLower) ? ' ' : '. '
|
||||
return { ...prev, additional: existing + separator + result }
|
||||
})
|
||||
} else {
|
||||
// Generate: put in additional
|
||||
setStructuredPrompt(prev => ({ ...prev, additional: result }))
|
||||
}
|
||||
setError('')
|
||||
}}
|
||||
onResult={(_result, _mode) => { /* handled by onStructuredResult */ }}
|
||||
onStructuredResult={(fields, mode) => {
|
||||
// Structured mode: merge fields into structuredPrompt, preserving user edits
|
||||
setStructuredPrompt(prev => ({
|
||||
|
||||
Reference in new issue
Block a user