forked from MULTI-ON/cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulling agentops integration out into separate class file
- Loading branch information
Showing
2 changed files
with
115 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from agentops import Client, Event | ||
from typing import List | ||
import os | ||
|
||
|
||
class AgentOpsClient: | ||
def __init__(self): | ||
self._api_key = None | ||
self._org_key = None | ||
self._client = None | ||
self.current_event = Event() | ||
|
||
@property | ||
def api_key(self): | ||
return self._api_key if self._api_key else os.getenv("AGENTOPS_API_KEY") | ||
|
||
@api_key.setter | ||
def api_key(self, value): | ||
self._api_key = value | ||
if value: | ||
os.environ["AGENTOPS_API_KEY"] = value | ||
|
||
@property | ||
def org_key(self): | ||
return self._org_key | ||
|
||
@api_key.setter | ||
def org_key(self, value): | ||
self.org_key = value | ||
|
||
# TODO: Call the setter to create the client | ||
@property | ||
def client(self): | ||
# if not self._client: | ||
# self.client = None | ||
return self._client | ||
|
||
@client.setter | ||
def client(self, tags: List[str] = ["multion"]): | ||
self._client = Client(api_key=self.api_key, | ||
tags=tags, | ||
org_key=self.org_key) | ||
|
||
def record(self): | ||
if self.client: | ||
self.client.record(self.current_event) | ||
|
||
def end_session(self): | ||
self.client.end_session(end_state="Success") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters