|
@@ -0,0 +1,455 @@
|
|
|
+{
|
|
|
+ "cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 6,
|
|
|
+ "id": "07721677",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/plain": [
|
|
|
+ "True"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "execution_count": 6,
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "execute_result"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "# from typing import Iterator\n",
|
|
|
+ "from agno.agent import Agent, RunResponse,RunResponseEvent\n",
|
|
|
+ "from typing import Iterator\n",
|
|
|
+ "# from agno.models.openai import OpenAIChat\n",
|
|
|
+ "from agno.utils.pprint import pprint_run_response\n",
|
|
|
+ "from rich.pretty import pprint\n",
|
|
|
+ "\n",
|
|
|
+ "# agent = Agent(model=OpenAIChat(id=\"gpt-4o-mini\"))\n",
|
|
|
+ "\n",
|
|
|
+ "# # Run agent and return the response as a variable\n",
|
|
|
+ "# response: RunResponse = agent.run(\"Tell me a 5 second short story about a robot\")\n",
|
|
|
+ "\n",
|
|
|
+ "# # Print the response in markdown format\n",
|
|
|
+ "# pprint_run_response(response, markdown=True)\n",
|
|
|
+ "\n",
|
|
|
+ "from agno.agent import Agent\n",
|
|
|
+ "from agno.models.openai import OpenAIChat, OpenAILike\n",
|
|
|
+ "from agno.tools.reasoning import ReasoningTools\n",
|
|
|
+ "from agno.tools.yfinance import YFinanceTools\n",
|
|
|
+ "import os\n",
|
|
|
+ "from textwrap import dedent\n",
|
|
|
+ "import dotenv\n",
|
|
|
+ "\n",
|
|
|
+ "dotenv.load_dotenv()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 2,
|
|
|
+ "id": "473a716e",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "model = OpenAILike(\n",
|
|
|
+ " id=\"qwen3-32b\",\n",
|
|
|
+ " api_key=os.getenv(\"BAILIAN_API_KEY\"),\n",
|
|
|
+ " base_url=os.getenv(\"BAILIAN_API_BASE_URL\"),\n",
|
|
|
+ " request_params={\"extra_body\": {\"enable_thinking\": False}},\n",
|
|
|
+ ")"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 9,
|
|
|
+ "id": "bb65de5a",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "3cd0c24e001148909c3c86e13037084d",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "from agno.utils.log import debug_level\n",
|
|
|
+ "\n",
|
|
|
+ "\n",
|
|
|
+ "def get_news(description: str):\n",
|
|
|
+ " print(f\"get_news: {description}\", )\n",
|
|
|
+ " return \"No news\"\n",
|
|
|
+ "\n",
|
|
|
+ "agent = Agent(\n",
|
|
|
+ " model=model,\n",
|
|
|
+ " tool_choice=\"auto\",\n",
|
|
|
+ " tools=[YFinanceTools(stock_price=True)],\n",
|
|
|
+ "# tools= [get_news],\n",
|
|
|
+ " # instructions=\"Use tables to display data. Don't include any other text.\",\n",
|
|
|
+ " # instructions=dedent(\"\"\"\\\n",
|
|
|
+ " # You are a seasoned Wall Street analyst with deep expertise in market analysis! 📊\n",
|
|
|
+ "\n",
|
|
|
+ " # Follow these steps for comprehensive financial analysis:\n",
|
|
|
+ " # 1. Market Overview\n",
|
|
|
+ " # - Latest stock price\n",
|
|
|
+ " # - 52-week high and low\n",
|
|
|
+ " # 2. Financial Deep Dive\n",
|
|
|
+ " # - Key metrics (P/E, Market Cap, EPS)\n",
|
|
|
+ " # 3. Professional Insights\n",
|
|
|
+ " # - Analyst recommendations breakdown\n",
|
|
|
+ " # - Recent rating changes\n",
|
|
|
+ "\n",
|
|
|
+ " # 4. Market Context\n",
|
|
|
+ " # - Industry trends and positioning\n",
|
|
|
+ " # - Competitive analysis\n",
|
|
|
+ " # - Market sentiment indicators\n",
|
|
|
+ "\n",
|
|
|
+ " # Your reporting style:\n",
|
|
|
+ " # - Begin with an executive summary\n",
|
|
|
+ " # - Use tables for data presentation\n",
|
|
|
+ " # - Include clear section headers\n",
|
|
|
+ " # - Add emoji indicators for trends (📈 📉)\n",
|
|
|
+ " # - Highlight key insights with bullet points\n",
|
|
|
+ " # - Compare metrics to industry averages\n",
|
|
|
+ " # - Include technical term explanations\n",
|
|
|
+ " # - End with a forward-looking analysis\n",
|
|
|
+ "\n",
|
|
|
+ " # Risk Disclosure:\n",
|
|
|
+ " # - Always highlight potential risk factors\n",
|
|
|
+ " # - Note market uncertainties\n",
|
|
|
+ " # - Mention relevant regulatory concerns\n",
|
|
|
+ " # \"\"\"),\n",
|
|
|
+ " add_datetime_to_instructions=True,\n",
|
|
|
+ " show_tool_calls=True,\n",
|
|
|
+ " # markdown=True,\n",
|
|
|
+ " # markdown=True,\n",
|
|
|
+ " # show_tool_calls=True,\n",
|
|
|
+ " # debug_mode=True, debug_level=2\n",
|
|
|
+ ")\n",
|
|
|
+ "\n",
|
|
|
+ "\n",
|
|
|
+ "pprint_run_response(agent.run(\n",
|
|
|
+ " \"Tell me a 5 second short story about a lion\",\n",
|
|
|
+ " stream=True, show_message=True\n",
|
|
|
+ " ))"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 10,
|
|
|
+ "id": "927a70d0",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "c4e88c67d8de4c19a6790f3f1835cede",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "Tool calls: [{'id': 'call_4c2c8551b4d249f8a3f58a', 'type': 'function', 'function': {'name': 'get_current_stock_price', 'arguments': '{\"symbol\": \"NVDA\"}'}}]\n",
|
|
|
+ "Tool calls: [{'id': 'call_4c2c8551b4d249f8a3f58a', 'type': 'function', 'function': {'name': 'get_current_stock_price', 'arguments': '{\"symbol\": \"NVDA\"}'}}]\n",
|
|
|
+ "--------------- Metrics ---------------\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">MessageMetrics</span><span style=\"font-weight: bold\">(</span>\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">input_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">218</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">output_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">total_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">240</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">input_audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">output_audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">cached_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">cache_write_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">reasoning_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">prompt_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">218</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">completion_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">prompt_tokens_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">completion_tokens_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">additional_metrics</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">time</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.3018417499988573</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">time_to_first_token</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.3011846250010421</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">timer</span>=<span style=\"font-weight: bold\"><</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">agno.utils.timer.Timer</span><span style=\"color: #000000; text-decoration-color: #000000\"> object at </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0x15c4545d0</span><span style=\"font-weight: bold\">></span>\n",
|
|
|
+ "<span style=\"font-weight: bold\">)</span>\n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;35mMessageMetrics\u001b[0m\u001b[1m(\u001b[0m\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33minput_tokens\u001b[0m=\u001b[1;36m218\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33moutput_tokens\u001b[0m=\u001b[1;36m22\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtotal_tokens\u001b[0m=\u001b[1;36m240\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33maudio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33minput_audio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33moutput_audio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcached_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcache_write_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mreasoning_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mprompt_tokens\u001b[0m=\u001b[1;36m218\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcompletion_tokens\u001b[0m=\u001b[1;36m22\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mprompt_tokens_details\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcompletion_tokens_details\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33madditional_metrics\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtime\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.3018417499988573\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtime_to_first_token\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.3011846250010421\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtimer\u001b[0m=\u001b[1m<\u001b[0m\u001b[1;95magno.utils.timer.Timer\u001b[0m\u001b[39m object at \u001b[0m\u001b[1;36m0x15c4545d0\u001b[0m\u001b[1m>\u001b[0m\n",
|
|
|
+ "\u001b[1m)\u001b[0m\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "------------------------------------------------------------\n",
|
|
|
+ "Message: It seems I'm currently rate-limited and unable to fetch the stock price for NVDA. Please try again later or check a financial platform for real-time stock information.\n",
|
|
|
+ "--------------- Metrics ---------------\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">MessageMetrics</span><span style=\"font-weight: bold\">(</span>\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">input_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">273</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">output_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">34</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">total_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">307</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">input_audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">output_audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">cached_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">cache_write_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">reasoning_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">prompt_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">273</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">completion_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">34</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">prompt_tokens_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">completion_tokens_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">additional_metrics</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">time</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.7436456249997718</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">time_to_first_token</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.7402209589999984</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">timer</span>=<span style=\"font-weight: bold\"><</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">agno.utils.timer.Timer</span><span style=\"color: #000000; text-decoration-color: #000000\"> object at </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0x15b177910</span><span style=\"font-weight: bold\">></span>\n",
|
|
|
+ "<span style=\"font-weight: bold\">)</span>\n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;35mMessageMetrics\u001b[0m\u001b[1m(\u001b[0m\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33minput_tokens\u001b[0m=\u001b[1;36m273\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33moutput_tokens\u001b[0m=\u001b[1;36m34\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtotal_tokens\u001b[0m=\u001b[1;36m307\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33maudio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33minput_audio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33moutput_audio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcached_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcache_write_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mreasoning_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mprompt_tokens\u001b[0m=\u001b[1;36m273\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcompletion_tokens\u001b[0m=\u001b[1;36m34\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mprompt_tokens_details\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcompletion_tokens_details\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33madditional_metrics\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtime\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.7436456249997718\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtime_to_first_token\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.7402209589999984\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtimer\u001b[0m=\u001b[1m<\u001b[0m\u001b[1;95magno.utils.timer.Timer\u001b[0m\u001b[39m object at \u001b[0m\u001b[1;36m0x15b177910\u001b[0m\u001b[1m>\u001b[0m\n",
|
|
|
+ "\u001b[1m)\u001b[0m\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "------------------------------------------------------------\n",
|
|
|
+ "--------------- Collected Metrics ---------------\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'input_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">218</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">273</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'output_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">34</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'total_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">240</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">307</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'audio_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'input_audio_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'output_audio_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'cached_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'cache_write_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'reasoning_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'prompt_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">218</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">273</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'completion_tokens'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">34</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'time'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.3018417499988573</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.7436456249997718</span><span style=\"font-weight: bold\">]</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'time_to_first_token'</span>: <span style=\"font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.3011846250010421</span>, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.7402209589999984</span><span style=\"font-weight: bold\">]</span>\n",
|
|
|
+ "<span style=\"font-weight: bold\">}</span>\n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1m{\u001b[0m\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'input_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m218\u001b[0m, \u001b[1;36m273\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'output_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m22\u001b[0m, \u001b[1;36m34\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'total_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m240\u001b[0m, \u001b[1;36m307\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'audio_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'input_audio_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'output_audio_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'cached_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'cache_write_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'reasoning_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'prompt_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m218\u001b[0m, \u001b[1;36m273\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'completion_tokens'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m22\u001b[0m, \u001b[1;36m34\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'time'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m1.3018417499988573\u001b[0m, \u001b[1;36m1.7436456249997718\u001b[0m\u001b[1m]\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[32m'time_to_first_token'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m1.3011846250010421\u001b[0m, \u001b[1;36m1.7402209589999984\u001b[0m\u001b[1m]\u001b[0m\n",
|
|
|
+ "\u001b[1m}\u001b[0m\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "--------------- Session Metrics ---------------\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">SessionMetrics</span><span style=\"font-weight: bold\">(</span>\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">input_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">712</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">output_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">109</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">total_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">821</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">input_audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">output_audio_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">cached_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">cache_write_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">reasoning_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">prompt_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">712</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">completion_tokens</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">109</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">prompt_tokens_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">completion_tokens_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">additional_metrics</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">time</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4.989817458998004</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">time_to_first_token</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.5254021249966172</span>,\n",
|
|
|
+ "<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">timer</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
|
|
|
+ "<span style=\"font-weight: bold\">)</span>\n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;35mSessionMetrics\u001b[0m\u001b[1m(\u001b[0m\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33minput_tokens\u001b[0m=\u001b[1;36m712\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33moutput_tokens\u001b[0m=\u001b[1;36m109\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtotal_tokens\u001b[0m=\u001b[1;36m821\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33maudio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33minput_audio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33moutput_audio_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcached_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcache_write_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mreasoning_tokens\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mprompt_tokens\u001b[0m=\u001b[1;36m712\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcompletion_tokens\u001b[0m=\u001b[1;36m109\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mprompt_tokens_details\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mcompletion_tokens_details\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33madditional_metrics\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtime\u001b[0m=\u001b[1;36m4\u001b[0m\u001b[1;36m.989817458998004\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtime_to_first_token\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.5254021249966172\u001b[0m,\n",
|
|
|
+ "\u001b[2;32m│ \u001b[0m\u001b[33mtimer\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
|
|
|
+ "\u001b[1m)\u001b[0m\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "agent.print_response(\n",
|
|
|
+ " \"What is the stock price of NVDA\", stream=True\n",
|
|
|
+ ")\n",
|
|
|
+ "\n",
|
|
|
+ "# Print metrics per message\n",
|
|
|
+ "if getattr(agent.run_response, \"messages\", None) is not None:\n",
|
|
|
+ " for message in agent.run_response.messages or []:\n",
|
|
|
+ " if getattr(message, \"role\", None) == \"assistant\":\n",
|
|
|
+ " if getattr(message, \"content\", None):\n",
|
|
|
+ " print(f\"Message: {message.content}\")\n",
|
|
|
+ " elif getattr(message, \"tool_calls\", None):\n",
|
|
|
+ " print(f\"Tool calls: {message.tool_calls}\")\n",
|
|
|
+ " print(f\"Tool calls: {message.tool_calls}\")\n",
|
|
|
+ " print(\"---\" * 5, \"Metrics\", \"---\" * 5)\n",
|
|
|
+ " pprint(message.metrics)\n",
|
|
|
+ " print(\"---\" * 20)\n",
|
|
|
+ "\n",
|
|
|
+ "# Print the aggregated metrics for the whole run\n",
|
|
|
+ "print(\"---\" * 5, \"Collected Metrics\", \"---\" * 5)\n",
|
|
|
+ "pprint(agent.run_response.metrics)\n",
|
|
|
+ "# Print the aggregated metrics for the whole session\n",
|
|
|
+ "print(\"---\" * 5, \"Session Metrics\", \"---\" * 5)\n",
|
|
|
+ "pprint(agent.session_metrics)"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "metadata": {
|
|
|
+ "kernelspec": {
|
|
|
+ "display_name": ".venv",
|
|
|
+ "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.11.13"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 5
|
|
|
+}
|