Skip to content
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

Open
Xurnnba opened this issue Dec 7, 2024 · 6 comments
Open

Improve Import Error Messages for LLM Client Dependencies #4605

Xurnnba opened this issue Dec 7, 2024 · 6 comments
Labels
0.2 Issues which are related to the pre 0.4 codebase good first issue Good for newcomers needs-triage

Comments

@Xurnnba
Copy link

Xurnnba commented Dec 7, 2024

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:

  1. Include the original error message in the raised ImportError
  2. Provide more context about potential dependencies

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

  • Users get more accurate information about what's actually causing the import failure
  • Easier troubleshooting of dependency issues
  • Clearer guidance on required packages and their relationships

Affected Files

  • /autogen/oai/client.py
@ekzhu ekzhu added the 0.2 Issues which are related to the pre 0.4 codebase label Dec 8, 2024
@rysweet rysweet added the good first issue Good for newcomers label Dec 9, 2024
@mmahjoub5
Copy link

Hi, I can attempt to take this issue, if no one has volunteered

@ekzhu
Copy link
Collaborator

ekzhu commented Dec 24, 2024

Sure @mmahjoub5

@D-Yuva
Copy link

D-Yuva commented Dec 29, 2024

Hey, can i give it a shot too ?

@ekzhu
Copy link
Collaborator

ekzhu commented Dec 29, 2024

@mmahjoub5 any update on your side?

@D-Yuva thanks! Since @mmahjoub5 is already working on it, let's wait for his response.

@dedsec995
Copy link

@ekzhu I think I want help out. This would be my first contribution to open source. If no one else is working.

@ekzhu
Copy link
Collaborator

ekzhu commented Jan 6, 2025

@dedsec995 thanks. To avoid duplicate PRs let @D-Yuva submit a fix and you can review it?

v0.4 version's autogen-ext package also has many external dependencies, and it would be good to fix the import errors there too.

E.g.,

from markitdown import FileConversionException, MarkItDown, UnsupportedFormatException # type: ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.2 Issues which are related to the pre 0.4 codebase good first issue Good for newcomers needs-triage
Projects
None yet
Development

No branches or pull requests

6 participants