Files
langchaingo/callbacks/callbacks.go
T
Šimun Strukan 36f399f058 callbacks: handle streaming func (#347)
* Added initial HandelStreamFunc callback handler

* added callback handler to conversational agent

* Added Agent final stdout callback

* Added callback handler to mrkl agent

* Added egress buffer for final agent streaming

* Added proper egress channel handling

* Added comments

* Added better context handling

* Fixing lint
2023-12-04 22:38:29 -08:00

32 lines
1.0 KiB
Go

package callbacks
import (
"context"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/schema"
)
// Handler is the interface that allows for hooking into specific parts of an
// LLM application.
//
//nolint:all
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, query string, documents []schema.Document)
HandleStreamingFunc(ctx context.Context, chunk []byte)
}
// HandlerHaver is an interface used to get callbacks handler.
type HandlerHaver interface {
GetCallbackHandler() Handler
}