mirror of
https://github.com/Shubhamsaboo/awesome-llm-apps.git
synced 2026-03-11 17:48:31 -05:00
Agno library is still using outdated import? Ref: ai_real_estate_agent #37
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AravindCT on GitHub (Mar 1, 2025).
Error: ImportError: cannot import name 'APIConnectionError' from 'openai' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/openai/init.py)
Traceback:
File "/Users/aravindtambad/Documents/GitHub/awesome-llm-apps/ai_agent_tutorials/ai_real_estate_agent/ai_real_estate_agent.py", line 6, in
from agno.models.openai import OpenAIChat
File "/Users/aravindtambad/Library/Python/3.12/lib/python/site-packages/agno/models/openai/init.py", line 1, in
from agno.models.openai.chat import OpenAIChat
File "/Users/aravindtambad/Library/Python/3.12/lib/python/site-packages/agno/models/openai/chat.py", line 18, in
from openai import APIConnectionError, APIStatusError, RateLimitError
This seems like an issue with import statements in agno library. Am I right? Or is there something else I am missing?
@Stephanieewelu commented on GitHub (Mar 2, 2025):
Hey @AravindCT, I looked into this issue, and it seems like it's due to changes in OpenAI’s package structure in recent versions.
The error occurs because APIConnectionError and other exceptions have been moved in OpenAI’s latest versions (>=1.0.0).
Instead of:
from openai import APIConnectionError, APIStatusError, RateLimitError
Try updating it to:
from openai._exceptions import APIConnectionError, APIStatusError, RateLimitError
Alternatively, downgrading OpenAI to <1.0.0 should also work.
@AravindCT commented on GitHub (Mar 3, 2025):
What worked for me is this:
from openai.error import APIConnectionError, APIError, RateLimitError
I changed this inside the agno/models/openai directory in the chat.py and init.py files manually and ran this in a venv. perhaps your method is simpler. I will try it.
@Stephanieewelu commented on GitHub (Mar 4, 2025):
@AravindCT Did you try my suggestion and did it work?