Skip to content

fix: convert token usage values to int before summing#1664

Open
rajkumar-prog wants to merge 1 commit into
openai:mainfrom
rajkumar-prog:main
Open

fix: convert token usage values to int before summing#1664
rajkumar-prog wants to merge 1 commit into
openai:mainfrom
rajkumar-prog:main

Conversation

@rajkumar-prog
Copy link
Copy Markdown

Problem

When running evals, the OpenAI API now returns CompletionTokensDetails objects instead of plain integers for token usage values. The current code tries to sum these directly, causing:

TypeError: unsupported operand type(s) for +: 'int' and 'CompletionTokensDetails'

Fixes #1582

Fix

Wrap the value with int() before summing, so it works regardless of whether the API returns a plain integer or a CompletionTokensDetails object.

Change

evals/cli/oaieval.py line 282 — added int() conversion before summing token usage values.

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

Successfully merging this pull request may close these issues.

TypeError: unsupported operand type(s) for +: 'int' and 'CompletionTokensDetail

1 participant