Skip to content

Commit

Permalink
allow host env opt out
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 committed Apr 30, 2024
1 parent 97ecd3a commit 4c1623c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def init(api_key: Optional[str] = None,
override: Optional[bool] = None, # Deprecated
instrument_llm_calls=True,
auto_start_session=True,
inherited_session_id: Optional[str] = None
inherited_session_id: Optional[str] = None,
env_data_opt_out: Optional[bool] = False
):
"""
Initializes the AgentOps singleton pattern.
Expand All @@ -42,6 +43,7 @@ def init(api_key: Optional[str] = None,
instrument_llm_calls (bool): Whether to instrument LLM calls and emit LLMEvents..
auto_start_session (bool): Whether to start a session automatically when the client is created.
inherited_session_id (optional, str): Init Agentops with an existing Session
env_data_opt_out (optional, bool): Opt out of AgentOps tracking environment data for debugging like storage, memory and CPU
Attributes:
"""
set_logging_level_info()
Expand All @@ -54,7 +56,8 @@ def init(api_key: Optional[str] = None,
override=override,
instrument_llm_calls=instrument_llm_calls,
auto_start_session=auto_start_session,
inherited_session_id=inherited_session_id
inherited_session_id=inherited_session_id,
env_data_opt_out=env_data_opt_out
)

return inherited_session_id or c.current_session_id
Expand Down
8 changes: 6 additions & 2 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Client(metaclass=MetaClient):
instrument_llm_calls (bool): Whether to instrument LLM calls and emit LLMEvents..
auto_start_session (bool): Whether to start a session automatically when the client is created.
inherited_session_id (optional, str): Init Agentops with an existing Session
env_data_opt_out (optional, bool): Opt out of AgentOps tracking environment data for debugging like storage, memory and CPU
Attributes:
_session (Session, optional): A Session is a grouping of events (e.g. a run of your agent).
_worker (Worker, optional): A Worker manages the event queue and sends session updates to the AgentOps api server
Expand All @@ -65,7 +66,8 @@ def __init__(self,
override: Optional[bool] = None, # Deprecated
instrument_llm_calls=True,
auto_start_session=True,
inherited_session_id: Optional[str] = None
inherited_session_id: Optional[str] = None,
env_data_opt_out: Optional[bool] = False
):

if override is not None:
Expand All @@ -77,6 +79,8 @@ def __init__(self,
self._worker = None
self._tags = tags

self._env_data_opt_out = env_data_opt_out

try:
self.config = Configuration(api_key=api_key,
parent_key=parent_key,
Expand Down Expand Up @@ -234,7 +238,7 @@ def start_session(self, tags: Optional[List[str]] = None, config: Optional[Confi
if not config and not self.config:
return logger.warning("🖇 AgentOps: Cannot start session - missing configuration")

self._session = Session(inherited_session_id or uuid4(), tags or self._tags, host_env=get_host_env())
self._session = Session(inherited_session_id or uuid4(), tags or self._tags, host_env=(get_host_env() if self._env_data_opt_out else None))
self._worker = Worker(config or self.config)
start_session_result = self._worker.start_session(self._session)
if not start_session_result:
Expand Down

0 comments on commit 4c1623c

Please sign in to comment.