ai

package
v0.0.0-...-3a228b6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetClientOptions

func SetClientOptions(options ClientOptions)

SetClientOptions allows customization of the HTTP client

Types

type AIAgent

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

func NewAIAgent

func NewAIAgent(provider Provider) *AIAgent

func (*AIAgent) Process

func (a *AIAgent) Process(ctx context.Context, input, prompt string) (string, error)

type BaseProvider

type BaseProvider struct {
	APIKey string
	Model  string
	URL    string
}

func (*BaseProvider) GetEnvOrDefault

func (p *BaseProvider) GetEnvOrDefault(key, defaultValue string) string

type BestPickerCombiner

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

BestPickerCombiner uses an AI provider to select the best result

func NewBestPickerCombiner

func NewBestPickerCombiner(picker Provider) *BestPickerCombiner

BestPickerCombiner implementation

func (*BestPickerCombiner) Combine

func (c *BestPickerCombiner) Combine(ctx context.Context, results []ProviderResponse) (string, error)

type ClaudeAIProvider

type ClaudeAIProvider struct {
	BaseProvider
}

func NewClaudeAIProvider

func NewClaudeAIProvider() (*ClaudeAIProvider, error)

func (*ClaudeAIProvider) GenerateResponse

func (p *ClaudeAIProvider) GenerateResponse(ctx context.Context, prompt string) (string, error)

func (*ClaudeAIProvider) Name

func (p *ClaudeAIProvider) Name() string

type ClientOptions

type ClientOptions struct {
	Timeout       time.Duration
	RetryAttempts int
	RetryDelay    time.Duration
}

ClientOptions holds options for customizing the HTTP client

type ConcatCombiner

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

ConcatCombiner simply concatenates all results

func NewConcatCombiner

func NewConcatCombiner(separator string) *ConcatCombiner

ConcatCombiner implementation

func (*ConcatCombiner) Combine

func (c *ConcatCombiner) Combine(_ context.Context, results []ProviderResponse) (string, error)

type GeminiAIProvider

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

func NewGeminiAIProvider

func NewGeminiAIProvider() (*GeminiAIProvider, error)

func (*GeminiAIProvider) GenerateResponse

func (p *GeminiAIProvider) GenerateResponse(ctx context.Context, prompt string) (string, error)

func (*GeminiAIProvider) Name

func (p *GeminiAIProvider) Name() string

type GrokProvider

type GrokProvider struct {
	BaseProvider
}

func NewGrokProvider

func NewGrokProvider() (*GrokProvider, error)

func (*GrokProvider) GenerateResponse

func (p *GrokProvider) GenerateResponse(ctx context.Context, prompt string) (string, error)

func (*GrokProvider) Name

func (p *GrokProvider) Name() string

type OpenAIProvider

type OpenAIProvider struct {
	BaseProvider
}

func NewOpenAIProvider

func NewOpenAIProvider() (*OpenAIProvider, error)

func (*OpenAIProvider) GenerateResponse

func (p *OpenAIProvider) GenerateResponse(ctx context.Context, prompt string) (string, error)

func (*OpenAIProvider) Name

func (p *OpenAIProvider) Name() string

type ParallelPipeline

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

ParallelPipeline executes multiple providers and combines/selects results

func NewParallelPipeline

func NewParallelPipeline(providers []Provider, combiner ResultCombiner) *ParallelPipeline

func (*ParallelPipeline) Execute

func (p *ParallelPipeline) Execute(ctx context.Context, input string) (string, error)

type Pipeline

type Pipeline interface {
	Execute(ctx context.Context, input string) (string, error)
}

Pipeline represents a sequence of AI operations

type Provider

type Provider interface {
	GenerateResponse(ctx context.Context, prompt string) (string, error)
	Name() string
}

func NewProvider

func NewProvider(name string) (Provider, error)

type ProviderResponse

type ProviderResponse struct {
	ProviderName string
	Content      string
}

ProviderResponse pairs the provider name with its response

type RequestDetails

type RequestDetails struct {
	URL               string
	APIKey            string
	RequestBody       interface{}
	AdditionalHeaders map[string]string
}

RequestDetails holds the details for an HTTP request

type ResultCombiner

type ResultCombiner interface {
	Combine(ctx context.Context, results []ProviderResponse) (string, error)
}

ResultCombiner defines how multiple results should be combined

type SerialPipeline

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

SerialPipeline passes output from one provider to the next

func NewSerialPipeline

func NewSerialPipeline(providers []Provider) *SerialPipeline

func (*SerialPipeline) Execute

func (p *SerialPipeline) Execute(ctx context.Context, input string) (string, error)

Jump to

Keyboard shortcuts

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