context

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package context estimates and prepares model context windows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Estimate

func Estimate(msgs []message.Message, model string) int

Estimate returns a non-negative token estimate for provider-neutral messages.

func EstimateRequest

func EstimateRequest(msgs []message.Message, tools []provider.ToolDefinition, model string) int

EstimateRequest returns a token estimate for a provider request, including the message list and tool schemas that providers count as prompt input.

func ObserveUsage

func ObserveUsage(model string, estimated int, actual int)

ObserveUsage records provider input-token usage to calibrate future estimates.

Types

type Breakdown

type Breakdown struct {
	SystemRuntime int
	ToolSchema    int
	UserAssistant int
	ToolResult    int
	Other         int
	Total         int
}

Breakdown summarizes the uncalibrated request estimate by broad source.

func EstimateRequestBreakdown

func EstimateRequestBreakdown(msgs []message.Message, tools []provider.ToolDefinition, model string) Breakdown

EstimateRequestBreakdown returns a lightweight request estimate breakdown.

Jump to

Keyboard shortcuts

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