template

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultCallbackHandler

type DefaultCallbackHandler struct {
	OnStart                func(ctx context.Context, info *callbacks.RunInfo, input callbacks.CallbackInput) context.Context
	OnStartWithStreamInput func(ctx context.Context, info *callbacks.RunInfo, input *schema.StreamReader[callbacks.CallbackInput]) context.Context
	OnEnd                  func(ctx context.Context, info *callbacks.RunInfo, output callbacks.CallbackOutput) context.Context
	OnEndWithStreamOutput  func(ctx context.Context, info *callbacks.RunInfo, output *schema.StreamReader[callbacks.CallbackOutput]) context.Context
	OnError                func(ctx context.Context, info *callbacks.RunInfo, err error) context.Context
}

DefaultCallbackHandler is the default callback handler implementation, can be used for callback handler builder in template.HandlerHelper (for example, Graph, StateGraph, Chain, Lambda, etc.).

func (*DefaultCallbackHandler) Needed

Needed checks if the callback handler is needed for the given timing.

type HandlerHelper

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

HandlerHelper is a builder for creating a callbacks.Handler with specific handlers for different component types. create a handler with template.NewHandlerHelper(). eg.

helper := template.NewHandlerHelper().
	ChatModel(&model.CallbackHandler{}).
	Prompt(&prompt.CallbackHandler{}).
	Handler()

then use the handler with runnable.Invoke(ctx, input, compose.WithCallbacks(handler))

func NewHandlerHelper

func NewHandlerHelper() *HandlerHelper

NewHandlerHelper creates a new component template handler builder. This builder can be used to configure and build a component template handler, which can handle callback events for different components with its own struct definition, and fallbackTemplate can be used to handle scenarios where none of the cases are hit as a fallback.

func (*HandlerHelper) Chain

Chain sets the chain handler for the handler helper, which will be called when the chain is executed.

func (*HandlerHelper) ChatModel

func (c *HandlerHelper) ChatModel(handler *model.CallbackHandler) *HandlerHelper

ChatModel sets the chat model handler for the handler helper, which will be called when the chat model component is executed.

func (*HandlerHelper) Embedding

func (c *HandlerHelper) Embedding(handler *embedding.CallbackHandler) *HandlerHelper

Embedding sets the embedding handler for the handler helper, which will be called when the embedding component is executed.

func (*HandlerHelper) Fallback

func (c *HandlerHelper) Fallback(handler *DefaultCallbackHandler) *HandlerHelper

Fallback sets the fallback handler for the handler helper, which will be called when no other handlers are matched.

func (*HandlerHelper) Graph

Graph sets the graph handler for the handler helper, which will be called when the graph is executed.

func (*HandlerHelper) Handler

func (c *HandlerHelper) Handler() callbacks.Handler

Handler returns the callbacks.Handler created by HandlerHelper.

func (*HandlerHelper) Indexer

func (c *HandlerHelper) Indexer(handler *indexer.CallbackHandler) *HandlerHelper

Indexer sets the indexer handler for the handler helper, which will be called when the indexer component is executed.

func (*HandlerHelper) Lambda

func (c *HandlerHelper) Lambda(handler *DefaultCallbackHandler) *HandlerHelper

Lambda sets the lambda handler for the handler helper, which will be called when the lambda is executed.

func (*HandlerHelper) Loader

Loader sets the loader handler for the handler helper, which will be called when the loader component is executed.

func (*HandlerHelper) Passthrough

func (c *HandlerHelper) Passthrough(handler *DefaultCallbackHandler) *HandlerHelper

Passthrough sets the passthrough handler for the handler helper, which will be called when the passthrough is executed.

func (*HandlerHelper) Prompt

func (c *HandlerHelper) Prompt(handler *prompt.CallbackHandler) *HandlerHelper

Prompt sets the prompt handler for the handler helper, which will be called when the prompt component is executed.

func (*HandlerHelper) Retriever

func (c *HandlerHelper) Retriever(handler *retriever.CallbackHandler) *HandlerHelper

Retriever sets the retriever handler for the handler helper, which will be called when the retriever component is executed.

func (*HandlerHelper) StateGraph

func (c *HandlerHelper) StateGraph(handler *DefaultCallbackHandler) *HandlerHelper

StateGraph sets the state graph handler for the handler helper, which will be called when the state graph is executed.

func (*HandlerHelper) Tool

func (c *HandlerHelper) Tool(handler *tool.CallbackHandler) *HandlerHelper

Tool sets the tool handler for the handler helper, which will be called when the tool component is executed.

func (*HandlerHelper) ToolsNode

func (c *HandlerHelper) ToolsNode(handler *DefaultCallbackHandler) *HandlerHelper

ToolsNode sets the tools node handler for the handler helper, which will be called when the tools node is executed.

func (*HandlerHelper) Transformer

Transformer sets the transformer handler for the handler helper, which will be called when the transformer component is executed.

Jump to

Keyboard shortcuts

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