llm

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const LLMRawLogFile = ".message_log.txt"

Variables

This section is empty.

Functions

func GetSimpleRawMessageLogger

func GetSimpleRawMessageLogger(perpetualDir string) func(v ...any)

func RenderMessagesToAIStrings added in v1.4.1

func RenderMessagesToAIStrings(filesToMdLangMappings [][2]string, messages []Message) ([]string, error)

Types

type AnthropicLLMConnector

type AnthropicLLMConnector struct {
	Subprofile            string
	BaseURL               string
	Token                 string
	Model                 string
	SystemPrompt          string
	FilesToMdLangMappings [][2]string
	MaxTokensSegments     int
	OnFailRetries         int
	Seed                  int
	RawMessageLogger      func(v ...any)
	Options               []llms.CallOption
	Variants              int
	VariantStrategy       VariantSelectionStrategy
}

func NewAnthropicLLMConnector

func NewAnthropicLLMConnector(subprofile string, token string, model string, systemPrompt string, filesToMdLangMappings [][2]string, customBaseURL string, maxTokensSegments int, onFailRetries int, seed int, llmRawMessageLogger func(v ...any), options []llms.CallOption, variants int, variantStrategy VariantSelectionStrategy) *AnthropicLLMConnector

func NewAnthropicLLMConnectorFromEnv

func NewAnthropicLLMConnectorFromEnv(subprofile string, operation string, systemPrompt string, filesToMdLangMappings [][2]string, llmRawMessageLogger func(v ...any)) (*AnthropicLLMConnector, error)

func (*AnthropicLLMConnector) GetDebugString added in v1.9.0

func (p *AnthropicLLMConnector) GetDebugString() string

func (*AnthropicLLMConnector) GetMaxTokensSegments added in v1.4.1

func (p *AnthropicLLMConnector) GetMaxTokensSegments() int

func (*AnthropicLLMConnector) GetOnFailureRetryLimit added in v1.4.1

func (p *AnthropicLLMConnector) GetOnFailureRetryLimit() int

func (*AnthropicLLMConnector) GetOptionsString added in v1.4.1

func (p *AnthropicLLMConnector) GetOptionsString() string

func (*AnthropicLLMConnector) GetVariantCount added in v1.9.0

func (p *AnthropicLLMConnector) GetVariantCount() int

func (*AnthropicLLMConnector) GetVariantSelectionStrategy added in v1.9.0

func (p *AnthropicLLMConnector) GetVariantSelectionStrategy() VariantSelectionStrategy

func (*AnthropicLLMConnector) Query

func (p *AnthropicLLMConnector) Query(maxCandidates int, messages ...Message) ([]string, QueryStatus, error)

type Fragment

type Fragment struct {
	Type         FragmentType
	Contents     string
	FileName     string
	FileNameTags string
}

type FragmentType

type FragmentType int
const (
	PlainTextFragment FragmentType = iota
	IndexFragment
	FileFragment
	TaggedFragment
	MultilineTaggedFragment
)

type LLMConnector

type LLMConnector interface {
	// Main interaction point with LLM
	Query(maxCandidates int, messages ...Message) ([]string, QueryStatus, error)
	// When response bumps max token limit, try to continue generating next segment, until reaching this limit
	GetMaxTokensSegments() int
	GetOnFailureRetryLimit() int
	GetDebugString() string
	// Results variant-count management.
	GetVariantCount() int
	GetVariantSelectionStrategy() VariantSelectionStrategy
}

func NewLLMConnector

func NewLLMConnector(operation string, systemPrompt string, filesToMdLangMappings [][2]string, llmRawMessageLogger func(v ...any)) (LLMConnector, error)

type Message

type Message struct {
	Type      MessageType
	Fragments []Fragment
	RawText   string
}

func AddFileFragment

func AddFileFragment(message Message, filename string, contents string, tags []string) Message

func AddIndexFragment

func AddIndexFragment(message Message, filename string, tags []string) Message

func AddMultilineTaggedFragment

func AddMultilineTaggedFragment(message Message, multilineContent string, tags []string) Message

func AddPlainTextFragment

func AddPlainTextFragment(message Message, text string) Message

func AddTaggedFragment

func AddTaggedFragment(message Message, contents string, tags []string) Message

func NewMessage

func NewMessage(messageType MessageType) Message

func SetRawResponse

func SetRawResponse(message Message, rawResponse string) Message

type MessageType

type MessageType int
const (
	UserRequest MessageType = iota
	SimulatedAIResponse
	RealAIResponse
)

type OllamaLLMConnector added in v1.4.1

