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
feature: display warnings to user
Shawn Qiuca5fd28ca915
diff --git a/agentops/http.py b/agentops/http.pyindex a83b3c73..0a3b10e5 100644--- a/agentops/http.py+++ b/agentops/http.py@@ -1,5 +1,6 @@from enum import Enumfrom typing import Optional+import loggingimport requestsfrom requests.adapters import Retry, HTTPAdapter@@ -14,6 +15,7 @@ retry_config = Retry(total=5, backoff_factor=0.1)class HttpStatus(Enum):SUCCESS = 200INVALID_REQUEST = 400+ INVALID_API_KEY = 401TIMEOUT = 408PAYLOAD_TOO_LARGE = 413TOO_MANY_REQUESTS = 429@@ -47,6 +49,8 @@ class Response:return HttpStatus.PAYLOAD_TOO_LARGEelif code == 408:return HttpStatus.TIMEOUT+ elif code == 401:+ return HttpStatus.INVALID_API_KEYelif 400 <= code < 500:return HttpStatus.INVALID_REQUESTelif code >= 500:@@ -74,6 +78,8 @@ class HttpClient:except requests.exceptions.Timeout:result.code = 408result.status = HttpStatus.TIMEOUT+ logging.warn(+ 'AgentOps: Could not post data - connection timed out')except requests.exceptions.HTTPError as e:try:result.parse(e.response)@@ -84,4 +90,11 @@ class HttpClient:result.body = {'error': str(e)}except requests.exceptions.RequestException as e:result.body = {'error': str(e)}++ if result.code == 401:+ logging.warn(+ 'AgentOps: Could not post data - API server rejected your API key')+ if result.code == 400:+ logging.warn(f'AgentOps: Could not post data - {result.body}')+return result