From b4225d1ed55f1d2550cae2d8b6a44df379dc4046 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Wed, 26 Feb 2025 15:50:37 -0800 Subject: [PATCH] remove agents monitoring notebook --- .../Llama_Stack_Agents_Monitoring.ipynb | 451 ------------------ 1 file changed, 451 deletions(-) delete mode 100644 docs/notebooks/Llama_Stack_Agents_Monitoring.ipynb diff --git a/docs/notebooks/Llama_Stack_Agents_Monitoring.ipynb b/docs/notebooks/Llama_Stack_Agents_Monitoring.ipynb deleted file mode 100644 index 01395400d..000000000 --- a/docs/notebooks/Llama_Stack_Agents_Monitoring.ipynb +++ /dev/null @@ -1,451 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Llama Stack - Agents Evaluation" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "# from llama_stack.distribution.library_client import LlamaStackAsLibraryClient\n", - "from llama_stack_client import LlamaStackClient\n", - "\n", - "# client = LlamaStackAsLibraryClient(\n", - "# \"together\", provider_data = {\"tavily_search_api_key\": os.environ['TAVILY_SEARCH_API_KEY']})\n", - "\n", - "client = LlamaStackClient(base_url=\"http://localhost:8321\")\n", - "# _ = client.initialize()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Building a Search Agent" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [], - "source": [ - "from llama_stack_client.types.agent_create_params import AgentConfig\n", - "from llama_stack_client.lib.agents.agent import Agent\n", - "\n", - "model_id = \"meta-llama/Llama-3.3-70B-Instruct\"\n", - "\n", - "agent_config_with_websearch = AgentConfig(\n", - " model=model_id,\n", - " instructions=\"You are a helpful assistant that can answer questions by searching the web.\",\n", - " sampling_params={\n", - " \"strategy\": {\"type\": \"top_p\", \"temperature\": 1.0, \"top_p\": 0.9},\n", - " },\n", - " toolgroups=[\"builtin::websearch\"],\n", - " tool_config={\n", - " \"tool_choice\": \"auto\",\n", - " \"tool_prompt_format\": \"python_list\",\n", - " },\n", - " input_shields=[],\n", - " output_shields=[],\n", - " enable_session_persistence=False,\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
Turn(\n",
-       "input_messages=[\n",
-       "│   │   UserMessage(content='Who received the IEEE Frank Rosenblatt Award in 2010?', role='user', context=None)\n",
-       "],\n",
-       "output_message=CompletionMessage(\n",
-       "│   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   role='assistant',\n",
-       "│   │   stop_reason='end_of_turn',\n",
-       "│   │   tool_calls=[]\n",
-       "),\n",
-       "session_id='558ddd4a-32f9-4455-b13f-a365dc8b04f7',\n",
-       "started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 917982, tzinfo=TzInfo(-08:00)),\n",
-       "steps=[\n",
-       "│   │   InferenceStep(\n",
-       "│   │   │   api_model_response=CompletionMessage(\n",
-       "│   │   │   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   │   │   role='assistant',\n",
-       "│   │   │   │   stop_reason='end_of_turn',\n",
-       "│   │   │   │   tool_calls=[]\n",
-       "│   │   │   ),\n",
-       "│   │   │   step_id='896d9ebd-5a26-4831-aff4-48bc136b26fc',\n",
-       "│   │   │   step_type='inference',\n",
-       "│   │   │   turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "│   │   │   completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 861070, tzinfo=TzInfo(-08:00)),\n",
-       "│   │   │   started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 929704, tzinfo=TzInfo(-08:00))\n",
-       "│   │   )\n",
-       "],\n",
-       "turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 875151, tzinfo=TzInfo(-08:00)),\n",
-       "output_attachments=[]\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mTurn\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33minput_messages\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mUserMessage\u001b[0m\u001b[1m(\u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'Who received the IEEE Frank Rosenblatt Award in 2010?'\u001b[0m, \u001b[33mrole\u001b[0m=\u001b[32m'user'\u001b[0m, \u001b[33mcontext\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33moutput_message\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33msession_id\u001b[0m=\u001b[32m'558ddd4a-32f9-4455-b13f-a365dc8b04f7'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m917982\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33msteps\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mInferenceStep\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mapi_model_response\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstep_id\u001b[0m=\u001b[32m'896d9ebd-5a26-4831-aff4-48bc136b26fc'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstep_type\u001b[0m=\u001b[32m'inference'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m861070\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m929704\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m875151\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33moutput_attachments\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "import uuid\n", - "from datasets import load_dataset\n", - "from rich.pretty import pprint\n", - "\n", - "# 0. Create an agent\n", - "agent = Agent(client, agent_config_with_websearch)\n", - "\n", - "# 2. Send it a couple of questions in the sesison. Here, we get the first 10 questions from the Simple QA dataset.\n", - "ds = load_dataset(\"llamastack/evals\", \"evals__simpleqa\")\n", - "questions = []\n", - "answers = []\n", - "for idx, x in enumerate(ds[\"train\"]):\n", - " if idx >= 1:\n", - " break\n", - " questions.append(x[\"input_query\"])\n", - " answers.append(x[\"expected_answer\"])\n", - "\n", - "for query in questions:\n", - " # create a new session for each question\n", - " session_id = agent.create_session(f\"{uuid.uuid4().hex}\")\n", - " response = agent.create_turn(\n", - " [\n", - " {\n", - " \"role\": \"user\",\n", - " \"content\": query,\n", - " }\n", - " ], \n", - " session_id=session_id,\n", - " stream=False\n", - " )\n", - " pprint(response)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Examine agent logs" - ] - }, - { - "cell_type": "code", - "execution_count": 70, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
Session(\n",
-       "session_id='558ddd4a-32f9-4455-b13f-a365dc8b04f7',\n",
-       "session_name='260253b6c81a4e2595b3f57e69e54c01',\n",
-       "started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 900529),\n",
-       "turns=[\n",
-       "│   │   Turn(\n",
-       "│   │   │   input_messages=[\n",
-       "│   │   │   │   UserMessage(\n",
-       "│   │   │   │   │   content='Who received the IEEE Frank Rosenblatt Award in 2010?',\n",
-       "│   │   │   │   │   role='user',\n",
-       "│   │   │   │   │   context=None\n",
-       "│   │   │   │   )\n",
-       "│   │   │   ],\n",
-       "│   │   │   output_message=CompletionMessage(\n",
-       "│   │   │   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   │   │   role='assistant',\n",
-       "│   │   │   │   stop_reason='end_of_turn',\n",
-       "│   │   │   │   tool_calls=[]\n",
-       "│   │   │   ),\n",
-       "│   │   │   session_id='558ddd4a-32f9-4455-b13f-a365dc8b04f7',\n",
-       "│   │   │   started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 917982, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n",
-       "│   │   │   steps=[\n",
-       "│   │   │   │   InferenceStep(\n",
-       "│   │   │   │   │   api_model_response=CompletionMessage(\n",
-       "│   │   │   │   │   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   │   │   │   │   role='assistant',\n",
-       "│   │   │   │   │   │   stop_reason='end_of_turn',\n",
-       "│   │   │   │   │   │   tool_calls=[]\n",
-       "│   │   │   │   │   ),\n",
-       "│   │   │   │   │   step_id='896d9ebd-5a26-4831-aff4-48bc136b26fc',\n",
-       "│   │   │   │   │   step_type='inference',\n",
-       "│   │   │   │   │   turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "│   │   │   │   │   completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 861070, tzinfo=TzInfo(-08:00)),\n",
-       "│   │   │   │   │   started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 929704, tzinfo=TzInfo(-08:00))\n",
-       "│   │   │   │   )\n",
-       "│   │   │   ],\n",
-       "│   │   │   turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "│   │   │   completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 875151, tzinfo=TzInfo(-08:00)),\n",
-       "│   │   │   output_attachments=[]\n",
-       "│   │   )\n",
-       "]\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mSession\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33msession_id\u001b[0m=\u001b[32m'558ddd4a-32f9-4455-b13f-a365dc8b04f7'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33msession_name\u001b[0m=\u001b[32m'260253b6c81a4e2595b3f57e69e54c01'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m900529\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mturns\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mTurn\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33minput_messages\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mUserMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'Who received the IEEE Frank Rosenblatt Award in 2010?'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'user'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mcontext\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33moutput_message\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33msession_id\u001b[0m=\u001b[32m'558ddd4a-32f9-4455-b13f-a365dc8b04f7'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m917982\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.timezone\u001b[0m\u001b[1m(\u001b[0m\u001b[1;35mdatetime.timedelta\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdays\u001b[0m=\u001b[1;36m-1\u001b[0m, \u001b[33mseconds\u001b[0m=\u001b[1;36m57600\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33msteps\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mInferenceStep\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mapi_model_response\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ │ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mstep_id\u001b[0m=\u001b[32m'896d9ebd-5a26-4831-aff4-48bc136b26fc'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mstep_type\u001b[0m=\u001b[32m'inference'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m861070\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m929704\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m875151\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33moutput_attachments\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
Turn(\n",
-       "input_messages=[\n",
-       "│   │   UserMessage(content='Who received the IEEE Frank Rosenblatt Award in 2010?', role='user', context=None)\n",
-       "],\n",
-       "output_message=CompletionMessage(\n",
-       "│   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   role='assistant',\n",
-       "│   │   stop_reason='end_of_turn',\n",
-       "│   │   tool_calls=[]\n",
-       "),\n",
-       "session_id='558ddd4a-32f9-4455-b13f-a365dc8b04f7',\n",
-       "started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 917982, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n",
-       "steps=[\n",
-       "│   │   InferenceStep(\n",
-       "│   │   │   api_model_response=CompletionMessage(\n",
-       "│   │   │   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   │   │   role='assistant',\n",
-       "│   │   │   │   stop_reason='end_of_turn',\n",
-       "│   │   │   │   tool_calls=[]\n",
-       "│   │   │   ),\n",
-       "│   │   │   step_id='896d9ebd-5a26-4831-aff4-48bc136b26fc',\n",
-       "│   │   │   step_type='inference',\n",
-       "│   │   │   turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "│   │   │   completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 861070, tzinfo=TzInfo(-08:00)),\n",
-       "│   │   │   started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 929704, tzinfo=TzInfo(-08:00))\n",
-       "│   │   )\n",
-       "],\n",
-       "turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 875151, tzinfo=TzInfo(-08:00)),\n",
-       "output_attachments=[]\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mTurn\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33minput_messages\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mUserMessage\u001b[0m\u001b[1m(\u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'Who received the IEEE Frank Rosenblatt Award in 2010?'\u001b[0m, \u001b[33mrole\u001b[0m=\u001b[32m'user'\u001b[0m, \u001b[33mcontext\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33moutput_message\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33msession_id\u001b[0m=\u001b[32m'558ddd4a-32f9-4455-b13f-a365dc8b04f7'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m917982\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.timezone\u001b[0m\u001b[1m(\u001b[0m\u001b[1;35mdatetime.timedelta\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdays\u001b[0m=\u001b[1;36m-1\u001b[0m, \u001b[33mseconds\u001b[0m=\u001b[1;36m57600\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33msteps\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mInferenceStep\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mapi_model_response\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstep_id\u001b[0m=\u001b[32m'896d9ebd-5a26-4831-aff4-48bc136b26fc'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstep_type\u001b[0m=\u001b[32m'inference'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m861070\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m929704\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m875151\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33moutput_attachments\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
StepRetrieveResponse(\n",
-       "step=InferenceStep(\n",
-       "│   │   api_model_response=CompletionMessage(\n",
-       "│   │   │   content='The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.',\n",
-       "│   │   │   role='assistant',\n",
-       "│   │   │   stop_reason='end_of_turn',\n",
-       "│   │   │   tool_calls=[]\n",
-       "│   │   ),\n",
-       "│   │   step_id='896d9ebd-5a26-4831-aff4-48bc136b26fc',\n",
-       "│   │   step_type='inference',\n",
-       "│   │   turn_id='dcb9c5f1-36c9-4928-b13f-a6e9478a940b',\n",
-       "│   │   completed_at=datetime.datetime(2025, 2, 26, 15, 15, 19, 861070, tzinfo=TzInfo(-08:00)),\n",
-       "│   │   started_at=datetime.datetime(2025, 2, 26, 15, 15, 15, 929704, tzinfo=TzInfo(-08:00))\n",
-       ")\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mStepRetrieveResponse\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mstep\u001b[0m=\u001b[1;35mInferenceStep\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mapi_model_response\u001b[0m=\u001b[1;35mCompletionMessage\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'The IEEE Frank Rosenblatt Award was given to Tomaso Poggio in 2010.'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mstop_reason\u001b[0m=\u001b[32m'end_of_turn'\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mstep_id\u001b[0m=\u001b[32m'896d9ebd-5a26-4831-aff4-48bc136b26fc'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mstep_type\u001b[0m=\u001b[32m'inference'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mturn_id\u001b[0m=\u001b[32m'dcb9c5f1-36c9-4928-b13f-a6e9478a940b'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mcompleted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m19\u001b[0m, \u001b[1;36m861070\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mstarted_at\u001b[0m=\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m929704\u001b[0m, \u001b[33mtzinfo\u001b[0m=\u001b[1;35mTzInfo\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m-08\u001b[0m:\u001b[1;36m00\u001b[0m\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# get the agent session ids\n", - "session_ids = agent.sessions\n", - "agent_id = agent.agent_id\n", - "\n", - "session_response = client.agents.session.retrieve(\n", - " session_id=session_ids[0],\n", - " agent_id=agent_id,\n", - ")\n", - "pprint(session_response)\n", - "\n", - "turn_response = client.agents.turn.retrieve(\n", - " session_id=session_ids[0],\n", - " agent_id=agent_id,\n", - " turn_id=session_response.turns[0].turn_id,\n", - ")\n", - "pprint(turn_response)\n", - "\n", - "step_response = client.agents.steps.retrieve(\n", - " session_id=session_ids[0],\n", - " agent_id=agent_id,\n", - " turn_id=session_response.turns[0].turn_id,\n", - " step_id=turn_response.steps[0].step_id,\n", - ")\n", - "pprint(step_response)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "master", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.16" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}