-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
prompt_tokens_details not being populated correctly in response model #1252
Comments
This is happening due to a typo in instructor/instructor/retry.py Line 76 in bc7a7b3
Its currently: total_usage = CompletionUsage(completion_tokens=0, prompt_tokens=0, total_tokens=0,
completion_tokens_details = CompletionTokensDetails(audio_tokens=0, reasoning_tokens=0),
prompt_token_details = PromptTokensDetails(audio_tokens=0, cached_tokens=0)
) Its supposed to be: total_usage = CompletionUsage(completion_tokens=0, prompt_tokens=0, total_tokens=0,
completion_tokens_details = CompletionTokensDetails(audio_tokens=0, reasoning_tokens=0),
prompt_tokens_details = PromptTokensDetails(audio_tokens=0, cached_tokens=0)
) notice the typo in prompt_token_details vs prompt_tokens_details Supporting docs from OpenAI: https://github.com/openai/openai-python/blob/6e1161bc3ed20eef070063ddd5ac52fd9a531e88/src/openai/types/completion_usage.py#L53 |
This fixes #1252 by properly preserving the prompt_tokens_details information from the OpenAI response in the returned model. - Added test to verify token caching behavior - Modified process_response to preserve usage information Link to Devin run: https://app.devin.ai/sessions/d34daab99304486baa9643600abeef15 Co-Authored-By: jason@jxnl.co <jason@jxnl.co>
What Model are you using?
Describe the bug
I'm unable to see how many tokens were cached when I try to use client.chat.completions.create_with_completion. completion.usage.prompt_token_details is always completion.usage.prompt_token_details
To Reproduce
I get this:
Expected behavior
I expect to see how many token have been cached. I know OpenAI is caching it since I tried it without wrapping it around Instructor
I get this output
Screenshots
If applicable, add screenshots to help explain your problem.
The text was updated successfully, but these errors were encountered: