llm_provider

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TestProviderExpectedMessage = "Hello, world!"

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicLLMProvider

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

func NewAnthropicLLMProvider

func NewAnthropicLLMProvider(apiKey string, model string) *AnthropicLLMProvider

func (*AnthropicLLMProvider) GetCompletion

func (p *AnthropicLLMProvider) GetCompletion(
	fullSystemMessage string,
	messages []Message,
	handleTokens func(tokens string) error,
) error

type LLMProvider

type LLMProvider interface {
	// Get a completion from an LLM. The function should pass the system message
	// (already including the context) to the LLM.
	GetCompletion(
		fullSystemMessage string,
		messages []Message,
		handleTokens func(tokens string) error,
	) error
}

A provider should act as a proxy to some LLM provider, such as "openai", "anthropic" or different. Its only task is to implement the GetCompletion function.

func ResolveFromConfig

func ResolveFromConfig(conf *config.Config) (LLMProvider, error)

type Message

type Message struct {
	Role    string
	Content string
}

type OpenAILLMProvider

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

func NewOpenAILLMProvider

func NewOpenAILLMProvider(apiKey string, model string) *OpenAILLMProvider

func (*OpenAILLMProvider) GetCompletion

func (p *OpenAILLMProvider) GetCompletion(
	fullSystemMessage string,
	messages []Message,
	handleTokens func(tokens string) error,
) error

type TestLLMProvider

type TestLLMProvider struct{}

func (*TestLLMProvider) GetCompletion

func (p *TestLLMProvider) GetCompletion(
	fullSystemMessage string,
	messages []Message,
	handleTokens func(tokens string) error,
) error

Jump to

Keyboard shortcuts

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