Jido.AI.Usage (Jido AI v2.2.0)

Copy Markdown View Source

Helpers for merging provider usage metadata.

Summary

Functions

Adds :total_tokens when input and output token counters are available.

Merges two usage maps while summing numeric counters and preserving provider metadata.

Normalizes common usage counter keys and numeric counter values.

Functions

ensure_total_tokens(usage)

@spec ensure_total_tokens(map()) :: map()

Adds :total_tokens when input and output token counters are available.

merge(existing, incoming)

@spec merge(term(), term()) :: map()

Merges two usage maps while summing numeric counters and preserving provider metadata.

normalize(usage)

@spec normalize(term()) :: map() | nil

Normalizes common usage counter keys and numeric counter values.