type OllamaLLMConnector struct {
	Subprofile            string
	BaseURL               string
	Model                 string
	SystemPrompt          string
	FilesToMdLangMappings [][2]string
	MaxTokensSegments     int
	OnFailRetries         int
	Seed                  int
	RawMessageLogger      func(v ...any)
	Options               []llms.CallOption
	Variants              int
	VariantStrategy       VariantSelectionStrategy
}

func NewOllamaLLMConnector added in v1.4.1

func NewOllamaLLMConnector(subprofile string, model string, systemPrompt string, filesToMdLangMappings [][2]string, customBaseURL string, maxTokensSegments int, onFailRetries int, seed int, llmRawMessageLogger func(v ...any), options []llms.CallOption, variants int, variantStrategy VariantSelectionStrategy) *OllamaLLMConnector

func NewOllamaLLMConnectorFromEnv added in v1.4.1

func NewOllamaLLMConnectorFromEnv(subprofile string, operation string, systemPrompt string, filesToMdLangMappings [][2]string, llmRawMessageLogger func(v ...any)) (*OllamaLLMConnector, error)

func (*OllamaLLMConnector) GetDebugString added in v1.9.0

func (p *OllamaLLMConnector) GetDebugString() string

func (*OllamaLLMConnector) GetMaxTokensSegments added in v1.4.1

func (p *OllamaLLMConnector) GetMaxTokensSegments() int

func (*OllamaLLMConnector) GetOnFailureRetryLimit added in v1.4.1

func (p *OllamaLLMConnector) GetOnFailureRetryLimit() int

func (*OllamaLLMConnector) GetOptionsString added in v1.4.1

func (p *OllamaLLMConnector) GetOptionsString() string

func (*OllamaLLMConnector) GetVariantCount added in v1.9.0

func (p *OllamaLLMConnector) GetVariantCount() int

func (*OllamaLLMConnector) GetVariantSelectionStrategy added in v1.9.0

func (p *OllamaLLMConnector) GetVariantSelectionStrategy() VariantSelectionStrategy

func (*OllamaLLMConnector) Query added in v1.4.1

func (p *OllamaLLMConnector) Query(maxCandidates int, messages ...Message) ([]string, QueryStatus, error)

type OpenAILLMConnector

type OpenAILLMConnector struct {
	Subprofile            string
	BaseURL               string
	Token                 string
	Model                 string
	SystemPrompt          string
	FilesToMdLangMappings [][2]string
	MaxTokensSegments     int
	OnFailRetries         int
	RawMessageLogger      func(v ...any)
	Options               []llms.CallOption
	Variants              int
	VariantStrategy       VariantSelectionStrategy
}

func NewOpenAILLMConnector

func NewOpenAILLMConnector(subprofile string, token string, model string, systemPrompt string, filesToMdLangMappings [][2]string, customBaseURL string, maxTokensSegments int, onFailRetries int, llmRawMessageLogger func(v ...any), options []llms.CallOption, variants int, variantStrategy VariantSelectionStrategy) *OpenAILLMConnector

func NewOpenAILLMConnectorFromEnv

func NewOpenAILLMConnectorFromEnv(subprofile string, operation string, systemPrompt string, filesToMdLangMappings [][2]string, llmRawMessageLogger func(v ...any)) (*OpenAILLMConnector, error)

func (*OpenAILLMConnector) GetDebugString added in v1.9.0

func (p *OpenAILLMConnector) GetDebugString() string

func (*OpenAILLMConnector) GetMaxTokensSegments added in v1.4.1

func (p *OpenAILLMConnector) GetMaxTokensSegments() int

func (*OpenAILLMConnector) GetOnFailureRetryLimit added in v1.4.1

func (p *OpenAILLMConnector) GetOnFailureRetryLimit() int

func (*OpenAILLMConnector) GetOptionsString added in v1.4.1

func (p *OpenAILLMConnector) GetOptionsString() string

func (*OpenAILLMConnector) GetVariantCount added in v1.9.0

func (p *OpenAILLMConnector) GetVariantCount() int

func (*OpenAILLMConnector) GetVariantSelectionStrategy added in v1.9.0

func (p *OpenAILLMConnector) GetVariantSelectionStrategy() VariantSelectionStrategy

func (*OpenAILLMConnector) Query

func (p *OpenAILLMConnector) Query(maxCandidates int, messages ...Message) ([]string, QueryStatus, error)

type QueryStatus

type QueryStatus int
const (
	QueryOk QueryStatus = iota
	QueryInitFailed
	QueryMaxTokens
	QueryFailed
)

type VariantSelectionStrategy added in v1.9.0

type VariantSelectionStrategy int
const (
	Short VariantSelectionStrategy = iota
	Long
	Combine
)

Jump to

Keyboard shortcuts

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