Why is this happening?
{
"name": "AttributeError",
"message": "'Beta' object has no attribute 'chat'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[17], line 18
13 final_answer: str
16 # client = OpenAI()
---> 18 completion = client.beta.chat.completions.parse(
19 model=\"gpt-4o-2024-08-06\",
20 messages=[
21 {\"role\": \"system\", \"content\": \"You are a helpful math tutor.\"},
22 {\"role\": \"user\", \"content\": \"solve 8x + 31 = 2\"},
23 ],
24 response_format=MathResponse,
25 )
27 message = completion.choices[0].message
28 if message.parsed:
AttributeError: 'Beta' object has no attribute 'chat'"
}
I’m using the latest openai python sdk.
3 Likes
zak-tt
August 8, 2024, 7:12am
2
I got the same error and realized using langfuse wrapper instead of the one from openai.
Try json.load()
instead if it is the case.
Langfuse doc: integrations/openai/python/structured-outputs
Disclaimer: Link post is not allowed here.
I got the same error, apparently this seems to be the only endpoint that supports structured outputs for now. Tried batch, assistants as well as completions and it doesn’t support despite latest SDK
Problem solved. Just update python to 3.12.
I don’t know why.
I tried after with python upgrade to 3.12, didn’t work
1 Like
omerd
August 8, 2024, 1:03pm
6
I’m already on python 3.12.4 and seeing the same issue: ‘Beta’ object has no attribute ‘chat’
1 Like
omerd
August 8, 2024, 1:20pm
7
Ok, make sure that you have version 1.40 (and beyond) of the openai package. After updating the package it works.
Still getting this issue. Have openai version 1.40.5 and python version 3.12.4
1 Like
Updating python to 3.12.4 and openai package to 1.40.0 worked for me.
2 Likes
This is the right answer, both the libraries need to be upgraded.
This is not working after upgrading both python and openai libraries
1 Like
rhruby
August 22, 2024, 10:12am
12
I have the same issue.
Interestingly the code runs in a jupyter notebook cell, but not when wrapped in a FastAPI endpoint.
Using same python interpreter and openai version for both.
Python 3.12.2
Openai 1.42.0
1 Like
yafim
August 26, 2024, 11:15pm
13
I get this error when using openai 1.42.0 but not when I downgraded to 1.40.0 with pip install openai==1.40.0
.
1 Like
hop on one leg, quack like a duck, and spin around. This worked for me. smh
I have the same issue as rhruby.
When running it as a script it works, but when wrapped in FastAPI I get the issue.
It works with Python 3.10. after upgrading openai to 1.43.0. Keep in mind that you have to restart the kernel after pip install, if you’re using Jupyter notebook.