llm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FeatureScriptPrompt is used to generate the main feature script
	FeatureScriptPrompt = `` /* 1032-byte string literal not displayed */

	// TestScriptPrompt is used to generate the test script
	TestScriptPrompt = `` /* 1538-byte string literal not displayed */

	// FixScriptPrompt is used to fix a script based on test failures
	FixScriptPrompt = `` /* 915-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func ExtractScriptContent added in v0.0.3

func ExtractScriptContent(response string) string

ExtractScriptContent extracts the content between <script> tags from an LLM response. If no <script> tags are found, returns the entire response.

func GetPlatformInfo

func GetPlatformInfo() string

GetPlatformInfo returns information about the current platform

Types

type BaseProvider

type BaseProvider struct {
	Config interface{}
}

BaseProvider provides common functionality for LLM providers

func (*BaseProvider) FixScript

func (p *BaseProvider) FixScript(ctx context.Context, script string, failures []TestFailure) (string, error)

FixScript is a default implementation that returns an error

func (*BaseProvider) FixScripts

func (p *BaseProvider) FixScripts(ctx context.Context, scripts ScriptPair, error string) (ScriptPair, error)

FixScripts attempts to fix a script pair based on test failures

func (*BaseProvider) GenerateScript

func (p *BaseProvider) GenerateScript(ctx context.Context, description string) (string, error)

GenerateScript is a default implementation that returns an error

func (*BaseProvider) GenerateScripts

func (p *BaseProvider) GenerateScripts(ctx context.Context, description string) (ScriptPair, error)

GenerateScripts generates a main script and test script pair

func (*BaseProvider) GenerateTests

func (p *BaseProvider) GenerateTests(ctx context.Context, script string, description string) ([]Test, error)

GenerateTests is a default implementation that returns an error

func (*BaseProvider) Name added in v0.0.3

func (p *BaseProvider) Name() string

Name returns a human-readable name for the provider

func (*BaseProvider) ValidateConfig

func (p *BaseProvider) ValidateConfig() error

ValidateConfig validates the provider configuration

type ClaudeConfig

type ClaudeConfig struct {
	APIKey string `yaml:"api_key"`
	Model  string `yaml:"model"`
}

ClaudeConfig represents configuration for the Claude provider

type ClaudeProvider

type ClaudeProvider struct {
	BaseProvider
	// contains filtered or unexported fields
}

ClaudeProvider implements the Provider interface using Anthropic's Claude

func NewClaudeProvider

func NewClaudeProvider(config ClaudeConfig) (*ClaudeProvider, error)

NewClaudeProvider creates a new Claude provider

func (*ClaudeProvider) FixScript

func (p *ClaudeProvider) FixScript(ctx context.Context, script string, failures []TestFailure) (string, error)

FixScript attempts to fix a script based on test failures

func (*ClaudeProvider) FixScripts

func (p *ClaudeProvider) FixScripts(ctx context.Context, scripts ScriptPair, error string) (ScriptPair, error)

FixScripts attempts to fix both scripts based on test failures

func (*ClaudeProvider) GenerateScript

func (p *ClaudeProvider) GenerateScript(ctx context.Context, description string) (string, error)

GenerateScript creates a shell script from a natural language description

func (*ClaudeProvider) GenerateScripts

func (p *ClaudeProvider) GenerateScripts(ctx context.Context, description string) (ScriptPair, error)

GenerateScripts creates a main script and test script from a natural language description

func (*ClaudeProvider) GenerateTests

func (p *ClaudeProvider) GenerateTests(ctx context.Context, script string, description string) ([]Test, error)

GenerateTests creates test cases for a script based on its description

func (*ClaudeProvider) Name added in v0.0.3

func (p *ClaudeProvider) Name() string

Name returns a human-readable name for the provider

type OllamaConfig

type OllamaConfig struct {
	Model string `yaml:"model"`
	Host  string `yaml:"host"`
}

OllamaConfig represents configuration for the Ollama provider

type OllamaProvider

type OllamaProvider struct {
	BaseProvider
	// contains filtered or unexported fields
}

OllamaProvider implements the Provider interface using Ollama

func NewOllamaProvider

func NewOllamaProvider(config OllamaConfig) (*OllamaProvider, error)

NewOllamaProvider creates a new Ollama provider

func (*OllamaProvider) FixScripts

func (p *OllamaProvider) FixScripts(ctx context.Context, scripts ScriptPair, error string) (ScriptPair, error)

FixScripts attempts to fix both scripts based on test failures

func (*OllamaProvider) GenerateScripts

func (p *OllamaProvider) GenerateScripts(ctx context.Context, description string) (ScriptPair, error)

GenerateScripts creates a main script and test script from a natural language description

func (*OllamaProvider) Name added in v0.0.3

func (p *OllamaProvider) Name() string

Name returns a human-readable name for the provider

type OpenAIConfig

type OpenAIConfig struct {
	APIKey string `yaml:"api_key"`
	Model  string `yaml:"model"`
}

OpenAIConfig represents configuration for the OpenAI provider

type OpenAIProvider

type OpenAIProvider struct {
	BaseProvider
	// contains filtered or unexported fields
}

OpenAIProvider implements the Provider interface using OpenAI's API

func NewOpenAIProvider

func NewOpenAIProvider(config OpenAIConfig) (*OpenAIProvider, error)

NewOpenAIProvider creates a new OpenAI provider

func (*OpenAIProvider) FixScript

func (p *OpenAIProvider) FixScript(ctx context.Context, script string, failures []TestFailure) (string, error)

FixScript attempts to fix a script based on test failures

func (*OpenAIProvider) FixScripts

func (p *OpenAIProvider) FixScripts(ctx context.Context, scripts ScriptPair, error string) (ScriptPair, error)

FixScripts attempts to fix both scripts based on test failures

func (*OpenAIProvider) GenerateScript

func (p *OpenAIProvider) GenerateScript(ctx context.Context, description string) (string, error)

GenerateScript creates a shell script from a natural language description

func (*OpenAIProvider) GenerateScripts

func (p *OpenAIProvider) GenerateScripts(ctx context.Context, description string) (ScriptPair, error)

GenerateScripts creates a main script and test script from a natural language description

func (*OpenAIProvider) GenerateTests

func (p *OpenAIProvider) GenerateTests(ctx context.Context, script string, description string) ([]Test, error)

GenerateTests creates test cases for a script based on its description

func (*OpenAIProvider) Name added in v0.0.3

func (p *OpenAIProvider) Name() string

Name returns a human-readable name for the provider

type Provider

type Provider interface {
	// GenerateScripts creates a main script and test script from a natural language description
	GenerateScripts(ctx context.Context, description string) (ScriptPair, error)
	// FixScripts attempts to fix both scripts based on test failures
	FixScripts(ctx context.Context, scripts ScriptPair, error string) (ScriptPair, error)
	// Name returns a human-readable name for the provider
	Name() string
}

Provider defines the interface for LLM providers

func NewProvider

func NewProvider(name string, config interface{}) (Provider, error)

NewProvider creates a new LLM provider based on the provider name

type ProviderConfig

type ProviderConfig struct {
	Provider string       `yaml:"provider"`
	Ollama   OllamaConfig `yaml:"ollama,omitempty"`
	Claude   ClaudeConfig `yaml:"claude,omitempty"`
	OpenAI   OpenAIConfig `yaml:"openai,omitempty"`
}

ProviderConfig represents the configuration for any LLM provider

type ScriptPair

type ScriptPair struct {
	MainScript string // The feature script that implements the functionality
	TestScript string // The test script that verifies the feature script
}

ScriptPair represents a feature script and its test script

type Test

type Test struct {
	Name        string
	Setup       []string
	Input       string
	Expected    string
	Timeout     time.Duration
	Environment map[string]string
}

Test represents a test case for a script

type TestFailure

type TestFailure struct {
	Test     Test
	Output   string
	Error    error
	ExitCode int
}

TestFailure represents a failed test case

Jump to

Keyboard shortcuts

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