llm

package
v0.0.0-...-ab17b8d Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package llm contains the language model provider interface and its implementations.

Index

Constants

View Source
const (
	// DefaultPromptTemplate is the default template for generating a prompt
	DefaultPromptTemplate = `` /* 525-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Documents

type Documents struct {
	Title    string
	Content  string
	Metadata map[string]string
	URL      string
}

Documents is a struct that represents a document

type Fake

type Fake struct {
}

Fake is a fake language model provider

func (*Fake) GetResponse

func (f *Fake) GetResponse(_ Prompt) (string, error)

GetResponse returns a response from the language model provider

func (*Fake) HealthCheck

func (f *Fake) HealthCheck() error

HealthCheck checks the health of the language model provider

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface for an HTTP client

type LLM

type LLM interface {
	HealthCheck() error
	GetResponse(prompt Prompt) (string, error)
}

LLM is an interface for a language model provider

func InitializeLLMProvider

func InitializeLLMProvider(ctx context.Context, st storage.Storage, logging *logrus.Logger) (LLM, error)

InitializeLLMProvider initializes the LLM provider

type LLMMock

type LLMMock struct {
	mock.Mock
}

func (*LLMMock) GetResponse

func (_m *LLMMock) GetResponse(prompt Prompt) (string, error)

type Manager

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

func NewManager

func NewManager(storage storage.Storage, logger *logrus.Logger, aclManager auth.ACLManager) *Manager

func (*Manager) RegisterRoutes

func (m *Manager) RegisterRoutes(r chi.Router)

type NoOpsLLM

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

NoOpsLLM is a language model provider that does nothing

func NewNoOpsLLM

func NewNoOpsLLM(settings *types.NoOpLLMProviderSettings) *NoOpsLLM

NewNoOpsLLM creates a new NoOpsLLM with the given settings

func (*NoOpsLLM) GetResponse

func (n *NoOpsLLM) GetResponse(_ Prompt) (string, error)

GetResponse returns a response from the language model provider

func (*NoOpsLLM) HealthCheck

func (n *NoOpsLLM) HealthCheck() error

HealthCheck checks the health of the language model provider

type OpenAILLM

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

OpenAILLM is a language model provider that uses OpenAI to generate responses

func NewOpenAILLM

func NewOpenAILLM(settings *types.OpenAILLMSettings, client HTTPClient, logging *logrus.Logger) *OpenAILLM

NewOpenAILLM creates a new OpenAILLM with the given settings

func (*OpenAILLM) GetResponse

func (o *OpenAILLM) GetResponse(prompt Prompt) (string, error)

GetResponse returns a response from the language model provider

func (*OpenAILLM) HealthCheck

func (o *OpenAILLM) HealthCheck() error

HealthCheck checks the health of the language model provider

type Prompt

type Prompt struct {
	Text string
}

Prompt is a struct that represents a prompt

type PromptGenerator

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

PromptGenerator is a struct that generates prompts

func NewPromptGenerator

func NewPromptGenerator(logger *logrus.Logger, template PromptTemplate) *PromptGenerator

NewPromptGenerator creates a new prompt generator with the given logger and template

func (*PromptGenerator) GeneratePrompt

func (p *PromptGenerator) GeneratePrompt(data PromptTemplateData) (Prompt, error)

GeneratePrompt generates a prompt with the given data

type PromptTemplate

type PromptTemplate struct {
	Template string
}

PromptTemplate is a struct that represents a prompt template

type PromptTemplateData

type PromptTemplateData struct {
	Query                 string
	Documents             []Documents
	ConversationHistories []types.Conversation
}

PromptTemplateData is the data used to generate a prompt

Jump to

Keyboard shortcuts

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