llm

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ask

func Ask[T any](ctx context.Context, llm gollem.LLMClient, prompt string, opts ...AskOption[T]) (*T, error)

func NewCompactionMiddleware added in v0.5.0

func NewCompactionMiddleware(llmClient gollem.LLMClient, logger *slog.Logger) gollem.ContentBlockMiddleware

NewCompactionMiddleware creates a content block middleware for automatic conversation history compaction. It compresses the oldest 70% of conversation history when the history grows too large, reducing token usage and preventing context window overflow.

func NewCompactionStreamMiddleware added in v0.5.0

func NewCompactionStreamMiddleware(llmClient gollem.LLMClient) gollem.ContentStreamMiddleware

NewCompactionStreamMiddleware creates a content stream middleware for automatic conversation history compaction.

func Summary

func Summary[T any](ctx context.Context, llm gollem.LLMClient, prompt string, data []T, opts ...SummaryOption) (string, error)

Summary generates a summary of the large data by using the LLM.

Types

type AskOption

type AskOption[T any] func(*askConfig[T])

func WithMaxRetry

func WithMaxRetry[T any](maxRetry int) AskOption[T]

func WithRetryPrompt

func WithRetryPrompt[T any](f func(ctx context.Context, err error) string) AskOption[T]

func WithSchema added in v0.5.0

func WithSchema[T any](schema *gollem.Parameter) AskOption[T]

func WithValidate

func WithValidate[T any](f func(v T) error) AskOption[T]

type SummaryOption

type SummaryOption func(*summaryConfig)

func WithMaxPartSize

func WithMaxPartSize(maxPartSize int) SummaryOption

Jump to

Keyboard shortcuts

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