Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix(python-sdk): don't abort openai instrumentation on missing attributes (#1328)

silvercondoraba7d98e9ed6
diff --git a/sdk/python/src/openlit/instrumentation/openai/__init__.py b/sdk/python/src/openlit/instrumentation/openai/__init__.py
index c112c3a5..90ddfbf1 100644
--- a/sdk/python/src/openlit/instrumentation/openai/__init__.py
+++ b/sdk/python/src/openlit/instrumentation/openai/__init__.py
@@ -141,12 +141,12 @@ def _standard_args(
def _safe_wrap(module, class_method, wrapper):
- """Wrap a function, silently skipping if the module doesn't exist in this SDK version."""
+ """Wrap a function, silently skipping if the module or attribute doesn't exist in this SDK version."""
try:
wrap_function_wrapper(module, class_method, wrapper)
- except ModuleNotFoundError:
+ except (ModuleNotFoundError, AttributeError):
logger.debug(
- "Skipping %s.%s — module not in this openai version", module, class_method
+ "Skipping %s.%s — not in this openai version", module, class_method
)