llm

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultModel

func DefaultModel(model string) string

DefaultModel returns the default model name for the given provider. When model is empty, auto-detects based on available API keys.

func FileOutputName

func FileOutputName(guideName string) string

FileOutputName returns the output file name for a given template guide name.

func NewProvider

func NewProvider(ctx context.Context, model string, apiKey string, progressOut io.Writer) (service.LLMProvider, error)

NewProvider creates the appropriate LLMProvider based on the model name. If model starts with "gemini-", uses Google Gemini. If model starts with "claude-" or is explicitly set, uses Anthropic. If model is empty, auto-detects provider from the API key.

func ResolveAPIKey

func ResolveAPIKey(model string) (string, error)

ResolveAPIKey returns the API key for the given model from the appropriate env var. For Gemini models, checks GEMINI_API_KEY then GOOGLE_API_KEY. For Anthropic models, checks ANTHROPIC_API_KEY. When no model is specified (empty string), tries Anthropic first, then Gemini.

Types

type AnthropicProvider

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

AnthropicProvider implements service.LLMProvider using the Anthropic Claude API.

func NewAnthropicProvider

func NewAnthropicProvider(apiKey string, model string, progressOut io.Writer) *AnthropicProvider

NewAnthropicProvider creates a new AnthropicProvider. If apiKey is empty, the SDK will use the ANTHROPIC_API_KEY env var. If model is empty, defaults to claude-sonnet-4-6. If progressOut is non-nil, progress messages will be written to it.

func (*AnthropicProvider) GenerateContext

GenerateContext generates all context files by making one API call per file. This avoids JSON truncation issues and provides per-file progress.

type GeminiProvider

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

GeminiProvider implements service.LLMProvider using the Google Gemini API.

func NewGeminiProvider

func NewGeminiProvider(ctx context.Context, apiKey string, model string, progressOut io.Writer) (*GeminiProvider, error)

NewGeminiProvider creates a new GeminiProvider. If apiKey is empty, the SDK will use the GEMINI_API_KEY or GOOGLE_API_KEY env var. If model is empty, defaults to gemini-3.1-pro-preview. If progressOut is non-nil, progress messages will be written to it.

func (*GeminiProvider) GenerateContext

GenerateContext generates all context files by making one API call per file.

type PromptBuilder

type PromptBuilder struct{}

PromptBuilder constructs prompts for the LLM from templates and project description.

func NewPromptBuilder

func NewPromptBuilder() *PromptBuilder

NewPromptBuilder creates a new PromptBuilder.

func (*PromptBuilder) BuildClaudeWorkflowSystemPrompt added in v1.14.0

func (b *PromptBuilder) BuildClaudeWorkflowSystemPrompt(workflowName, locale, projectContext string) string

BuildClaudeWorkflowSystemPrompt returns a system prompt for generating Claude Code workflow skills. Translates Antigravity execution annotations to prose instructions for Claude's SKILL.md format.

func (*PromptBuilder) BuildPersonalizedSkillsSystemPrompt added in v1.10.0

func (b *PromptBuilder) BuildPersonalizedSkillsSystemPrompt(skillName, target, locale, projectContext string) string

BuildPersonalizedSkillsSystemPrompt returns a system prompt for generating personalized Agent Skills. Unlike the generic version, this prompt instructs the LLM to adapt the skill to the user's project.

func (*PromptBuilder) BuildPersonalizedWorkflowsSystemPrompt added in v1.13.0

func (b *PromptBuilder) BuildPersonalizedWorkflowsSystemPrompt(workflowName, locale, projectContext string) string

BuildPersonalizedWorkflowsSystemPrompt returns a system prompt for generating personalized Antigravity workflows.

func (*PromptBuilder) BuildSkillsUserMessage

func (b *PromptBuilder) BuildSkillsUserMessage(guide service.TemplateGuide, target string) string

BuildSkillsUserMessage constructs the user message for generating a single skill.

func (*PromptBuilder) BuildSpecSystemPrompt

func (b *PromptBuilder) BuildSpecSystemPrompt(existingContext string, locale string) string

BuildSpecSystemPrompt returns a system prompt for generating spec files from existing context.

func (*PromptBuilder) BuildSystemPromptForFile

func (b *PromptBuilder) BuildSystemPromptForFile(guideName string, locale string) string

BuildSystemPromptForFile returns a system prompt for generating a single context file.

func (*PromptBuilder) BuildUserMessageForFile

func (b *PromptBuilder) BuildUserMessageForFile(req service.GenerationRequest, guide service.TemplateGuide) string

BuildUserMessageForFile constructs the user message for generating a single file.

func (*PromptBuilder) BuildWorkflowsUserMessage added in v1.13.0

func (b *PromptBuilder) BuildWorkflowsUserMessage(guide service.TemplateGuide, target string) string

BuildWorkflowsUserMessage constructs the user message for generating a single workflow.

Jump to

Keyboard shortcuts

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