openai

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BasicText describes model capabilities for text-only GPT models.
	BasicText = ai.ModelCapabilities{
		Multiturn:  true,
		Tools:      true,
		SystemRole: true,
		Media:      false,
	}

	//  Multimodal describes model capabilities for multimodal GPT models.
	Multimodal = ai.ModelCapabilities{
		Multiturn:  true,
		Tools:      true,
		SystemRole: true,
		Media:      true,
	}
)

Functions

func DefineEmbedder

func DefineEmbedder(name string) ai.Embedder

DefineEmbedder defines an embedder with a given name.

func DefineModel

func DefineModel(name string, caps *ai.ModelCapabilities) (ai.Model, error)

DefineModel defines an unknown model with the given name. The second argument describes the capability of the model. Use IsDefinedModel to determine if a model is already defined. After Init is called, only the known models are defined.

func Embedder

func Embedder(name string) ai.Embedder

Embedder returns the ai.Embedder with the given name. It returns nil if the embedder was not defined.

func Init

func Init(ctx context.Context, cfg *Config) (err error)

Init initializes the plugin and all known models. After calling Init, you may call DefineModel to create and register any additional generative models.

func IsDefinedEmbedder

func IsDefinedEmbedder(name string) bool

IsDefinedEmbedder reports whether the named Embedder is defined by this plugin.

func IsDefinedModel

func IsDefinedModel(name string) bool

IsDefinedModel reports whether the named Model is defined by this plugin.

func Model

func Model(name string) ai.Model

Model returns the ai.Model with the given name. It returns nil if the model was not defined.

Types

type Config

type Config struct {
	// The API key to access the service.
	// If empty, the values of the environment variables OPENAI_API_KEY will be consulted.
	APIKey string
}

Config is the configuration for the plugin.

Jump to

Keyboard shortcuts

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