textgen

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 4 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

type EnhanceResult struct {
	Content         string
	Title           string
	MetaDescription string
}

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

type TranslateResult struct {
	Content         string
	Title           string
	MetaDescription string
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL