llms

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultTemperature = 0.0
View Source
const InvalidLLMModelError = "llm model is not set or is invalid"
View Source
const OpenAIAPIKeyNotSetError = "ZEP_OPENAI_API_KEY is not set" //nolint:gosec

Variables

View Source
var MaxLLMTokensMap = map[string]int{
	"gpt-3.5-turbo":     4096,
	"gpt-3.5-turbo0301": 8192,
	"gpt-4":             8192,
}
View Source
var ValidLLMMap = map[string]bool{
	"gpt-3.5-turbo":     true,
	"gpt-3.5-turbo0301": true,
	"gpt-4":             true,
}

Functions

func CreateOpenAIClient

func CreateOpenAIClient(cfg *config.Config) *openai.Client

func EmbedMessages

func EmbedMessages(
	ctx context.Context,
	appState *models.AppState,
	text []string,
) (*[]openai.Embedding, error)

func GetLLMModelName

func GetLLMModelName(cfg *config.Config) (string, error)

func GetTokenCount

func GetTokenCount(text string) (int, error)

func RunChatCompletion

func RunChatCompletion(
	ctx context.Context,
	appState *models.AppState,
	summaryMaxTokens int,
	prompt string,
) (openai.ChatCompletionResponse, error)

Types

type LLMError

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

func NewLLMError

func NewLLMError(message string, originalError error) *LLMError

func (*LLMError) Error

func (e *LLMError) Error() string

Jump to

Keyboard shortcuts

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