llm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIResponse

type AIResponse struct {
	Choices []*Choice `json:"choices"`
	Usage   AIUsage   `json:"usage"`
}

type AIUsage

type AIUsage struct {
	PromptTokens     int `json:"promptTokens"`
	CompletionTokens int `json:"completionTokens"`
	TotalTokens      int `json:"totalTokens"`
}

type CallOption

type CallOption func(*CallOptions)

CallOption is a function that configures a CallOptions

func WithLang

func WithLang(lang string) CallOption

func WithMaxTokens

func WithMaxTokens(maxTokens int) CallOption

WithMaxTokens is an option for LLM.Call.

func WithModel

func WithModel(model string) CallOption

WithModel is an option for LLM.Call.

func WithOptions

func WithOptions(options CallOptions) CallOption

WithOptions is an option for LLM.Call.

func WithStopWords

func WithStopWords(stopWords []string) CallOption

WithStopWords is an option for LLM.Call.

func WithTemperature

func WithTemperature(temperature float64) CallOption

WithTemperature is an option for LLM.Call.

type CallOptions

type CallOptions struct {
	// Model is the models to use.
	Model string `json:"models"`
	// MaxTokens is the maximum number of tokens to generate.
	MaxTokens int `json:"maxTokens"`
	// Temperature is the temperature for sampling, between 0 and 1.
	Temperature float64 `json:"temperature"`
	// StopWords is a list of words to stop on.
	StopWords []string `json:"stopWords"`
	// Lang is the programming language type.
	Lang string `json:"lang"`
}

CallOptions is a set of options for LLM.Call.

type Choice

type Choice struct {
	// Text is the generated text.
	Text string `json:"text"`
	// Info is the generation info, contains specific information.
	Info map[string]any `json:"info"`
}

type LLM

type LLM interface {
	Call(ctx context.Context, prompt string, options ...CallOption) (string, error)
	Generate(ctx context.Context, prompts []string, options ...CallOption) (*AIResponse, error)
}

LLM is a Large Language Model.

Directories

Path Synopsis
model

Jump to

Keyboard shortcuts

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