Skip to content
1 min read · 145 words

Interface: ContentLike

Defined in: src/batteries/context/thrift/contracts.ts:85

A Tokenizable-like value: renders to a string and (usually) knows its own token cost. Every content field the working set carries (system prompt, standing instructions, message/thought content) is either a plain string or a value shaped like this.

Remarks

estimateTokens is optional here (unlike Estimable) because a caller may hand the battery a plain object that only renders text (e.g. a lightweight test double) — the battery falls back to measuring toString() via the injected EstimateTokensFn when estimateTokens is absent.

Methods

estimateTokens()?

ts
optional estimateTokens(encoding: string, ctx?: unknown): number;

Defined in: src/batteries/context/thrift/contracts.ts:89

Optional self-measurement, preferred over the toString() fallback when present.

Parameters

ParameterType
encodingstring
ctx?unknown

Returns

number


toString()

ts
toString(): string;

Defined in: src/batteries/context/thrift/contracts.ts:87

Render this value to its dispatched text form.

Returns

string