diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/azure/__init__.py b/python/packages/autogen-ext/src/autogen_ext/agents/azure/__init__.py index 1952155d0413..aa15ab61cace 100644 --- a/python/packages/autogen-ext/src/autogen_ext/agents/azure/__init__.py +++ b/python/packages/autogen-ext/src/autogen_ext/agents/azure/__init__.py @@ -2,7 +2,7 @@ from ._azure_ai_agent import AzureAIAgent except ImportError as e: raise ImportError( - "Dependencies for AzureAIAgent not found. " + f"Dependencies for AzureAIAgent not found. Original error: {e}\n" 'Please install autogen-ext with the "azure" extra: ' 'pip install "autogen-ext[azure]"' ) from e diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/magentic_one/__init__.py b/python/packages/autogen-ext/src/autogen_ext/agents/magentic_one/__init__.py index 3ec42d4fa5ae..3043b9760e10 100644 --- a/python/packages/autogen-ext/src/autogen_ext/agents/magentic_one/__init__.py +++ b/python/packages/autogen-ext/src/autogen_ext/agents/magentic_one/__init__.py @@ -2,7 +2,7 @@ from ._magentic_one_coder_agent import MagenticOneCoderAgent except ImportError as e: raise ImportError( - "Dependencies for MagenticOneCoderAgent not found. " + f"Dependencies for MagenticOneCoderAgent not found. Original error: {e}\n" 'Please install autogen-ext with the "magentic-one" extra: ' 'pip install "autogen-ext[magentic-one]"' ) from e diff --git a/python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py b/python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py index 6664b404407c..6d9b25ec94af 100644 --- a/python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py +++ b/python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py @@ -28,7 +28,8 @@ from chromadb.api import ClientAPI except ImportError as e: raise ImportError( - "To use the ChromaDBVectorMemory the chromadb extra must be installed. Run `pip install autogen-ext[chromadb]`" + f"To use the ChromaDBVectorMemory the chromadb extra must be installed. Original error: {e}\n" + "Run `pip install autogen-ext[chromadb]`" ) from e diff --git a/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py b/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py index a1057bbd6b37..a662c5daf763 100644 --- a/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py +++ b/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py @@ -15,7 +15,10 @@ from redisvl.utils.utils import deserialize, serialize from redisvl.utils.vectorize import HFTextVectorizer except ImportError as e: - raise ImportError("To use Redis Memory RedisVL must be installed. Run `pip install autogen-ext[redisvl]`") from e + raise ImportError( + f"To use Redis Memory RedisVL must be installed. Original error: {e}\n" + "Run `pip install autogen-ext[redisvl]`" + ) from e class RedisMemoryConfig(BaseModel): diff --git a/python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/__init__.py b/python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/__init__.py index 0324e4005a09..fcb6132049de 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/__init__.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/__init__.py @@ -2,7 +2,7 @@ from ._llama_cpp_completion_client import LlamaCppChatCompletionClient except ImportError as e: raise ImportError( - "Dependencies for Llama Cpp not found. " + f"Dependencies for Llama Cpp not found. Original error: {e}\n" "Please install llama-cpp-python: " "pip install autogen-ext[llama-cpp]" ) from e diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/__init__.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/__init__.py index dacfa6b0be45..b78cf3835ca7 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/__init__.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/__init__.py @@ -6,7 +6,8 @@ import grpc # type: ignore except ImportError as e: raise ImportError( - "To use the GRPC runtime the grpc extra must be installed. Run `pip install autogen-ext[grpc]`" + f"To use the GRPC runtime the grpc extra must be installed. Original error: {e}\n" + "Run `pip install autogen-ext[grpc]`" ) from e __all__ = [ diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py index 6a3963586e18..8efb96f46f40 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py @@ -66,7 +66,7 @@ try: import grpc.aio except ImportError as e: - raise ImportError(GRPC_IMPORT_ERROR_STR) from e + raise ImportError(f"{GRPC_IMPORT_ERROR_STR} Original error: {e}") from e if TYPE_CHECKING: from .protos.agent_worker_pb2_grpc import AgentRpcAsyncStub diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host.py index 04e941215929..2c678d26913d 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host.py @@ -10,7 +10,7 @@ try: import grpc except ImportError as e: - raise ImportError(GRPC_IMPORT_ERROR_STR) from e + raise ImportError(f"{GRPC_IMPORT_ERROR_STR} Original error: {e}") from e from .protos import agent_worker_pb2_grpc logger = logging.getLogger("autogen_core") diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py index 1c0b57a440ed..20702c099c20 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py @@ -16,7 +16,7 @@ try: import grpc except ImportError as e: - raise ImportError(GRPC_IMPORT_ERROR_STR) from e + raise ImportError(f"{GRPC_IMPORT_ERROR_STR} Original error: {e}") from e from .protos import agent_worker_pb2, agent_worker_pb2_grpc, cloudevent_pb2 diff --git a/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py b/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py index eb77f78df79c..c86f040ba278 100644 --- a/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py +++ b/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py @@ -154,11 +154,11 @@ async def _get_embedding(self, query: str) -> List[float]: from openai import AsyncAzureOpenAI from azure.identity import DefaultAzureCredential - except ImportError: + except ImportError as e: raise ImportError( - "Azure OpenAI SDK is required for client-side embedding generation. " + f"Azure OpenAI SDK is required for client-side embedding generation. Original error: {e}\n" "Please install it with: uv add openai azure-identity" - ) from None + ) from e api_key = getattr(search_config, "openai_api_key", None) api_version = getattr(search_config, "openai_api_version", "2023-11-01") @@ -193,11 +193,11 @@ def get_token() -> str: elif embedding_provider.lower() == "openai": try: from openai import AsyncOpenAI - except ImportError: + except ImportError as e: raise ImportError( - "OpenAI SDK is required for client-side embedding generation. " + f"OpenAI SDK is required for client-side embedding generation. Original error: {e}\n" "Please install it with: uv add openai" - ) from None + ) from e api_key = getattr(search_config, "openai_api_key", None) openai_client = AsyncOpenAI(api_key=api_key)