diff --git a/examples/mistral/create_notebook.py b/examples/mistral/create_notebook.py index 18371469..ab477f40 100644 --- a/examples/mistral/create_notebook.py +++ b/examples/mistral/create_notebook.py @@ -1,6 +1,14 @@ -import nbformat as nbf -import asyncio import os +import nbformat as nbf +import sys +from pathlib import Path + +# Add agentops to path if needed +if str(Path.home() / "repos/agentops") not in sys.path: + sys.path.append(str(Path.home() / "repos/agentops")) + +from agentops.session import EndState # Import EndState at the top level +import agentops nb = nbf.v4.new_notebook() @@ -287,6 +295,7 @@ def analyze_costs(prompts): ), nbf.v4.new_code_cell( '''# Start a new analysis session +from agentops.session import EndState # Import EndState from correct module session = agentops.start_session() def comprehensive_analysis(): @@ -310,11 +319,18 @@ def comprehensive_analysis(): continue with agent: # Use context manager for proper tracking - response = client.chat.complete( - model="mistral-small-latest", - messages=[{"role": "user", "content": prompt}] - ) - results.append(response.choices[0].message.content) + try: + response = client.chat.complete( + model="mistral-small-latest", + messages=[{"role": "user", "content": prompt}] + ) + results.append(response.choices[0].message.content) + except AttributeError: + print("Client not initialized. Using placeholder response.") + results.append("This is a placeholder response. Please set valid API keys.") + except Exception as e: + print(f"Error during completion: {str(e)}") + results.append(f"Error: {str(e)}") # Analyze results for i, (prompt, result) in enumerate(zip(prompts, results)): @@ -334,7 +350,7 @@ def comprehensive_analysis(): # End the session with proper status print("Ending AgentOps session...") try: - session.end(agentops.EndState.COMPLETED) + session.end(EndState.COMPLETED) # Use imported EndState except Exception as e: print(f"Error ending session: {str(e)}") print("Session ended successfully")''' diff --git a/examples/mistral/monitoring_mistral.ipynb b/examples/mistral/monitoring_mistral.ipynb index 88486571..307a741b 100644 --- a/examples/mistral/monitoring_mistral.ipynb +++ b/examples/mistral/monitoring_mistral.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "98c85b11", + "id": "5f07a0f2", "metadata": {}, "source": [ "# Monitoring Mistral with AgentOps\n", @@ -33,13 +33,13 @@ { "cell_type": "code", "execution_count": 1, - "id": "95091dc2", + "id": "b87f1d86", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:45.260537Z", - "iopub.status.busy": "2024-12-13T05:36:45.260312Z", - "iopub.status.idle": "2024-12-13T05:36:46.343959Z", - "shell.execute_reply": "2024-12-13T05:36:46.343179Z" + "iopub.execute_input": "2024-12-13T05:38:59.899761Z", + "iopub.status.busy": "2024-12-13T05:38:59.899532Z", + "iopub.status.idle": "2024-12-13T05:39:01.009605Z", + "shell.execute_reply": "2024-12-13T05:39:01.008801Z" } }, "outputs": [ @@ -54,14 +54,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: agentops in /home/ubuntu/repos/agentops (0.3.21)\r\n", - "Requirement already satisfied: python-dotenv in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (1.0.1)\r\n" + "Requirement already satisfied: agentops in /home/ubuntu/repos/agentops (0.3.21)\r\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ + "Requirement already satisfied: python-dotenv in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (1.0.1)\r\n", "Requirement already satisfied: eval-type-backport<0.3.0,>=0.2.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from mistralai) (0.2.0)\r\n", "Requirement already satisfied: httpx<0.28.0,>=0.27.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from mistralai) (0.27.2)\r\n", "Requirement already satisfied: jsonpath-python<2.0.0,>=1.0.6 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from mistralai) (1.0.6)\r\n", @@ -83,20 +83,20 @@ "Requirement already satisfied: h11<0.15,>=0.13 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from httpcore==1.*->httpx<0.28.0,>=0.27.0->mistralai) (0.14.0)\r\n", "Requirement already satisfied: deprecated>=1.2.6 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-api<2.0.0,>=1.22.0->agentops) (1.2.15)\r\n", "Requirement already satisfied: importlib-metadata<=8.5.0,>=6.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-api<2.0.0,>=1.22.0->agentops) (8.5.0)\r\n", - "Requirement already satisfied: googleapis-common-protos~=1.52 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (1.66.0)\r\n", - "Requirement already satisfied: opentelemetry-exporter-otlp-proto-common==1.28.2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (1.28.2)\r\n", - "Requirement already satisfied: opentelemetry-proto==1.28.2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (1.28.2)\r\n", - "Requirement already satisfied: protobuf<6.0,>=5.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-proto==1.28.2->opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (5.29.1)\r\n", - "Requirement already satisfied: opentelemetry-semantic-conventions==0.49b2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-sdk<2.0.0,>=1.22.0->agentops) (0.49b2)\r\n", - "Requirement already satisfied: typing-extensions>=3.7.4 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-sdk<2.0.0,>=1.22.0->agentops) (4.12.2)\r\n", - "Requirement already satisfied: annotated-types>=0.6.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.9.0->mistralai) (0.7.0)\r\n", - "Requirement already satisfied: pydantic-core==2.27.1 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.9.0->mistralai) (2.27.1)\r\n" + "Requirement already satisfied: googleapis-common-protos~=1.52 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (1.66.0)\r\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-common==1.28.2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (1.28.2)\r\n", + "Requirement already satisfied: opentelemetry-proto==1.28.2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (1.28.2)\r\n", + "Requirement already satisfied: protobuf<6.0,>=5.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-proto==1.28.2->opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0->agentops) (5.29.1)\r\n", + "Requirement already satisfied: opentelemetry-semantic-conventions==0.49b2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-sdk<2.0.0,>=1.22.0->agentops) (0.49b2)\r\n", + "Requirement already satisfied: typing-extensions>=3.7.4 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from opentelemetry-sdk<2.0.0,>=1.22.0->agentops) (4.12.2)\r\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.9.0->mistralai) (0.7.0)\r\n", + "Requirement already satisfied: pydantic-core==2.27.1 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.9.0->mistralai) (2.27.1)\r\n", "Requirement already satisfied: six>=1.5 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from python-dateutil<3.0.0,>=2.8.2->mistralai) (1.17.0)\r\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.4.0)\r\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/ubuntu/.pyenv/versions/3.12.7/lib/python3.12/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2.2.3)\r\n", @@ -128,7 +128,7 @@ }, { "cell_type": "markdown", - "id": "a3f8635d", + "id": "c211da48", "metadata": {}, "source": [ "Import dependencies and initialize clients:" @@ -137,13 +137,13 @@ { "cell_type": "code", "execution_count": 2, - "id": "1160496b", + "id": "406eab6c", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:46.346741Z", - "iopub.status.busy": "2024-12-13T05:36:46.346503Z", - "iopub.status.idle": "2024-12-13T05:36:47.687974Z", - "shell.execute_reply": "2024-12-13T05:36:47.687209Z" + "iopub.execute_input": "2024-12-13T05:39:01.012351Z", + "iopub.status.busy": "2024-12-13T05:39:01.012101Z", + "iopub.status.idle": "2024-12-13T05:39:03.704545Z", + "shell.execute_reply": "2024-12-13T05:39:03.703650Z" } }, "outputs": [ @@ -159,7 +159,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=0c56c3e1-0d6d-4585-aad4-ad9e8af7404c\u001b[0m\u001b[0m\n" + "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=b422759d-d29a-48fa-b8de-8bd3320a3878\u001b[0m\u001b[0m\n" ] }, { @@ -211,7 +211,7 @@ }, { "cell_type": "markdown", - "id": "e6afa325", + "id": "945e4b2c", "metadata": {}, "source": [ "## Basic Completion with Monitoring\n", @@ -222,13 +222,13 @@ { "cell_type": "code", "execution_count": 3, - "id": "30b0ad86", + "id": "cf6c03fb", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:47.690483Z", - "iopub.status.busy": "2024-12-13T05:36:47.690257Z", - "iopub.status.idle": "2024-12-13T05:36:47.786470Z", - "shell.execute_reply": "2024-12-13T05:36:47.785719Z" + "iopub.execute_input": "2024-12-13T05:39:03.707145Z", + "iopub.status.busy": "2024-12-13T05:39:03.706898Z", + "iopub.status.idle": "2024-12-13T05:39:03.802925Z", + "shell.execute_reply": "2024-12-13T05:39:03.802075Z" } }, "outputs": [ @@ -264,7 +264,7 @@ }, { "cell_type": "markdown", - "id": "f01d8867", + "id": "f8090521", "metadata": {}, "source": [ "## Streaming Responses\n", @@ -275,13 +275,13 @@ { "cell_type": "code", "execution_count": 4, - "id": "9877b34b", + "id": "a9da9354", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:47.788890Z", - "iopub.status.busy": "2024-12-13T05:36:47.788666Z", - "iopub.status.idle": "2024-12-13T05:36:47.881449Z", - "shell.execute_reply": "2024-12-13T05:36:47.880728Z" + "iopub.execute_input": "2024-12-13T05:39:03.805492Z", + "iopub.status.busy": "2024-12-13T05:39:03.805284Z", + "iopub.status.idle": "2024-12-13T05:39:03.941413Z", + "shell.execute_reply": "2024-12-13T05:39:03.940525Z" } }, "outputs": [ @@ -324,7 +324,7 @@ }, { "cell_type": "markdown", - "id": "05595e54", + "id": "d9228431", "metadata": {}, "source": [ "## Async Operations\n", @@ -335,13 +335,13 @@ { "cell_type": "code", "execution_count": 5, - "id": "eb828cf5", + "id": "2daff87f", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:47.883850Z", - "iopub.status.busy": "2024-12-13T05:36:47.883616Z", - "iopub.status.idle": "2024-12-13T05:36:47.973710Z", - "shell.execute_reply": "2024-12-13T05:36:47.972986Z" + "iopub.execute_input": "2024-12-13T05:39:03.943951Z", + "iopub.status.busy": "2024-12-13T05:39:03.943730Z", + "iopub.status.idle": "2024-12-13T05:39:04.048385Z", + "shell.execute_reply": "2024-12-13T05:39:04.047483Z" } }, "outputs": [ @@ -377,7 +377,7 @@ }, { "cell_type": "markdown", - "id": "71cc1535", + "id": "556d0561", "metadata": {}, "source": [ "## Error Handling and Debugging\n", @@ -390,13 +390,13 @@ { "cell_type": "code", "execution_count": 6, - "id": "37288e82", + "id": "810272a0", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:47.976208Z", - "iopub.status.busy": "2024-12-13T05:36:47.976005Z", - "iopub.status.idle": "2024-12-13T05:36:48.064592Z", - "shell.execute_reply": "2024-12-13T05:36:48.063860Z" + "iopub.execute_input": "2024-12-13T05:39:04.050784Z", + "iopub.status.busy": "2024-12-13T05:39:04.050571Z", + "iopub.status.idle": "2024-12-13T05:39:04.151355Z", + "shell.execute_reply": "2024-12-13T05:39:04.150529Z" } }, "outputs": [ @@ -434,7 +434,7 @@ }, { "cell_type": "markdown", - "id": "a71b1bb6", + "id": "becbec6a", "metadata": {}, "source": [ "## Cost Tracking and Optimization\n", @@ -451,13 +451,13 @@ { "cell_type": "code", "execution_count": 7, - "id": "6e6d0be5", + "id": "b5050013", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:48.067221Z", - "iopub.status.busy": "2024-12-13T05:36:48.067006Z", - "iopub.status.idle": "2024-12-13T05:36:48.165379Z", - "shell.execute_reply": "2024-12-13T05:36:48.164640Z" + "iopub.execute_input": "2024-12-13T05:39:04.153858Z", + "iopub.status.busy": "2024-12-13T05:39:04.153648Z", + "iopub.status.idle": "2024-12-13T05:39:04.253409Z", + "shell.execute_reply": "2024-12-13T05:39:04.252519Z" } }, "outputs": [ @@ -515,7 +515,7 @@ }, { "cell_type": "markdown", - "id": "1f558504", + "id": "a7619da6", "metadata": {}, "source": [ "## Session Replay and Analysis\n", @@ -532,13 +532,13 @@ { "cell_type": "code", "execution_count": 8, - "id": "5361f419", + "id": "90198c89", "metadata": { "execution": { - "iopub.execute_input": "2024-12-13T05:36:48.167998Z", - "iopub.status.busy": "2024-12-13T05:36:48.167712Z", - "iopub.status.idle": "2024-12-13T05:36:48.537519Z", - "shell.execute_reply": "2024-12-13T05:36:48.536788Z" + "iopub.execute_input": "2024-12-13T05:39:04.256042Z", + "iopub.status.busy": "2024-12-13T05:39:04.255781Z", + "iopub.status.idle": "2024-12-13T05:39:04.761543Z", + "shell.execute_reply": "2024-12-13T05:39:04.760564Z" } }, "outputs": [ @@ -546,46 +546,32 @@ "name": "stderr", "output_type": "stream", "text": [ - "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=6a0ac391-e138-4646-bd1d-bdd0d540d78b\u001b[0m\u001b[0m\n" + "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=62561fd6-d93e-4cd9-aec1-9619a98498c2\u001b[0m\u001b[0m\n" ] }, { - "name": "stderr", - "output_type": "stream", - "text": [ - "🖇 AgentOps: Multiple sessions detected. You must use session.create_agent(). More info: https://docs.agentops.ai/v1/concepts/core-concepts#session-management\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Using placeholder response for prompt: What is AI?\n", - "Using placeholder response for prompt: Explain the concept of machine learning.\n", - "Using placeholder response for prompt: Write a detailed analysis of artificial intelligence.\n", - "Analysis 1:\n", - "Prompt length: 11 chars\n", - "Response length: 58 chars\n", - "Analysis 2:\n", - "Prompt length: 40 chars\n", - "Response length: 58 chars\n", - "Analysis 3:\n", - "Prompt length: 53 chars\n", - "Response length: 58 chars\n", - "Analysis result: Analysis completed successfully\n", - "Ending AgentOps session...\n", - "Error ending session: module 'agentops' has no attribute 'EndState'\n", - "Session ended successfully\n" + "ename": "TypeError", + "evalue": "Session.create_agent() missing 1 required positional argument: 'agent_id'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[8], line 51\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(e)\n\u001b[1;32m 50\u001b[0m \u001b[38;5;66;03m# Run the analysis\u001b[39;00m\n\u001b[0;32m---> 51\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mcomprehensive_analysis\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 52\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAnalysis result: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresult\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# End the session with proper status\u001b[39;00m\n", + "Cell \u001b[0;32mIn[8], line 8\u001b[0m, in \u001b[0;36mcomprehensive_analysis\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Run a comprehensive analysis of Mistral model behavior.\"\"\"\u001b[39;00m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;66;03m# Create an agent for this analysis\u001b[39;00m\n\u001b[0;32m----> 8\u001b[0m agent \u001b[38;5;241m=\u001b[39m \u001b[43msession\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_agent\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmistral-analyzer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 11\u001b[0m \u001b[38;5;66;03m# Test different scenarios\u001b[39;00m\n\u001b[1;32m 12\u001b[0m prompts \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 13\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat is AI?\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;66;03m# Short prompt\u001b[39;00m\n\u001b[1;32m 14\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExplain the concept of machine learning.\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;66;03m# Medium prompt\u001b[39;00m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWrite a detailed analysis of artificial intelligence.\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;66;03m# Long prompt\u001b[39;00m\n\u001b[1;32m 16\u001b[0m ]\n", + "\u001b[0;31mTypeError\u001b[0m: Session.create_agent() missing 1 required positional argument: 'agent_id'" ] } ], "source": [ "# Start a new analysis session\n", - "agentops.start_session() # Use start_session instead of init\n", + "from agentops.session import EndState # Import EndState from correct module\n", + "session = agentops.start_session()\n", "\n", - "@agentops.track_agent(name=\"mistral-analyzer\")\n", "def comprehensive_analysis():\n", " \"\"\"Run a comprehensive analysis of Mistral model behavior.\"\"\"\n", + " # Create an agent for this analysis\n", + " agent = session.create_agent(name=\"mistral-analyzer\")\n", + "\n", " try:\n", " # Test different scenarios\n", " prompts = [\n", @@ -601,11 +587,19 @@ " results.append(\"This is a placeholder response. Please set valid API keys.\")\n", " continue\n", "\n", - " response = client.chat.complete(\n", - " model=\"mistral-small-latest\",\n", - " messages=[{\"role\": \"user\", \"content\": prompt}]\n", - " )\n", - " results.append(response.choices[0].message.content)\n", + " with agent: # Use context manager for proper tracking\n", + " try:\n", + " response = client.chat.complete(\n", + " model=\"mistral-small-latest\",\n", + " messages=[{\"role\": \"user\", \"content\": prompt}]\n", + " )\n", + " results.append(response.choices[0].message.content)\n", + " except AttributeError:\n", + " print(\"Client not initialized. Using placeholder response.\")\n", + " results.append(\"This is a placeholder response. Please set valid API keys.\")\n", + " except Exception as e:\n", + " print(f\"Error during completion: {str(e)}\")\n", + " results.append(f\"Error: {str(e)}\")\n", "\n", " # Analyze results\n", " for i, (prompt, result) in enumerate(zip(prompts, results)):\n", @@ -625,7 +619,7 @@ "# End the session with proper status\n", "print(\"Ending AgentOps session...\")\n", "try:\n", - " agentops.end_session(agentops.EndState.COMPLETED)\n", + " session.end(EndState.COMPLETED) # Use imported EndState\n", "except Exception as e:\n", " print(f\"Error ending session: {str(e)}\")\n", "print(\"Session ended successfully\")"