- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 750
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
AttributeError("'dict' object has no attribute 'audio_tokens'") #1332
Comments
@demux79 could you provide a code snippet to reproduce this? |
ivanleo@Ivans-MacBook-Pro ~/D/c/test (main) [127]> uv pip list | grep -E "instructor|openai" I just tested this on the latest release of instructor and I don't get this error. from openai import OpenAI
from pydantic import BaseModel
import instructor
class ChatClassification(BaseModel):
relevant: bool
message: str
client = instructor.from_openai(OpenAI())
resp = client.chat.completions.create(
model="gpt-4o-mini-2024-07-18",
messages=[{"role": "user", "content": "Is a secret answer relevant?"}],
response_model=ChatClassification,
)
print(resp) Closing this issue for now until there's a code snippet to reproduce this error and a list of installed packages for openai and instructor |
Reproduction: from litellm import completion
from pydantic import BaseModel
import instructor
class ChatClassification(BaseModel):
relevant: bool
message: str
client = instructor.from_litellm(completion)
resp = client.chat.completions.create(
model="gpt-4o-mini-2024-07-18",
messages=[{"role": "user", "content": "Is a secret answer relevant?"}],
response_model=ChatClassification,
)
print(resp)
|
Looks like litellm doesn't fully convert the usage information to objects. |
Yes, that must be it. Now that I know it I understand why some of my projects work and some not. Those with litellm fail. |
What Model are you using?
Describe the bug
After upgrading from Instructor 1.4 to 1.7.2 I reliably get this error message:
AttributeError("'dict' object has no attribute 'audio_tokens'")
Instructor retry error (AttributeError("'dict' object has no attribute 'audio_tokens'"),): Secret question | Number of attempts: 2 | Last completion: ChatCompletion(id='chatcmpl-AwHgTkbW0O4qstBcBXV7tVbGnLqkj', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', audio=None, function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_Bje6d4Fv05eM7UqnQ8r3Jqyk', function=Function(arguments='{"relevant":true,"message":"Secret Answer"}', name='ChatClassification'), type='function')]))], created=1738454365, model='gpt-4o-mini-2024-07-18', object='chat.completion', service_tier='default', system_fingerprint='fp_72ed7ab54c', usage=CompletionUsage(completion_tokens=95, prompt_tokens=326, total_tokens=421, completion_tokens_details={'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, prompt_tokens_details={'audio_tokens': 0, 'cached_tokens': 0}))
To Reproduce
Every time
Expected behavior
Do not fail on audio_token
The text was updated successfully, but these errors were encountered: