Documentation
¶
Overview ¶
Package textgen is the AI text module's domain layer: the text-generation port, its result value types, and the parser that validates the model's JSON envelope. Provider adapters (the OpenAI-compatible client) live in the module's infrastructure package and implement the port.
Index ¶
Constants ¶
const ( // FormatTiptap is the canonical rich-text format: the generated body is a // TipTap JSON document. FormatTiptap = "tiptap" // FormatHTML is the HTML format: the generated body is an HTML fragment. FormatHTML = "html" )
Variables ¶
This section is empty.
Functions ¶
func ParseMetadataEnvelope ¶
func ParseMetadataEnvelope(responseText, format string) (content, title, metaDescription string, err error)
ParseMetadataEnvelope validates an AI response envelope carrying generated content plus SEO metadata and splits it into its parts. The title is required; the meta description is optional and may be empty. For FormatHTML, content must be a non-empty string; otherwise it must be a valid TipTap document object.
Types ¶
type EnhanceResult ¶
EnhanceResult is the outcome of enhancing rich-text content: the enhanced body document plus AI-generated SEO metadata. Title and MetaDescription are populated for the tiptap format only; HTML generation fills Content.
func NewEnhanceResult ¶
func NewEnhanceResult( content, title, metaDescription string, ) EnhanceResult
NewEnhanceResult assembles an enhance outcome from its generated parts.
func ParseEnhanceEnvelope ¶
func ParseEnhanceEnvelope(responseText string) (EnhanceResult, error)
ParseEnhanceEnvelope validates the AI's enhance response and splits it into the enhanced TipTap document and its SEO metadata. The title and the document are required; the meta description is optional and may be empty.
type TextGenerationService ¶
type TextGenerationService interface {
EnhanceText(
ctx context.Context,
content, format, mediaContext string,
) (EnhanceResult, error)
TranslateText(
ctx context.Context,
content, title, metaDescription, sourceLang, targetLang, format string,
) (TranslateResult, error)
EnhanceTranscription(
ctx context.Context,
transcript string,
) (EnhanceResult, error)
}
TextGenerationService defines the interface for AI text generation services.
type TranslateResult ¶
TranslateResult is the outcome of translating content: the translated body plus translated SEO metadata. Title and MetaDescription are populated for both the tiptap and html formats.
func NewTranslateResult ¶
func NewTranslateResult( content, title, metaDescription string, ) TranslateResult
NewTranslateResult assembles a translate outcome from its generated parts.