2026-05-12 02:57:06 +00:00
|
|
|
package grammar
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
|
|
|
|
"gitea.maximumdirect.net/eric/audita/internal/framework/contracts"
|
2026-05-13 12:13:32 +00:00
|
|
|
"gitea.maximumdirect.net/eric/audita/internal/framework/promptcontext"
|
2026-05-13 18:49:06 +00:00
|
|
|
"gitea.maximumdirect.net/eric/audita/internal/prompts"
|
2026-05-12 02:57:06 +00:00
|
|
|
)
|
|
|
|
|
|
2026-05-12 15:19:50 -05:00
|
|
|
// BuildProposalMessages constrains corrections to punctuation/capitalization/
|
|
|
|
|
// spacing cleanup with strict meaning guards.
|
2026-05-13 12:13:32 +00:00
|
|
|
func BuildProposalMessages(transcript *schema.Transcript, glossary *schema.Glossary, sectionIndex int, transcriptDescription string) ([]contracts.LLMMessage, error) {
|
2026-05-12 02:57:06 +00:00
|
|
|
glossaryJSON, err := json.MarshalIndent(glossary, "", " ")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("marshal glossary prompt context: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 17:56:07 +00:00
|
|
|
sectionJSON, err := promptcontext.MarshalTranscriptSectionJSON(transcript, sectionIndex)
|
2026-05-12 02:57:06 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("marshal transcript prompt context: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-13 18:49:06 +00:00
|
|
|
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDModuleGrammarProposal, map[string]string{
|
|
|
|
|
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
|
|
|
|
"GlossaryJSON": string(glossaryJSON),
|
|
|
|
|
"SectionJSON": string(sectionJSON),
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
2026-05-12 02:57:06 +00:00
|
|
|
|
|
|
|
|
return []contracts.LLMMessage{
|
|
|
|
|
{Role: "system", Content: system},
|
|
|
|
|
{Role: "user", Content: user},
|
|
|
|
|
}, nil
|
|
|
|
|
}
|