View Source LangChain.TokenUsage (LangChain v0.3.0-rc.0)
Contains token usage information returned from an LLM.
Example
%TokenUsage{
input: 30,
output: 15
}
Input is the tokens from the prompt. Output is the completion or generated tokens returned.
Summary
Functions
Build a new TokenUsage and return an :ok
/:error
tuple with the result.
Build a new TokenUsage and return it or raise an error if invalid.
Return the total token usage amount. The total is the sum of input and output.
Types
Functions
@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Build a new TokenUsage and return an :ok
/:error
tuple with the result.
Build a new TokenUsage and return it or raise an error if invalid.
Return the total token usage amount. The total is the sum of input and output.