infrastructure

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: 8 Imported by: 1 module, 0 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 infrastructure adapts the text module's domain port onto OpenAI-compatible chat-completion APIs. Prompt construction and transport live here; response validation stays in the domain's envelope parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenAITextService

type OpenAITextService struct {
	// contains filtered or unexported fields
}

OpenAITextService implements textgendomain.TextGenerationService using any OpenAI-compatible API. The HTML system prompt is held behind an atomic pointer so RefreshThemeStyles can hot-apply a new theme's styles while generations are in flight.

func NewOpenAITextService

func NewOpenAITextService(apiKey, baseURL, model, themeBaseCSS, themeStyleCSS string) *OpenAITextService

NewOpenAITextService creates a new OpenAI-compatible text generation service. baseURL is optional — pass "" to use the OpenAI default. model is the chat model name (e.g. "gpt-5-mini", "gpt-5.4-mini", "openai/gpt-5-mini" for OpenRouter). themeBaseCSS and themeStyleCSS are the active theme's minified base.css (design tokens) and style.css (component styles). When non-empty, they are injected into the HTML generation prompt so output reuses the site's brand tokens and component classes instead of inventing off-brand styles. Pass empty strings when no theme is available (the embedded defaults are still a reasonable brief).

func (*OpenAITextService) EnhanceText

func (s *OpenAITextService) EnhanceText(
	ctx context.Context,
	content, format, mediaContext string,
) (textgendomain.EnhanceResult, error)

EnhanceText takes existing content and returns an enhanced version with AI-generated SEO metadata. format controls the output format: "tiptap" (default) or "html". mediaContext is an optional string of available images injected into the prompt for HTML generation.

func (*OpenAITextService) EnhanceTranscription added in v1.2.1

func (s *OpenAITextService) EnhanceTranscription(
	ctx context.Context,
	transcript string,
) (textgendomain.EnhanceResult, error)

EnhanceTranscription turns a raw speech-to-text transcript into a polished TipTap document with AI-generated SEO metadata. Spoken formatting cues ("heading two", "bullet list", ...) are applied as structure by the dictation prompt; the JSON envelope is validated like enhancement.

func (*OpenAITextService) RefreshThemeStyles added in v1.5.0

func (s *OpenAITextService) RefreshThemeStyles(themeBaseCSS, themeStyleCSS string)

RefreshThemeStyles rebuilds the HTML system prompt from the active theme's styles so later generations follow the new brand without a restart. Safe for concurrent use with in-flight generations.

func (*OpenAITextService) TranslateText

func (s *OpenAITextService) TranslateText(
	ctx context.Context,
	content, title, metaDescription, sourceLang, targetLang, format string,
) (textgendomain.TranslateResult, error)

TranslateText translates content from sourceLang to targetLang, along with its SEO title and meta description. An empty metaDescription asks the AI to write a fresh summary for the target language instead. format controls the output format: "tiptap" (default) or "html".

Jump to

Keyboard shortcuts

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