openai

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 14 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 ClientSettings

type ClientSettings struct {
	APIKey        *string        `yaml:"api_key,omitempty"`
	Timeout       *time.Duration `yaml:"timeout,omitempty"`
	Organization  *string        `yaml:"organization,omitempty"`
	DefaultEngine *string        `yaml:"default_engine,omitempty"`
	UserAgent     *string        `yaml:"user_agent,omitempty"`
	BaseURL       *string        `yaml:"base_url,omitempty"`
	HTTPClient    *http.Client   `yaml:"omitempty"`
}

func NewClientSettings

func NewClientSettings() *ClientSettings

func NewClientSettingsFromCobra

func NewClientSettingsFromCobra(cmd *cobra.Command) (*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 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"`
	// contains filtered or unexported fields
}

func NewCompletionStepFactory

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

func NewCompletionStepFactoryFromYAML

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

func (*CompletionStepFactory) AddFlags

func (csf *CompletionStepFactory) AddFlags(cmd *cobra.Command, prefix string, defaults interface{}) error

func (*CompletionStepFactory) NewStep

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

func (*CompletionStepFactory) UpdateFromCobra

func (csf *CompletionStepFactory) UpdateFromCobra(cmd *cobra.Command) error

type CompletionStepFactoryFlagsDefaults

type CompletionStepFactoryFlagsDefaults struct {
	Engine            *string
	MaxResponseTokens *int
	Temperature       *float32
	TopP              *float32
	N                 *int
	LogProbs          *int
	Stop              *[]string
	Stream            *bool
}

type CompletionStepSettings

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

	Engine *string `yaml:"engine,omitempty"`

	MaxResponseTokens *int `yaml:"max_response_tokens,omitempty"`

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

	Stream bool `yaml:"stream,omitempty"`
}

func NewCompletionStepSettings

func NewCompletionStepSettings() *CompletionStepSettings

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