Skip to content

Commit

Permalink
Fixed typo that was causing crash when not using autogen (#207)
Browse files Browse the repository at this point in the history
* Fixed typo

* Added error info
  • Loading branch information
HowieG authored May 15, 2024
1 parent ea6328d commit cf1ca9f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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()

0 comments on commit cf1ca9f

Please sign in to comment.