llm

package
v0.0.0-...-da789b0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 21 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 (c *Agent) Ask(
	prompt string,
	content string,
) (rxgo.Observable, error)

func (*Agent) Call

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

func (*Agent) GenerateImages

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

func (*Agent) Prompt

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

func (*Agent) PromptToProto

func (c *Agent) PromptToProto(
	ctx context.Context,
	prompt string,
	p protoreflect.ProtoMessage,
	jsonSchemaDef []byte,
) 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) HandleChainEnd

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

func (*LogHandler) HandleChainStart

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

func (*LogHandler) HandleLLMEnd

func (l *LogHandler) HandleLLMEnd(_ context.Context, output llms.LLMResult)

func (*LogHandler) HandleLLMStart

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

func (*LogHandler) HandleRetrieverEnd

func (l *LogHandler) HandleRetrieverEnd(ctx 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) HandleToolStart

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

type Option

type Option func(*LogHandler)

func WithEvents

func WithEvents(events chan rxgo.Item) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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