callbacks

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package callbacks includes a standard interface for hooking into various stages of your LLM application. The package contains an implementation of this interface that prints to the standard output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	HandleText(ctx context.Context, text string)
	HandleLLMStart(ctx context.Context, prompts []string)
	HandleLLMEnd(ctx context.Context, output llms.LLMResult)
	HandleChainStart(ctx context.Context, inputs map[string]any)
	HandleChainEnd(ctx context.Context, outputs map[string]any)
	HandleToolStart(ctx context.Context, input string)
	HandleToolEnd(ctx context.Context, output string)
	HandleAgentAction(ctx context.Context, action schema.AgentAction)
	HandleRetrieverStart(ctx context.Context, query string)
	HandleRetrieverEnd(ctx context.Context, documents []schema.Document)
}

Handler is the interface that allows for hooking into specific parts of an LLM application.

type HandlerHaver

type HandlerHaver interface {
	GetCallbackHandler() Handler
}

HandlerHaver is an interface used to get callbacks handler.

type LogHandler

type LogHandler struct{}

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

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(_ context.Context, documents []schema.Document)

func (LogHandler) HandleRetrieverStart

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

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)

Jump to

Keyboard shortcuts

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