93 lines
3.5 KiB
Go
93 lines
3.5 KiB
Go
package validators
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"gitea.maximumdirect.net/eric/audita/internal/framework/promptcontext"
|
|
"gitea.maximumdirect.net/eric/audita/internal/prompts"
|
|
)
|
|
|
|
func BuildSpokenFormPlausibilityMessages(validationPayload []LLMValidationItem, transcriptDescription string) ([]LLMMessage, error) {
|
|
payloadJSON, err := marshalPromptPayload(validationPayload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDValidatorSpokenFormPlausibility, map[string]string{
|
|
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
|
"PayloadJSON": payloadJSON,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return []LLMMessage{{Role: "system", Content: system}, {Role: "user", Content: user}}, nil
|
|
}
|
|
|
|
func BuildMeaningReversalMessages(validationPayload []LLMValidationItem, transcriptDescription string) ([]LLMMessage, error) {
|
|
payloadJSON, err := marshalPromptPayload(validationPayload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDValidatorMeaningReversalReview, map[string]string{
|
|
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
|
"PayloadJSON": payloadJSON,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return []LLMMessage{{Role: "system", Content: system}, {Role: "user", Content: user}}, nil
|
|
}
|
|
|
|
func BuildEditorialMessages(validationPayload []LLMValidationItem, transcriptDescription string) ([]LLMMessage, error) {
|
|
payloadJSON, err := marshalPromptPayload(validationPayload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDValidatorEditorialReview, map[string]string{
|
|
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
|
"PayloadJSON": payloadJSON,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return []LLMMessage{{Role: "system", Content: system}, {Role: "user", Content: user}}, nil
|
|
}
|
|
|
|
func BuildGrammarReviewMessages(validationPayload []LLMValidationItem, transcriptDescription string) ([]LLMMessage, error) {
|
|
payloadJSON, err := marshalPromptPayload(validationPayload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDValidatorGrammarReview, map[string]string{
|
|
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
|
"PayloadJSON": payloadJSON,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return []LLMMessage{{Role: "system", Content: system}, {Role: "user", Content: user}}, nil
|
|
}
|
|
|
|
func BuildSpokenWordReviewMessages(validationPayload []LLMValidationItem, transcriptDescription string) ([]LLMMessage, error) {
|
|
payloadJSON, err := marshalPromptPayload(validationPayload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
system, user, _, err := prompts.RenderUserSystem(prompts.PromptIDValidatorSpokenWordReview, map[string]string{
|
|
"TranscriptDescriptionBlock": promptcontext.TranscriptDescriptionBlock(transcriptDescription),
|
|
"PayloadJSON": payloadJSON,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return []LLMMessage{{Role: "system", Content: system}, {Role: "user", Content: user}}, nil
|
|
}
|
|
|
|
func marshalPromptPayload(validationPayload []LLMValidationItem) (string, error) {
|
|
payloadJSON, err := json.MarshalIndent(validationPayload, "", " ")
|
|
if err != nil {
|
|
return "", fmt.Errorf("marshal validation payload: %w", err)
|
|
}
|
|
return string(payloadJSON), nil
|
|
}
|