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

Misc

Howard Gil7af1c03cd1fa
diff --git a/agentops/client.py b/agentops/client.py
index 700bbcda..dd197df6 100644
--- a/agentops/client.py
+++ b/agentops/client.py
@@ -157,6 +157,7 @@ class Client(metaclass=MetaClient):
action_type=event_name)
try:
+ self.record(event) # REMOVE
returns = func(*args, **kwargs)
# If the function returns multiple values, record them all in the same event
@@ -193,6 +194,7 @@ class Client(metaclass=MetaClient):
action_type=event_name)
try:
+ self.record(event) # REMOVE
returns = await func(*args, **kwargs)
diff --git a/agentops/config.py b/agentops/config.py
index 7f7b470c..2755916c 100644
--- a/agentops/config.py
+++ b/agentops/config.py
@@ -6,6 +6,7 @@ Classes:
"""
from typing import Optional
+from os import environ
class Configuration:
@@ -20,7 +21,7 @@ class Configuration:
"""
def __init__(self, api_key: str,
- endpoint: Optional[str] = 'https://api.agentops.ai',
+ endpoint: Optional[str] = environ.get('AGENTOPS_API_ENDPOINT', 'https://api.agentops.ai'),
max_wait_time: Optional[int] = 1000, max_queue_size: Optional[int] = 100):
self._api_key: str = api_key
self._endpoint = endpoint
diff --git a/agentops/event.py b/agentops/event.py
index dca658bd..bbfb2989 100644
--- a/agentops/event.py
+++ b/agentops/event.py
@@ -70,7 +70,7 @@ class Error():
def __init__(self, event: Event = None, **kwargs):
self.event_type = "errors" # Temporary to accomodate /events endpoint. Won't be necessary with /errors endpoint
- self.timestamp = get_ISO_time() # TODO: Evaluate if this is correct
+ self.timestamp = get_ISO_time()
if event:
self.trigger_event_id = event.id
self.trigger_event_type = event.event_type
diff --git a/agentops/meta_client.py b/agentops/meta_client.py
index 9ae9f051..0beb3ae9 100644
--- a/agentops/meta_client.py
+++ b/agentops/meta_client.py
@@ -1,11 +1,11 @@
import logging
-import toml
import traceback
from .host_env import get_host_env
from .http_client import HttpClient
from .helpers import safe_serialize
from importlib.metadata import version
+from os import environ
class MetaClient(type):
@@ -32,7 +32,9 @@ class MetaClient(type):
"stack_trace": exception_traceback,
"host_env": get_host_env()
}
- HttpClient.post("https://api.agentops.ai/developer_errors",
+
+ endpoint = environ.get('AGENTOPS_API_ENDPOINT', 'https://api.agentops.ai') # TODO
+ HttpClient.post(endpoint+"/developer_errors",
safe_serialize(developer_error).encode("utf-8"),
api_key=api_key)
@@ -46,7 +48,7 @@ def handle_exceptions(method):
except Exception as e:
type(self).send_exception_to_server(e, self.config._api_key)
logging.warning(f"AgentOps: Error: {e}")
- # raise e
+ raise e
return wrapper