openai

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingClientAPIKey = errors.Newf("missing client settings api key")
View Source
var ErrMissingClientSettings = errors.Newf("missing client settings")
View Source
var ErrMissingYAMLAPIKey = &yaml.TypeError{Errors: []string{"missing api key"}}

Functions

This section is empty.

Types

type ClientParameterLayer added in v0.1.4

type ClientParameterLayer struct {
	*layers.ParameterLayerImpl
}

func NewClientParameterLayer added in v0.1.4

func NewClientParameterLayer(options ...layers.ParameterLayerOptions) (*ClientParameterLayer, error)

func (*ClientParameterLayer) ParseFlagsFromCobraCommand added in v0.1.7

func (cp *ClientParameterLayer) ParseFlagsFromCobraCommand(
	cmd *cobra.Command,
) (map[string]interface{}, error)

type ClientSettings

type ClientSettings struct {
	APIKey        *string        `yaml:"api_key,omitempty" glazed.parameter:"openai-api-key"`
	Timeout       *time.Duration `yaml:"timeout,omitempty" glazed.parameter:"openai-timeout"`
	Organization  *string        `yaml:"organization,omitempty" glazed.parameter:"openai-organization"`
	DefaultEngine *string        `yaml:"default_engine,omitempty" glazed.parameter:"openai-default-engine"`
	UserAgent     *string        `yaml:"user_agent,omitempty" glazed.parameter:"openai-user-agent"`
	BaseURL       *string        `yaml:"base_url,omitempty" glazed.parameter:"openai-base-url"`
	HTTPClient    *http.Client   `yaml:"omitempty"`
}

func NewClientSettings

func NewClientSettings() *ClientSettings

func NewClientSettingsFromParameters added in v0.1.4

func NewClientSettingsFromParameters(ps map[string]interface{}) (*ClientSettings, error)

func (*ClientSettings) Clone

func (c *ClientSettings) Clone() *ClientSettings

func (*ClientSettings) CreateClient

func (c *ClientSettings) CreateClient() (gpt3.Client, error)

func (*ClientSettings) IsValid

func (c *ClientSettings) IsValid() error

func (*ClientSettings) ToOptions

func (c *ClientSettings) ToOptions() []gpt3.ClientOption

func (*ClientSettings) UnmarshalYAML

func (c *ClientSettings) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML overrides YAML parsing to convert time.duration from int

type CompletionParameterLayer added in v0.1.4

type CompletionParameterLayer struct {
	*layers.ParameterLayerImpl
}

func NewCompletionParameterLayer added in v0.1.4

func NewCompletionParameterLayer(options ...layers.ParameterLayerOptions) (*CompletionParameterLayer, error)

type CompletionStep

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

func NewCompletionStep

func NewCompletionStep(settings *CompletionStepSettings) *CompletionStep

func (*CompletionStep) GetOutput

func (o *CompletionStep) GetOutput() <-chan helpers.Result[string]

func (*CompletionStep) GetState

func (o *CompletionStep) GetState() interface{}

func (*CompletionStep) IsFinished

func (o *CompletionStep) IsFinished() bool

func (*CompletionStep) Run

func (o *CompletionStep) Run(ctx context.Context, prompt string) error

type CompletionStepFactory

type CompletionStepFactory struct {
	ClientSettings *ClientSettings         `yaml:"client,omitempty"`
	StepSettings   *CompletionStepSettings `yaml:"completion,omitempty"`
}

func NewCompletionStepFactory

func NewCompletionStepFactory(
	settings *CompletionStepSettings,
	clientSettings *ClientSettings,
) *CompletionStepFactory

func NewCompletionStepFactoryFromYAML

func NewCompletionStepFactoryFromYAML(s io.Reader) (*CompletionStepFactory, error)

func (*CompletionStepFactory) NewStep

func (csf *CompletionStepFactory) NewStep() (steps.Step[string, string], error)

func (*CompletionStepFactory) UpdateFromParameters added in v0.1.4

func (csf *CompletionStepFactory) UpdateFromParameters(ps map[string]interface{}) error

type CompletionStepSettings

type CompletionStepSettings struct {
	ClientSettings *ClientSettings `yaml:"client,omitempty"`

	Engine *string `yaml:"engine,omitempty" glazed.parameter:"openai-engine"`

	MaxResponseTokens *int `yaml:"max_response_tokens,omitempty" glazed.parameter:"openai-max-response-tokens"`

	// Sampling temperature to use
	Temperature *float32 `yaml:"temperature,omitempty" glazed.parameter:"openai-temperature"`
	// Alternative to temperature for nucleus sampling
	TopP *float32 `yaml:"top_p,omitempty" glazed.parameter:"openai-top-p"`
	// How many choice to create for each prompt
	N *int `yaml:"n" glazed.parameter:"openai-n"`
	// Include the probabilities of most likely tokens
	LogProbs *int `yaml:"logprobs" glazed.parameter:"openai-logprobs"`
	// Up to 4 sequences where the API will stop generating tokens. Response will not contain the stop sequence.
	Stop []string `yaml:"stop,omitempty" glazed.parameter:"openai-stop"`

	Stream bool `yaml:"stream,omitempty" glazed.parameter:"openai-stream"`
}

func NewCompletionStepSettings

func NewCompletionStepSettings() *CompletionStepSettings

func NewCompletionStepSettingsFromParameters added in v0.1.4

func NewCompletionStepSettingsFromParameters(ps map[string]interface{}) (*CompletionStepSettings, error)

func (*CompletionStepSettings) Clone

type CompletionStepState

type CompletionStepState int
const (
	CompletionStepNotStarted CompletionStepState = iota
	CompletionStepRunning
	CompletionStepFinished
	CompletionStepClosed
)

type MultiCompletionStep

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

MultiCompletionStep runs multiple completion steps in parallel

func NewMultiCompletionStep

func NewMultiCompletionStep(settings *CompletionStepSettings) *MultiCompletionStep

func (*MultiCompletionStep) GetOutput

func (mc *MultiCompletionStep) GetOutput() <-chan helpers.Result[[]string]

func (*MultiCompletionStep) GetState

func (mc *MultiCompletionStep) GetState() interface{}

func (*MultiCompletionStep) IsFinished

func (mc *MultiCompletionStep) IsFinished() bool

func (*MultiCompletionStep) Run

func (mc *MultiCompletionStep) Run(ctx context.Context, prompts []string) error

Jump to

Keyboard shortcuts

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