Move prompts into embedded Markdown assets
This commit is contained in:
@@ -60,11 +60,18 @@ func (m *Module) Propose(ctx context.Context, req contracts.ProposalRequest) ([]
|
||||
Glossary: req.Glossary,
|
||||
Config: req.Config,
|
||||
Messages: messages,
|
||||
StageName: proposalStageName(req),
|
||||
StartIndex: 0,
|
||||
LLMClient: req.LLMClient,
|
||||
Scheduler: req.LLMScheduler,
|
||||
DiagnosticsDir: req.DiagnosticsDir,
|
||||
PromptMetadata: map[string]any{
|
||||
"prompt_id": proposalPromptMetadata().PromptID,
|
||||
"prompt_version": proposalPromptMetadata().PromptVersion,
|
||||
"prompt_source": proposalPromptMetadata().PromptSource,
|
||||
"embedded_path": proposalPromptMetadata().EmbeddedPath,
|
||||
"sha256": proposalPromptMetadata().SHA256,
|
||||
},
|
||||
StageName: proposalStageName(req),
|
||||
StartIndex: 0,
|
||||
LLMClient: req.LLMClient,
|
||||
Scheduler: req.LLMScheduler,
|
||||
DiagnosticsDir: req.DiagnosticsDir,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/promptcontext"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/prompts"
|
||||
)
|
||||
|
||||
type promptSegment struct {
|
||||
@@ -52,34 +53,21 @@ func BuildProposalMessages(transcript *schema.Transcript, glossary *schema.Gloss
|
||||
return nil, fmt.Errorf("marshal transcript prompt context: %w", err)
|
||||
}
|
||||
|
||||
system := "You are Audita, a conservative homophone correction assistant. Identify only transcript changes that plausibly reflect homophones, phonetic similarity, or common mistranscriptions of spoken English. Do not make punctuation, capitalization, spacing, filler-word, repetition, style, or grammar edits. Do not paraphrase, summarize, or rewrite content."
|
||||
user := "Review this transcript section and return only homophone or spoken-form corrections that should be applied.\n\n" +
|
||||
"Rules:\n" +
|
||||
"- Approve only corrections where the original text is plausibly a mistaken homophone, phonetic rendering, or mistranscription of what was likely spoken.\n" +
|
||||
"- Allow examples such as changing \"dam\" to \"damn\", \"rank\" to \"Hrank\", or \"gestures\" to \"Jesters\" when local context supports the correction.\n" +
|
||||
"- Reject unrelated substitutions like changing \"Lyra\" to \"Jesters\".\n" +
|
||||
"- Reject antonyms or reversals such as changing \"visible\" to \"invisible\".\n" +
|
||||
"- Do not add or remove punctuation, alter capitalization only, normalize spacing, remove filler words, collapse repetitions, or make general readability edits.\n" +
|
||||
"- Treat glossary names and aliases as protected spellings and context.\n" +
|
||||
"- You may correct toward glossary names, aliases, or their plural forms when the correction is acoustically plausible and supported by local context.\n" +
|
||||
"- Do not replace, Anglicize, normalize, lowercase, or otherwise alter protected glossary names or aliases that already appear correctly in the transcript.\n" +
|
||||
"- Preserve canonical glossary capitalization for protected names and aliases, even if they look unusual.\n" +
|
||||
"- If a segment includes categories, treat them as additional transcript context.\n" +
|
||||
"- Use the exact id from the input segment.\n" +
|
||||
"- For returned corrections, original_text must be only the exact text span that needs replacement, not the full segment text unless the whole segment is the replacement span.\n" +
|
||||
"- Choose an original_text span that appears exactly once in the current segment text.\n" +
|
||||
"- corrected_text must be only the replacement text for that span, not the full corrected segment text unless the whole segment is the replacement span.\n" +
|
||||
"- Each returned correction must contain only id, original_text, corrected_text, and confidence.\n" +
|
||||
"- Do not return corrections where original_text and corrected_text are identical.\n" +
|
||||
"- Do not return speaker, start, or end fields.\n" +
|
||||
"- Return only changed segments; do not return entries for unchanged segments.\n" +
|
||||
"- confidence must be between 0.0 and 1.0.\n" +
|
||||
"- If no corrections are needed, return an empty corrections list.\n\n" +
|
||||
promptcontext.TranscriptDescriptionBlock(transcriptDescription) +
|
||||
fmt.Sprintf("Protected glossary/context:\n%s\n\nTranscript section:\n%s", string(glossaryJSON), string(sectionJSON))
|
||||
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDModuleHomophonesProposal, map[string]string{
|
||||
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
||||
"GlossaryJSON": string(glossaryJSON),
|
||||
"SectionJSON": string(sectionJSON),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []contracts.LLMMessage{
|
||||
{Role: "system", Content: system},
|
||||
{Role: "user", Content: user},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func proposalPromptMetadata() prompts.Metadata {
|
||||
return prompts.MustLookupMetadata(prompts.PromptIDModuleHomophonesProposal)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user