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
changed callback import from init
reibs10452befdf82
diff --git a/agentops/__init__.py b/agentops/__init__.pyindex 523208eb..4dc51d37 100755--- a/agentops/__init__.py+++ b/agentops/__init__.py@@ -2,4 +2,3 @@ from .client import Clientfrom .event import Eventfrom .logger import AgentOpsLoggerfrom .helpers import Models-from .langchain_callback_handler import LangchainCallbackHandler, AsyncLangchainCallbackHandlerdiff --git a/agentops/client.py b/agentops/client.pyindex eb46889b..98b90657 100644--- a/agentops/client.py+++ b/agentops/client.py@@ -14,6 +14,7 @@ from typing import Optional, Listfrom pydantic import Fieldfrom os import environimport functools+import tracebackimport loggingimport inspectimport atexit@@ -89,24 +90,28 @@ class Client:exc_value (BaseException): The exception instance.exc_traceback (TracebackType): A traceback object encapsulating the call stack at the point where the exception originally occurred."""- # Perform cleanup+ formatted_traceback = ''.join(traceback.format_exception(exc_type, exc_value,+ exc_traceback))++ # Perform cleanup)self.cleanup(- end_state_reason=f"{str(exc_value)}: {str(exc_traceback)}")+ end_state_reason=f"{str(exc_value)}: {formatted_traceback}")# Then call the default excepthook to exit the programsys.__excepthook__(exc_type, exc_value, exc_traceback)- def signal_handler(self, signal, frame):+ def signal_handler(self, signum, frame):"""Signal handler for SIGINT (Ctrl+C) and SIGTERM. Ends the session and exits the program.Args:- signal (int): The signal number.+ signum (int): The signal number.frame: The current stack frame."""- logging.info('Signal SIGTERM or SIGINT detected. Ending session...')+ signal_name = 'SIGINT' if signum == signal.SIGINT else 'SIGTERM'+ logging.info(f'Signal {signal_name} detected. Ending session...')self.end_session(end_state='Fail',- end_state_reason='Signal SIGTERM or SIGINT detected')+ end_state_reason=f'Signal {signal_name} detected')sys.exit(0)def record(self, event: Event):diff --git a/examples/langchain_examples.ipynb b/examples/langchain_examples.ipynbindex 746a5a46..469b0226 100644--- a/examples/langchain_examples.ipynb+++ b/examples/langchain_examples.ipynb@@ -51,7 +51,7 @@},"outputs": [],"source": [- "from agentops import LangchainCallbackHandler"+ "from agentops.langchain_callback_handler import LangchainCallbackHandler"]},{@@ -290,7 +290,7 @@"metadata": {},"outputs": [],"source": [- "from agentops import AsyncLangchainCallbackHandler"+ "from agentops.langchain_callback_handler import AsyncLangchainCallbackHandler"]},{