openaiapi

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT 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

This section is empty.

Variables

This section is empty.

Functions

func QueryOpenAIAPIModel

func QueryOpenAIAPIModel(ctx context.Context, client *openai.Client, modelIdentifier string, attributes map[string]string, promptText string) (response string, err error)

QueryOpenAIAPIModel queries an OpenAI API model.

Types

type Provider

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

Provider holds a generic "OpenAI API" provider.

func NewProvider

func NewProvider(id string, baseURL string) (provider *Provider)

NewProvider returns a generic "OpenAI API" provider.

func (*Provider) AddModel

func (p *Provider) AddModel(m model.Model)

AddModel manually adds a model to the provider.

func (*Provider) Available

func (p *Provider) Available(logger *log.Logger) (err error)

Available checks if the provider is ready to be used. This might include checking for an installation or making sure an API access token is valid.

func (*Provider) ID

func (p *Provider) ID() (id string)

ID returns the unique ID of this provider.

func (*Provider) Models

func (p *Provider) Models() (models []model.Model, err error)

Models returns which models are available to be queried via this provider.

func (*Provider) Query

func (p *Provider) Query(ctx context.Context, model model.Model, promptText string) (response string, err error)

Query queries the provider with the given model name.

func (*Provider) SetToken

func (p *Provider) SetToken(token string)

SetToken sets a potential token to be used in case the provider needs to authenticate a remote API.

Jump to

Keyboard shortcuts

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