providerbatch

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 2 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

Overview

Package providerbatch owns request partitioning for provider APIs that bound a request by an input count and by an aggregate token budget.

Text is counted in UTF-8 bytes, which is a conservative upper bound on the number of text tokens: a provider tokenizer never yields more tokens than the input has bytes. A zero limit means the provider documents no such bound, so that limit never splits a request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForBatches

func ForBatches(ctx context.Context, operation string, count, maxInputs, maxTokens int, tokens func(int) int, send func(int, int) error) error

ForBatches splits count inputs into consecutive requests and sends each one exactly once, in order.

maxInputs bounds the inputs in one request and maxTokens bounds the request's aggregate cost as reported by tokens; both values are the provider's own documented ceilings. An input that is larger than maxTokens on its own is still sent alone: the provider's own refusal stays visible instead of being hidden or pre-empted here, and no input text is shortened.

A failing send stops the sequence and its error is returned with the failed input range, so a caller that must fail as a whole cannot mistake earlier successes for a result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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