Documentation
¶
Overview ¶
Package infrastructure adapts the themegen domain port onto OpenAI-compatible chat-completion APIs. Prompt construction grounds the model on the active edition's readable sources; response validation stays in the domain's envelope parser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRepairPrompt ¶
func BuildRepairPrompt(brief themegendomain.Brief, themeFiles map[string]string, problems []string) string
BuildRepairPrompt feeds compiler/validation findings back to the model. The brief's style preset rides along so a repair does not drift from the requested look; theme files arrive verbatim (minification happens at install time) so braces and structure stay readable.
func BuildSystemPrompt ¶
func BuildSystemPrompt(sources themegendomain.ThemeSources, templateOverrides bool) string
BuildSystemPrompt assembles the theme generation system prompt from the distilled contract, the edition's readable stylesheet sources, and — when the brief asks for template overrides — the template contract and page sources.
func BuildUserPrompt ¶
BuildUserPrompt assembles the user prompt from the brief and style preset.
Types ¶
type OpenAIThemeService ¶
type OpenAIThemeService struct {
// contains filtered or unexported fields
}
OpenAIThemeService implements themegendomain.ThemeGenerationService over any OpenAI-compatible chat-completion API.
func NewOpenAIThemeService ¶
func NewOpenAIThemeService(apiKey, baseURL, model string) *OpenAIThemeService
NewOpenAIThemeService builds the OpenAI-compatible theme generation service. baseURL is optional ("" = provider default); model names the chat model. Sources and the template-override flag arrive per generation call.
func (*OpenAIThemeService) GenerateTheme ¶
func (s *OpenAIThemeService) GenerateTheme( ctx context.Context, brief themegendomain.Brief, edition themegendomain.Edition, sources themegendomain.ThemeSources, ) (themegendomain.Theme, error)
GenerateTheme asks the model for the JSON envelope and validates it via the domain parser. Files stay verbatim so validation and the repair loop see the model's original output; minification happens at install time. The system prompt is built per call so template overrides and their sources are honored.
func (*OpenAIThemeService) RepairTheme ¶
func (s *OpenAIThemeService) RepairTheme( ctx context.Context, brief themegendomain.Brief, sources themegendomain.ThemeSources, theme themegendomain.Theme, problems []string, ) (themegendomain.Theme, error)
RepairTheme feeds validation problems back to the model (the caller bounds the attempts). The system prompt matches the generation one, so template overrides keep their contract across repairs.