contextreduce

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ContextWindowExceededError = "context exceeds model window after removing tool results"
View Source
const RemovedToolResultPlaceholder = "Tool result removed to fit context."

Variables

View Source
var ErrContextWindowExceeded = errors.New("context window exceeded")

Functions

func AnthropicToolResultContent

func AnthropicToolResultContent(result *anthropic.ToolResultBlockParam) string

func BedrockToolResultContent

func BedrockToolResultContent(content []brtypes.ToolResultContentBlock) string

func EstimateAnthropic

func EstimateAnthropic(messages []anthropic.MessageParam) int

func EstimateBedrock

func EstimateBedrock(messages []brtypes.Message) int

func EstimateGenkit

func EstimateGenkit(messages []*ai.Message) int

func EstimateOpenAI

func EstimateOpenAI(messages []openai.ChatCompletionMessageParamUnion) int

func EstimateResponses

func EstimateResponses(input []responses.ResponseInputItemUnionParam) int

Types

type Reduction

type Reduction struct {
	OriginalTokenCount int
	ReducedTokenCount  int
	RemovedToolResults int
	FitsBudget         bool
}

func ReduceAnthropic

func ReduceAnthropic(window int, messages []anthropic.MessageParam) ([]anthropic.MessageParam, Reduction)

func ReduceBedrock

func ReduceBedrock(window int, messages []brtypes.Message) ([]brtypes.Message, Reduction)

func ReduceGenkit

func ReduceGenkit(window int, messages []*ai.Message) ([]*ai.Message, Reduction)

Jump to

Keyboard shortcuts

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