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
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
Misc
Howard Gil7af1c03cd1fa
diff --git a/agentops/client.py b/agentops/client.pyindex 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) # REMOVEreturns = 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) # REMOVEreturns = await func(*args, **kwargs)diff --git a/agentops/config.py b/agentops/config.pyindex 7f7b470c..2755916c 100644--- a/agentops/config.py+++ b/agentops/config.py@@ -6,6 +6,7 @@ Classes:"""from typing import Optional+from os import environclass 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_keyself._endpoint = endpointdiff --git a/agentops/event.py b/agentops/event.pyindex 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.idself.trigger_event_type = event.event_typediff --git a/agentops/meta_client.py b/agentops/meta_client.pyindex 9ae9f051..0beb3ae9 100644--- a/agentops/meta_client.py+++ b/agentops/meta_client.py@@ -1,11 +1,11 @@import logging-import tomlimport tracebackfrom .host_env import get_host_envfrom .http_client import HttpClientfrom .helpers import safe_serializefrom importlib.metadata import version+from os import environclass 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 ereturn wrapper