Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend TokenUsage to Support Custom Fields for Enhanced Usability #235

Closed
nallwhy opened this issue Jan 15, 2025 · 1 comment
Closed

Extend TokenUsage to Support Custom Fields for Enhanced Usability #235

nallwhy opened this issue Jan 15, 2025 · 1 comment

Comments

@nallwhy
Copy link
Contributor

nallwhy commented Jan 15, 2025

Currently, the TokenUsage module in LangChain only supports input and output fields, limiting its flexibility for use cases requiring additional metadata, such as cached_tokens. By allowing extensions to include a raw field or other custom fields, users could store and retrieve more comprehensive information tailored to their specific needs.

%LangChain.TokenUsage{
  input: 19,
  output: 10,
  raw: %{
    "completion_tokens" => 10,
    "completion_tokens_details" => %{
      "accepted_prediction_tokens" => 0,
      "reasoning_tokens" => 0,
      "rejected_prediction_tokens" => 0
    },
    "prompt_tokens" => 19,
    "prompt_tokens_details" => %{"cached_tokens" => 0},
    "total_tokens" => 29
  }
}
@brainlid
Copy link
Owner

Closed by PR #236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants