Skip to content

Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI

fix methods without __version__ not getting patched

reibs9a29b88fcd09
diff --git a/agentops/llm_tracker.py b/agentops/llm_tracker.py
index 9350ab9c..8745c7e2 100644
--- a/agentops/llm_tracker.py
+++ b/agentops/llm_tracker.py
@@ -296,8 +296,8 @@ class LlmTracker:
if module_version >= parse('1.0.0'):
self.override_openai_v1_completion()
self.override_openai_v1_async_completion()
+ return
# Patch openai <v1.0.0 methods
- else:
- for method_path in self.SUPPORTED_APIS['openai']['0.0.0']:
- self._override_method(api, method_path, module)
+ for method_path in self.SUPPORTED_APIS['openai']['0.0.0']:
+ self._override_method(api, method_path, module)
diff --git a/tests/openai_handlers/test_handler_openai_v0.py b/tests/openai_handlers/test_handler_openai_v0.py
index c1ed32fa..719470ba 100644
--- a/tests/openai_handlers/test_handler_openai_v0.py
+++ b/tests/openai_handlers/test_handler_openai_v0.py
@@ -3,11 +3,14 @@ import openai
import agentops
import asyncio
import os
+import pkg_resources
print('Running OpenAI <v1.0.0')
-ao_client = agentops.Client(tags=['mock tests'])
+ao_client = agentops.Client(
+ tags=['mock tests', pkg_resources.get_distribution('openai').version]
+)
openai.api_key = os.environ['OPENAI_API_KEY']
diff --git a/tests/openai_handlers/test_handler_openai_v1.py b/tests/openai_handlers/test_handler_openai_v1.py
index 39c3212f..888f9fc4 100644
--- a/tests/openai_handlers/test_handler_openai_v1.py
+++ b/tests/openai_handlers/test_handler_openai_v1.py
@@ -16,7 +16,7 @@ print('Running OpenAI v1.0.0+')
# Assuming that instantiating agentops.Client will trigger the LlmTracker to override methods
-ao_client = agentops.Client(tags=['mock agent'])
+ao_client = agentops.Client(tags=['mock agent', openai.__version__])
# Now the client.chat.completions.create should be the overridden method