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
terminal logs in jupyter notebooks (#1049)
koreandinnera61baa6d1321
diff --git a/agentops/__init__.py b/agentops/__init__.pyindex 2f10c142..e4d48055 100755--- a/agentops/__init__.py+++ b/agentops/__init__.py@@ -116,6 +116,13 @@ def init(elif default_tags:merged_tags = default_tags+ # Check if in a Jupyter Notebook (manual start/end_trace())+ try:+ get_ipython().__class__.__name__ == "ZMQInteractiveShell" # type: ignore+ auto_start_session = False+ except NameError:+ pass+# Prepare initialization argumentsinit_kwargs = {"api_key": api_key,diff --git a/agentops/instrumentation/__init__.py b/agentops/instrumentation/__init__.pyindex cb4a6b88..86740a62 100644--- a/agentops/instrumentation/__init__.py+++ b/agentops/instrumentation/__init__.py@@ -35,7 +35,6 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor # type:from agentops.logging import loggerfrom agentops.sdk.core import tracer-# Module-level state variables_active_instrumentors: list[BaseInstrumentor] = []_original_builtins_import = builtins.__import__ # Store original importdiff --git a/docs/v2/usage/sdk-reference.mdx b/docs/v2/usage/sdk-reference.mdxindex bfb1d65f..9d4812d2 100644--- a/docs/v2/usage/sdk-reference.mdx+++ b/docs/v2/usage/sdk-reference.mdx@@ -29,7 +29,7 @@ Initializes the AgentOps SDK and automatically starts tracking your application.- `default_tags` (List[str], optional): Default tags for the sessions that can be used for grouping or sorting later (e.g. ["GPT-4"]).- `tags` (List[str], optional): [Deprecated] Use `default_tags` instead.- `instrument_llm_calls` (bool, optional): Whether to instrument LLM calls automatically. Defaults to True.-- `auto_start_session` (bool, optional): Whether to start a session automatically when the client is created. Defaults to True.+- `auto_start_session` (bool, optional): Whether to start a session automatically when the client is created. Set to False if running in a Jupyter Notebook. Defaults to True.- `auto_init` (bool, optional): Whether to automatically initialize the client on import. Defaults to True.- `skip_auto_end_session` (bool, optional): Don't automatically end session based on your framework's decision-making. Defaults to False.- `env_data_opt_out` (bool, optional): Whether to opt out of collecting environment data. Defaults to False.diff --git a/examples/openai_agents/customer_service_agent.ipynb b/examples/openai_agents/customer_service_agent.ipynbindex 6135c44d..1485d3ee 100644--- a/examples/openai_agents/customer_service_agent.ipynb+++ b/examples/openai_agents/customer_service_agent.ipynb@@ -96,7 +96,7 @@"metadata": {},"outputs": [],"source": [- "agentops.init(tags=[\"customer-service-agent\", \"openai-agents\", \"agentops-example\"], auto_start_session=False)\n",+ "agentops.init(tags=[\"customer-service-agent\", \"openai-agents\", \"agentops-example\"])\n","tracer = agentops.start_trace(trace_name=\"Customer Service Agent\")"]},