From cf1ca9fd968d41312c9ee788a53e5017234371cf Mon Sep 17 00:00:00 2001 From: Howard Gil Date: Wed, 15 May 2024 15:55:12 -0700 Subject: [PATCH] Fixed typo that was causing crash when not using autogen (#207) * Fixed typo * Added error info --- agentops/client.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/agentops/client.py b/agentops/client.py index 92653f1e..049b49db 100644 --- a/agentops/client.py +++ b/agentops/client.py @@ -82,7 +82,6 @@ def __init__(self, self._tags: Optional[List[str]] = tags self._tags_for_future_session: Optional[List[str]] = None - self._env_data_opt_out = os.getenv('AGENTOPS_ENV_DATA_OPT_OUT') and os.getenv( 'AGENTOPS_ENV_DATA_OPT_OUT').lower() == 'true' @@ -97,7 +96,8 @@ def __init__(self, self._handle_unclean_exits() - instrument_llm_calls, auto_start_session = self._check_for_partner_frameworks(instrument_llm_calls, auto_start_session) + instrument_llm_calls, auto_start_session = self._check_for_partner_frameworks( + instrument_llm_calls, auto_start_session) if auto_start_session: self.start_session(tags, self.config, inherited_session_id) @@ -113,11 +113,16 @@ def _check_for_partner_frameworks(self, instrument_llm_calls, auto_start_session for framework in partner_frameworks.keys(): if framework in sys.modules: self.add_tags([framework]) - if 'autogen': - import autogen - autogen.runtime_logging.start(logger_type="agentops") + if framework == 'autogen': + try: + import autogen + autogen.runtime_logging.start(logger_type="agentops") + except ImportError: + pass + except Exception as e: + logger.warning("🖇️ AgentOps: Failed to set up autogen logger with AgentOps. Error: " + e) - return partner_frameworks[framework] + return partner_frameworks[framework] return instrument_llm_calls, auto_start_session @@ -402,4 +407,5 @@ def parent_key(self): return self.config.parent_key def stop_instrumenting(self): - self.llm_tracker.stop_instrumenting() + if self.llm_tracker: + self.llm_tracker.stop_instrumenting()