-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Improve Import Error Messages for LLM Client Dependencies #4605
Comments
Hi, I can attempt to take this issue, if no one has volunteered |
Sure @mmahjoub5 |
Hey, can i give it a shot too ? |
@mmahjoub5 any update on your side? @D-Yuva thanks! Since @mmahjoub5 is already working on it, let's wait for his response. |
@ekzhu I think I want help out. This would be my first contribution to open source. If no one else is working. |
@dedsec995 thanks. To avoid duplicate PRs let @D-Yuva submit a fix and you can review it? v0.4 version's E.g., autogen/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_markdown_file_browser.py Lines 10 to 11 in d99fb23
|
What feature would you like to be added?
Current Behavior
When an import error occurs while initializing LLM clients (e.g., Gemini, Anthropic, etc.), the code raises a generic ImportError with a hardcoded message suggesting to install specific packages. However, the actual import error might be caused by other issues (like missing dependencies of those packages or version conflicts).
For example, when trying to use the Gemini client, if there's an error importing
vertexai
, the code shows:ImportError: Please install google-generativeai to use Google OpenAI API.
Even though the actual error was:
ImportError: No module named 'vertexai'
Why is this needed?
Proposed Change
Modify the import error handling to:
Example implementation:
if gemini_import_exception:
raise ImportError(
f"Failed to initialize Gemini client. Original error: {gemini_import_exception}\n"
"Required packages:\n"
"- google-generativeai\n"
"- google-cloud-aiplatform (provides vertexai)"
)
Benefits
Affected Files
/autogen/oai/client.py
The text was updated successfully, but these errors were encountered: