package grammar import ( "encoding/json" "fmt" "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" ) // BuildProposalMessages constrains corrections to punctuation/capitalization/ // spacing cleanup with strict meaning guards. func BuildProposalMessages(transcript *schema.Transcript, glossary *schema.Glossary, sectionIndex int, transcriptDescription string) ([]contracts.LLMMessage, error) { glossaryJSON, err := json.MarshalIndent(glossary, "", " ") if err != nil { return nil, fmt.Errorf("marshal glossary prompt context: %w", err) } sectionJSON, err := promptcontext.MarshalTranscriptSectionJSON(transcript, sectionIndex) if err != nil { return nil, fmt.Errorf("marshal transcript prompt context: %w", err) } 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 } return []contracts.LLMMessage{ {Role: "system", Content: system}, {Role: "user", Content: user}, }, nil }