chatmodel

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package chatmodel provides functionalities for working with Large Language Models (LLMs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anthropic

type Anthropic struct {
	schema.Tokenizer
	// contains filtered or unexported fields
}

func NewAnthropic

func NewAnthropic(apiKey string, optFns ...func(o *AnthropicOptions)) (*Anthropic, error)

func (*Anthropic) Callbacks

func (cm *Anthropic) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the model.

func (*Anthropic) Generate

func (cm *Anthropic) Generate(ctx context.Context, messages schema.ChatMessages, optFns ...func(o *schema.GenerateOptions)) (*schema.ModelResult, error)

func (*Anthropic) InvocationParams added in v0.0.27

func (cm *Anthropic) InvocationParams() map[string]any

InvocationParams returns the parameters used in the model invocation.

func (*Anthropic) Type

func (cm *Anthropic) Type() string

Type returns the type of the model.

func (*Anthropic) Verbose

func (cm *Anthropic) Verbose() bool

Verbose returns the verbosity setting of the model.

type AnthropicOptions

type AnthropicOptions struct {
	*schema.CallbackOptions
	Tokenizer schema.Tokenizer
	// Model name to use.
	ModelName string
	// Denotes the number of tokens to predict per generation.
	MaxTokens int
}

type AzureOpenAIOptions added in v0.0.26

type AzureOpenAIOptions struct {
	OpenAIOptions
	Deployment string
}

type Fake added in v0.0.14

type Fake struct {
	schema.Tokenizer
	// contains filtered or unexported fields
}

func NewFake added in v0.0.14

func NewFake(response string) *Fake

func (*Fake) Callbacks added in v0.0.14

func (cm *Fake) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the model.

func (*Fake) Generate added in v0.0.14

func (cm *Fake) Generate(ctx context.Context, messages schema.ChatMessages, optFns ...func(o *schema.GenerateOptions)) (*schema.ModelResult, error)

func (*Fake) InvocationParams added in v0.0.27

func (cm *Fake) InvocationParams() map[string]any

InvocationParams returns the parameters used in the model invocation.

func (*Fake) Type added in v0.0.14

func (cm *Fake) Type() string

Type returns the type of the model.

func (*Fake) Verbose added in v0.0.14

func (cm *Fake) Verbose() bool

Verbose returns the verbosity setting of the model.

type OpenAI

type OpenAI struct {
	schema.Tokenizer
	// contains filtered or unexported fields
}

func NewAzureOpenAI added in v0.0.26

func NewAzureOpenAI(apiKey, baseURL string, optFns ...func(o *AzureOpenAIOptions)) (*OpenAI, error)

func NewOpenAI

func NewOpenAI(apiKey string, optFns ...func(o *OpenAIOptions)) (*OpenAI, error)

func (*OpenAI) Callbacks

func (cm *OpenAI) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the model.

func (*OpenAI) Generate

func (cm *OpenAI) Generate(ctx context.Context, messages schema.ChatMessages, optFns ...func(o *schema.GenerateOptions)) (*schema.ModelResult, error)

func (*OpenAI) InvocationParams added in v0.0.27

func (cm *OpenAI) InvocationParams() map[string]any

InvocationParams returns the parameters used in the model invocation.

func (*OpenAI) Type

func (cm *OpenAI) Type() string

Type returns the type of the model.

func (*OpenAI) Verbose

func (cm *OpenAI) Verbose() bool

Verbose returns the verbosity setting of the model.

type OpenAIOptions

type OpenAIOptions struct {
	*schema.CallbackOptions `map:"-"`
	schema.Tokenizer        `map:"-"`
	// Model name to use.
	ModelName string
	// Sampling temperature to use.
	Temperatur float32
	// The maximum number of tokens to generate in the completion.
	// -1 returns as many tokens as possible given the prompt and
	//the models maximal context size.
	MaxTokens int
	// Total probability mass of tokens to consider at each step.
	TopP float32
	// Penalizes repeated tokens.
	PresencePenalty float32
	// Penalizes repeated tokens according to frequency.
	FrequencyPenalty float32
	// How many completions to generate for each prompt.
	N int
}

Jump to

Keyboard shortcuts

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