openai

package
v0.0.0-...-0a0123b Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(
	NewConfig,
	NewAgent,
)

Functions

This section is empty.

Types

type Agent

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

func NewAgent

func NewAgent(c Config) (*Agent, error)

func (*Agent) Ask

func (s *Agent) Ask(
	prompt string,
	content string,
) (rxgo.Observable, error)

func (*Agent) Call

func (s *Agent) Call(
	ctx context.Context,
	content string,
	functions []llms.FunctionDefinition,
) (*schema.FunctionCall, error)

func (*Agent) GenerateImages

func (s *Agent) GenerateImages(ctx context.Context, prompt string) ([]string, error)

func (*Agent) Prompt

func (s *Agent) Prompt(
	ctx context.Context,
	prompt string,
) (string, error)

func (*Agent) PromptStream

func (s *Agent) PromptStream(
	ctx context.Context,
	prompt string,
) (rxgo.Observable, error)

func (*Agent) PromptToProto

func (s *Agent) PromptToProto(
	ctx context.Context,
	prompt string,
	p protoreflect.ProtoMessage,
) error

func (*Agent) TextToSpeech

func (s *Agent) TextToSpeech(
	ctx context.Context,
	text string,
) (io.Reader, error)

type Config

type Config struct {
	APIKey  string        `yaml:"api_key"`
	Timeout time.Duration `yaml:"timeout"`
	Model   string        `yaml:"model"`
}

func NewConfig

func NewConfig(provider config.Provider) (Config, error)

func NewDefaultConfig

func NewDefaultConfig() Config

type Definition

type Definition struct {
	Properties           json.RawMessage `json:"properties"`
	AdditionalProperties bool            `json:"additionalProperties"`
	Type                 string          `json:"type"`
	Title                string          `json:"title"`
}

type FunctionCallJSON

type FunctionCallJSON struct {
	Schema      string                `json:"$schema"`
	Ref         string                `json:"$ref"`
	Definitions map[string]Definition `json:"definitions"`
}

type LogHandler

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

LogHandler is a callback handler that prints to the standard output.

func NewHandler

func NewHandler(ops ...Option) *LogHandler

func (*LogHandler) HandleAgentAction

func (l *LogHandler) HandleAgentAction(_ context.Context, action schema.AgentAction)

func (*LogHandler) HandleAgentFinish

func (l *LogHandler) HandleAgentFinish(ctx context.Context, finish schema.AgentFinish)

func (*LogHandler) HandleChainEnd

func (l *LogHandler) HandleChainEnd(_ context.Context, outputs map[string]any)

func (*LogHandler) HandleChainError

func (l *LogHandler) HandleChainError(ctx context.Context, err error)

func (*LogHandler) HandleChainStart

func (l *LogHandler) HandleChainStart(_ context.Context, inputs map[string]any)

func (*LogHandler) HandleLLMError

func (l *LogHandler) HandleLLMError(ctx context.Context, err error)

func (*LogHandler) HandleLLMGenerateContentEnd

func (l *LogHandler) HandleLLMGenerateContentEnd(ctx context.Context, res *llms.ContentResponse)

func (*LogHandler) HandleLLMGenerateContentStart

func (l *LogHandler) HandleLLMGenerateContentStart(ctx context.Context, ms []llms.MessageContent)

func (*LogHandler) HandleLLMStart

func (l *LogHandler) HandleLLMStart(_ context.Context, prompts []string)

func (*LogHandler) HandleRetrieverEnd

func (l *LogHandler) HandleRetrieverEnd(_ context.Context, query string, documents []schema.Document)

func (*LogHandler) HandleRetrieverStart

func (l *LogHandler) HandleRetrieverStart(_ context.Context, query string)

func (*LogHandler) HandleStreamingFunc

func (l *LogHandler) HandleStreamingFunc(ctx context.Context, chunk []byte)

func (*LogHandler) HandleText

func (l *LogHandler) HandleText(_ context.Context, text string)

func (*LogHandler) HandleToolEnd

func (l *LogHandler) HandleToolEnd(_ context.Context, output string)

func (*LogHandler) HandleToolError

func (l *LogHandler) HandleToolError(ctx context.Context, err error)

func (*LogHandler) HandleToolStart

func (l *LogHandler) HandleToolStart(_ context.Context, input string)

type ModelDetails

type ModelDetails struct {
	MaxTokens     int
	TokensPerMsg  int
	TokensPerName int
}

type Option

type Option func(*LogHandler)

func WithEvents

func WithEvents(events chan rxgo.Item) Option

Jump to

Keyboard shortcuts

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