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

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