diff --git a/.cursor/rules/general.mdc b/.cursor/rules/general.mdc new file mode 100644 index 000000000..24daef2ba --- /dev/null +++ b/.cursor/rules/general.mdc @@ -0,0 +1,9 @@ +--- +description: General rules always applicable across the project +globs: +alwaysApply: true +--- +# Style + +- Comments must add value to code. Don't write filler comments explaining what you are doing next; they just add noise. +- Add a comment to clarify surprising behavior which would not be obvious. Good variable naming and clear code organization is more important. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..4aba604dd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +# GitHub Dependabot configuration +version: 2 +updates: + # Enable version updates for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" # Will use the default workflow location of `.github/workflows` + schedule: + interval: "daily" diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..517b5c39a --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,47 @@ +name: Unit Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + unit-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python: + - "3.10" + - "3.11" + - "3.12" + - "3.13" + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - uses: astral-sh/setup-uv@v5 + with: + python-version: ${{ matrix.python }} + enable-cache: false + + - name: Run unit tests + run: | + uv run --python ${{ matrix.python }} --with-editable . --with-editable ".[dev]" --with-editable ".[unit]" pytest --cov=llama_stack -s -v tests/unit/ --junitxml=pytest-report-${{ matrix.python }}.xml --cov-report=html:htmlcov-${{ matrix.python }} + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results-${{ matrix.python }} + path: | + .pytest_cache/ + pytest-report-${{ matrix.python }}.xml + htmlcov-${{ matrix.python }}/ + retention-days: 7 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..62862ebdc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,304 @@ +# Changelog + +# v0.1.6 +Published on: 2025-03-08T04:35:08Z + +## 0.1.6 Release Notes + +### Build and Test Agents +* Inference: Fixed support for inline vllm provider +* (**New**) Agent: Build & Monitor Agent Workflows with Llama Stack + Anthropic's Best Practice [Notebook](https://github.com/meta-llama/llama-stack/blob/main/docs/notebooks/Llama_Stack_Agent_Workflows.ipynb) +* (**New**) Agent: Revamped agent [documentation](https://llama-stack.readthedocs.io/en/latest/building_applications/agent.html) with more details and examples +* Agent: Unify tools and Python SDK Agents API +* Agent: AsyncAgent Python SDK wrapper supporting async client tool calls +* Agent: Support python functions without @client_tool decorator as client tools +* Agent: deprecation for allow_resume_turn flag, and remove need to specify tool_prompt_format +* VectorIO: MilvusDB support added + +### Agent Evals and Model Customization +* (**New**) Agent: Llama Stack RAG Lifecycle [Notebook](https://github.com/meta-llama/llama-stack/blob/main/docs/notebooks/Llama_Stack_RAG_Lifecycle.ipynb) +* Eval: Documentation for eval, scoring, adding new benchmarks +* Eval: Distribution template to run benchmarks on llama & non-llama models +* Eval: Ability to register new custom LLM-as-judge scoring functions +* (**New**) Looking for contributors for open benchmarks. See [documentation](https://llama-stack.readthedocs.io/en/latest/references/evals_reference/index.html#open-benchmark-contributing-guide) for details. + +### Deploy and Monitoring of Agents +* Better support for different log levels across all components for better monitoring + +### Better Engineering +* Enhance OpenAPI spec to include Error types across all APIs +* Moved all tests to /tests and created unit tests to run on each PR +* Removed all dependencies on llama-models repo + + +--- + +# v0.1.5.1 +Published on: 2025-02-28T22:37:44Z + +## 0.1.5.1 Release Notes +* Fixes for security risk in https://github.com/meta-llama/llama-stack/pull/1327 and https://github.com/meta-llama/llama-stack/pull/1328 + +**Full Changelog**: https://github.com/meta-llama/llama-stack/compare/v0.1.5...v0.1.5.1 + +--- + +# v0.1.5 +Published on: 2025-02-28T18:14:01Z + +## 0.1.5 Release Notes +### Build Agents +* Inference: Support more non-llama models (openai, anthropic, gemini) +* Inference: Can use the provider's model name in addition to the HF alias +* Inference: Fixed issues with calling tools that weren't specified in the prompt +* RAG: Improved system prompt for RAG and no more need for hard-coded rag-tool calling +* Embeddings: Added support for Nemo retriever embedding models +* Tools: Added support for MCP tools in Ollama Distribution +* Distributions: Added new Groq distribution + +### Customize Models +* Save post-trained checkpoint in SafeTensor format to allow Ollama inference provider to use the post-trained model + +### Monitor agents +* More comprehensive logging of agent steps including client tools +* Telemetry inputs/outputs are now structured and queryable +* Ability to retrieve agents session, turn, step by ids + +### Better Engineering +* Moved executorch Swift code out of this repo into the llama-stack-client-swift repo, similar to kotlin +* Move most logging to use logger instead of prints +* Completed text /chat-completion and /completion tests + + +--- + +# v0.1.4 +Published on: 2025-02-25T00:02:43Z + +## v0.1.4 Release Notes +Here are the key changes coming as part of this release: + +### Build and Test Agents +* Inference: Added support for non-llama models +* Inference: Added option to list all downloaded models and remove models +* Agent: Introduce new api agents.resume_turn to include client side tool execution in the same turn +* Agent: AgentConfig introduces new variable βtool_configβ that allows for better tool configuration and system prompt overrides +* Agent: Added logging for agent step start and completion times +* Agent: Added support for logging for tool execution metadata +* Embedding: Updated /inference/embeddings to support asymmetric models, truncation and variable sized outputs +* Embedding: Updated embedding models for Ollama, Together, and Fireworks with available defaults +* VectorIO: Improved performance of sqlite-vec using chunked writes +### Agent Evals and Model Customization +* Deprecated api /eval-tasks. Use /eval/benchmark instead +* Added CPU training support for TorchTune +### Deploy and Monitoring of Agents +* Consistent view of client and server tool calls in telemetry +### Better Engineering +* Made tests more data-driven for consistent evaluation +* Fixed documentation links and improved API reference generation +* Various small fixes for build scripts and system reliability + + + +--- + +# v0.1.3 +Published on: 2025-02-14T20:24:32Z + +## v0.1.3 Release + +Here are some key changes that are coming as part of this release. + +### Build and Test Agents +Streamlined the initial development experience +- Added support for llama stack run --image-type venv +- Enhanced vector store options with new sqlite-vec provider and improved Qdrant integration +- vLLM improvements for tool calling and logprobs +- Better handling of sporadic code_interpreter tool calls + +### Agent Evals +Better benchmarking and Agent performance assessment +- Renamed eval API /eval-task to /benchmarks +- Improved documentation and notebooks for RAG and evals + +### Deploy and Monitoring of Agents +Improved production readiness +- Added usage metrics collection for chat completions +- CLI improvements for provider information +- Improved error handling and system reliability +- Better model endpoint handling and accessibility +- Improved signal handling on distro server + +### Better Engineering +Infrastructure and code quality improvements +- Faster text-based chat completion tests +- Improved testing for non-streaming agent apis +- Standardized import formatting with ruff linter +- Added conventional commits standard +- Fixed documentation parsing issues + + +--- + +# v0.1.2 +Published on: 2025-02-07T22:06:49Z + +# TL;DR +- Several stabilizations to development flows after the switch to `uv` +- Migrated CI workflows to new OSS repo - [llama-stack-ops](https://github.com/meta-llama/llama-stack-ops) +- Added automated rebuilds for ReadTheDocs +- Llama Stack server supports HTTPS +- Added system prompt overrides support +- Several bug fixes and improvements to documentation (check out Kubernetes deployment guide by @terrytangyuan ) + + +--- + +# v0.1.1 +Published on: 2025-02-02T02:29:24Z + +A bunch of small / big improvements everywhere including support for Windows, switching to `uv` and many provider improvements. + + +--- + +# v0.1.0 +Published on: 2025-01-24T17:47:47Z + +We are excited to announce a stable API release of Llama Stack, which enables developers to build RAG applications and Agents using tools and safety shields, monitor and those agents with telemetry, and evaluate the agent with scoring functions. + +## Context +GenAI application developers need more than just an LLM - they need to integrate tools, connect with their data sources, establish guardrails, and ground the LLM responses effectively. Currently, developers must piece together various tools and APIs, complicating the development lifecycle and increasing costs. The result is that developers are spending more time on these integrations rather than focusing on the application logic itself. The bespoke coupling of components also makes it challenging to adopt state-of-the-art solutions in the rapidly evolving GenAI space. This is particularly difficult for open models like Llama, as best practices are not widely established in the open. + +Llama Stack was created to provide developers with a comprehensive and coherent interface that simplifies AI application development and codifies best practices across the Llama ecosystem. Since our launch in September 2024, we have seen a huge uptick in interest in Llama Stack APIs by both AI developers and from partners building AI services with Llama models. Partners like Nvidia, Fireworks, and Ollama have collaborated with us to develop implementations across various APIs, including inference, memory, and safety. + +With Llama Stack, you can easily build a RAG agent which can also search the web, do complex math, and custom tool calling. You can use telemetry to inspect those traces, and convert telemetry into evals datasets. And with Llama Stackβs plugin architecture and prepackage distributions, you choose to run your agent anywhere - in the cloud with our partners, deploy your own environment using virtualenv, conda, or Docker, operate locally with Ollama, or even run on mobile devices with our SDKs. Llama Stack offers unprecedented flexibility while also simplifying the developer experience. + +## Release +After iterating on the APIs for the last 3 months, today weβre launching a stable release (V1) of the Llama Stack APIs and the corresponding llama-stack server and client packages(v0.1.0). We now have automated tests for providers. These tests make sure that all provider implementations are verified. Developers can now easily and reliably select distributions or providers based on their specific requirements. + +There are example standalone apps in llama-stack-apps. + + +## Key Features of this release + +- **Unified API Layer** + - Inference: Run LLM models + - RAG: Store and retrieve knowledge for RAG + - Agents: Build multi-step agentic workflows + - Tools: Register tools that can be called by the agent + - Safety: Apply content filtering and safety policies + - Evaluation: Test model and agent quality + - Telemetry: Collect and analyze usage data and complex agentic traces + - Post Training ( Coming Soon ): Fine tune models for specific use cases + +- **Rich Provider Ecosystem** + - Local Development: Meta's Reference, Ollama + - Cloud: Fireworks, Together, Nvidia, AWS Bedrock, Groq, Cerebras + - On-premises: Nvidia NIM, vLLM, TGI, Dell-TGI + - On-device: iOS and Android support + +- **Built for Production** + - Pre-packaged distributions for common deployment scenarios + - Backwards compatibility across model versions + - Comprehensive evaluation capabilities + - Full observability and monitoring + +- **Multiple developer interfaces** + - CLI: Command line interface + - Python SDK + - Swift iOS SDK + - Kotlin Android SDK + +- **Sample llama stack applications** + - Python + - iOS + - Android + + + +--- + +# v0.1.0rc12 +Published on: 2025-01-22T22:24:01Z + + + +--- + +# v0.0.63 +Published on: 2024-12-18T07:17:43Z + +A small but important bug-fix release to update the URL datatype for the client-SDKs. The issue affected multimodal agentic turns especially. + +**Full Changelog**: https://github.com/meta-llama/llama-stack/compare/v0.0.62...v0.0.63 + +--- + +# v0.0.62 +Published on: 2024-12-18T02:39:43Z + + + +--- + +# v0.0.61 +Published on: 2024-12-10T20:50:33Z + + + +--- + +# v0.0.55 +Published on: 2024-11-23T17:14:07Z + + + +--- + +# v0.0.54 +Published on: 2024-11-22T00:36:09Z + + + +--- + +# v0.0.53 +Published on: 2024-11-20T22:18:00Z + +π Initial Release Notes for Llama Stack! + +### Added +- Resource-oriented design for models, shields, memory banks, datasets and eval tasks +- Persistence for registered objects with distribution +- Ability to persist memory banks created for FAISS +- PostgreSQL KVStore implementation +- Environment variable placeholder support in run.yaml files +- Comprehensive Zero-to-Hero notebooks and quickstart guides +- Support for quantized models in Ollama +- Vision models support for Together, Fireworks, Meta-Reference, and Ollama, and vLLM +- Bedrock distribution with safety shields support +- Evals API with task registration and scoring functions +- MMLU and SimpleQA benchmark scoring functions +- Huggingface dataset provider integration for benchmarks +- Support for custom dataset registration from local paths +- Benchmark evaluation CLI tools with visualization tables +- RAG evaluation scoring functions and metrics +- Local persistence for datasets and eval tasks + +### Changed +- Split safety into distinct providers (llama-guard, prompt-guard, code-scanner) +- Changed provider naming convention (`impls` β `inline`, `adapters` β `remote`) +- Updated API signatures for dataset and eval task registration +- Restructured folder organization for providers +- Enhanced Docker build configuration +- Added version prefixing for REST API routes +- Enhanced evaluation task registration workflow +- Improved benchmark evaluation output formatting +- Restructured evals folder organization for better modularity + +### Removed +- `llama stack configure` command + + +--- diff --git a/docs/notebooks/Llama_Stack_Agent_Workflows.ipynb b/docs/notebooks/Llama_Stack_Agent_Workflows.ipynb new file mode 100644 index 000000000..f800fb1d4 --- /dev/null +++ b/docs/notebooks/Llama_Stack_Agent_Workflows.ipynb @@ -0,0 +1,3535 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[](https://colab.research.google.com/github/meta-llama/llama-stack/blob/main/docs/notebooks/Llama_Stack_Agent_Workflows.ipynb)\n", + "\n", + "# Build and Monitor Agent Workflows with Llama Stack + Anthropic's Best Practice\n", + "\n", + "This notebook contains Llama Stack implementations of common agent workflows defined in Anthropic's blog post [Building Effective Agent Workflows](https://www.anthropic.com/research/building-effective-agents). \n", + "\n", + "**1. Basic Workflows**\n", + "- 1.1 Prompt Chaining\n", + "- 1.2 Routing\n", + "- 1.3 Parallelization\n", + "\n", + "**2. Advanced Workflows**\n", + "- 2.1 Evaluator-Optimizer\n", + "- 2.2 Orchestrator-Workers\n", + "\n", + "\n", + "For each workflow type, we present minimal implementations using Llama Stack using task examples from [anthropic-cookbook](https://github.com/anthropics/anthropic-cookbook/tree/main/patterns/agents), and showcase how to monitor the internals within each workflow execution. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 0. Setup" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# NBVAL_SKIP\n", + "!pip install -U llama-stack\n", + "!UV_SYSTEM_PYTHON=1 llama stack build --template fireworks --image-type venv" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from llama_stack_client import LlamaStackClient\n", + "from llama_stack.distribution.library_client import LlamaStackAsLibraryClient\n", + "from llama_stack_client.lib.agents.agent import Agent\n", + "from rich.pretty import pprint\n", + "import json\n", + "import uuid\n", + "from pydantic import BaseModel\n", + "import rich\n", + "import os\n", + "try:\n", + " from google.colab import userdata\n", + " os.environ['FIREWORKS_API_KEY'] = userdata.get('FIREWORKS_API_KEY')\n", + "except ImportError:\n", + " print(\"Not in Google Colab environment\")\n", + "\n", + "client = LlamaStackAsLibraryClient(\"fireworks\", provider_data = {\"fireworks_api_key\": os.environ['FIREWORKS_API_KEY']})\n", + "_ = client.initialize()\n", + "\n", + "# Uncomment to run on a hosted Llama Stack server\n", + "# client = LlamaStackClient(base_url=\"http://localhost:8321\")\n", + "\n", + "MODEL_ID = \"meta-llama/Llama-3.3-70B-Instruct\"\n", + "\n", + "base_agent_config = dict(\n", + " model=MODEL_ID,\n", + " instructions=\"You are a helpful assistant.\",\n", + " sampling_params={\n", + " \"strategy\": {\"type\": \"top_p\", \"temperature\": 1.0, \"top_p\": 0.9},\n", + " },\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Basic Workflows" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1.1 Prompt Chaining\n", + "\n", + "**Prompt chaining** decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one.\n", + "\n", + "\n", + "\n", + "**Example: Formatting Report Data**\n", + "- We'll build a agent and use prompt chaining by sending in a series of prompts to guide the agent to extract the data from the report." + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Turn: 0 =========\n", + "92: customer satisfaction score\n", + "45%: revenue growth\n", + "23%: market share\n", + "5%: customer churn\n", + "43: new user acquisition cost\n", + "78%: product adoption rate\n", + "87: employee satisfaction\n", + "34%: operating margin\n", + "8%: customer churn (previous)\n", + "\n", + "\n", + "========= Turn: 1 =========\n", + "92%: customer satisfaction\n", + "45%: revenue growth\n", + "23%: market share\n", + "5%: customer churn\n", + "87%: employee satisfaction\n", + "78%: product adoption rate\n", + "34%: operating margin\n", + "8%: previous customer churn\n", + "0.043: new user acquisition cost (as a decimal, assuming $43 is a dollar value and not a percentage)\n", + "\n", + "\n", + "========= Turn: 2 =========\n", + "92%: customer satisfaction\n", + "87%: employee satisfaction\n", + "78%: product adoption rate\n", + "45%: revenue growth\n", + "34%: operating margin\n", + "23%: market share\n", + "8%: previous customer churn\n", + "5%: customer churn\n", + "0.043: new user acquisition cost\n", + "\n", + "\n", + "========= Turn: 3 =========\n", + "| Metric | Value |\n", + "|:--|--:|\n", + "| Customer Satisfaction | 92% |\n", + "| Employee Satisfaction | 87% |\n", + "| Product Adoption Rate | 78% |\n", + "| Revenue Growth | 45% |\n", + "| Operating Margin | 34% |\n", + "| Market Share | 23% |\n", + "| Previous Customer Churn | 8% |\n", + "| Customer Churn | 5% |\n", + "| New User Acquisition Cost | 0.043 |\n", + "\n", + "\n" + ] + } + ], + "source": [ + "vanilla_agent_config = {\n", + " **base_agent_config,\n", + " \"instructions\": \"\"\"\n", + " You are a helpful assistant capable of structuring data extraction and formatting. \n", + "\n", + " You will be given tasks to extract and format data from a performance report. Here is the report:\n", + "\n", + " Q3 Performance Summary:\n", + " Our customer satisfaction score rose to 92 points this quarter.\n", + " Revenue grew by 45% compared to last year.\n", + " Market share is now at 23% in our primary market.\n", + " Customer churn decreased to 5% from 8%.\n", + " New user acquisition cost is $43 per user.\n", + " Product adoption rate increased to 78%.\n", + " Employee satisfaction is at 87 points.\n", + " Operating margin improved to 34%.\n", + " \"\"\",\n", + "}\n", + "\n", + "vanilla_agent = Agent(client, **vanilla_agent_config)\n", + "prompt_chaining_session_id = vanilla_agent.create_session(session_name=f\"vanilla_agent_{uuid.uuid4()}\")\n", + "\n", + "prompts = [\n", + " \"\"\"Extract only the numerical values and their associated metrics from the text.\n", + " Format each as 'value: metric' on a new line.\n", + " Example format:\n", + " 92: customer satisfaction\n", + " 45%: revenue growth\"\"\",\n", + "\n", + " \"\"\"Convert all numerical values to percentages where possible.\n", + " If not a percentage or points, convert to decimal (e.g., 92 points -> 92%).\n", + " Keep one number per line.\n", + " Example format:\n", + " 92%: customer satisfaction\n", + " 45%: revenue growth\"\"\",\n", + "\n", + " \"\"\"Sort all lines in descending order by numerical value.\n", + " Keep the format 'value: metric' on each line.\n", + " Example:\n", + " 92%: customer satisfaction\n", + " 87%: employee satisfaction\"\"\",\n", + "\n", + " \"\"\"Format the sorted data as a markdown table with columns:\n", + " | Metric | Value |\n", + " |:--|--:|\n", + " | Customer Satisfaction | 92% |\"\"\",\n", + "]\n", + "\n", + "for i, prompt in enumerate(prompts): \n", + " response = vanilla_agent.create_turn(\n", + " messages=[\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": prompt,\n", + " }\n", + " ],\n", + " session_id=prompt_chaining_session_id,\n", + " stream=False,\n", + " )\n", + " print(\"========= Turn: \", i, \"=========\")\n", + " print(response.output_message.content)\n", + " print(\"\\n\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.1.1 Monitor Prompt Chaining Internals\n", + "\n", + "We can use the `prompt_chaining_session_id` to retrieve details about what happened during the agent session. We can see that we created 4 sequential turns, to guide the agents to extract the data from the report." + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '79d7729c-9b66-49de-95ba-142572825873',\n", + "β 'session_name': 'vanilla_agent_9cbc951e-26c0-40b3-ad88-a4879492a1d4',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 15, 11, 58, 812136),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Extract only the numerical values and their associated metrics from the text.\\n Format each as 'value: metric' on a new line.\\n Example format:\\n 92: customer satisfaction\\n 45%: revenue growth\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '92: customer satisfaction score\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n43: new user acquisition cost\\n78%: product adoption rate\\n87: employee satisfaction\\n34%: operating margin\\n8%: customer churn (previous)',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '79d7729c-9b66-49de-95ba-142572825873',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 11, 58, 823529, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '92: customer satisfaction score\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n43: new user acquisition cost\\n78%: product adoption rate\\n87: employee satisfaction\\n34%: operating margin\\n8%: customer churn (previous)',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'b4155057-1d6e-4f6d-9ff5-2dd608590c31',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '4c94adf7-3fe1-497e-8219-e68eab6d9fc1',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 11, 59, 676732, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 11, 58, 833807, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '4c94adf7-3fe1-497e-8219-e68eab6d9fc1',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 11, 59, 688854, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β },\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Convert all numerical values to percentages where possible.\\n If not a percentage or points, convert to decimal (e.g., 92 points -> 92%).\\n Keep one number per line.\\n Example format:\\n 92%: customer satisfaction\\n 45%: revenue growth',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '92%: customer satisfaction\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n8%: previous customer churn\\n78%: product adoption rate\\n87%: employee satisfaction\\n34%: operating margin\\n43: new user acquisition cost \\n(Note: new user acquisition cost is in dollars, not a percentage or points, so it remains as is, but in decimal format it would be 43.00, however the original was not in decimal, it was in whole dollar amount)',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '79d7729c-9b66-49de-95ba-142572825873',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 11, 59, 712725, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '92%: customer satisfaction\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n8%: previous customer churn\\n78%: product adoption rate\\n87%: employee satisfaction\\n34%: operating margin\\n43: new user acquisition cost \\n(Note: new user acquisition cost is in dollars, not a percentage or points, so it remains as is, but in decimal format it would be 43.00, however the original was not in decimal, it was in whole dollar amount)',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'aea721fa-3a39-40eb-8d96-50703f10c090',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': 'e043b951-33d5-49a7-8350-f887500ee767',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 12, 0, 956951, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 11, 59, 724201, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': 'e043b951-33d5-49a7-8350-f887500ee767',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 12, 0, 970930, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β },\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Sort all lines in descending order by numerical value.\\n Keep the format 'value: metric' on each line.\\n Example:\\n 92%: customer satisfaction\\n 87%: employee satisfaction\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '92%: customer satisfaction\\n87%: employee satisfaction\\n78%: product adoption rate\\n45%: revenue growth\\n43: new user acquisition cost\\n34%: operating margin\\n23%: market share\\n8%: previous customer churn\\n5%: customer churn',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '79d7729c-9b66-49de-95ba-142572825873',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 12, 0, 991064, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '92%: customer satisfaction\\n87%: employee satisfaction\\n78%: product adoption rate\\n45%: revenue growth\\n43: new user acquisition cost\\n34%: operating margin\\n23%: market share\\n8%: previous customer churn\\n5%: customer churn',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '2d735f42-36ad-4751-b16c-0847b06ebd5b',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '65751002-460d-48b8-ae84-34ecbac01c1b',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 12, 2, 135853, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 12, 1, 2270, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '65751002-460d-48b8-ae84-34ecbac01c1b',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 12, 2, 148764, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β },\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Format the sorted data as a markdown table with columns:\\n | Metric | Value |\\n |:--|--:|\\n | Customer Satisfaction | 92% |',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': \"| Metric | Value |\\n|:--|--:|\\n| Customer Satisfaction | 92% |\\n| Employee Satisfaction | 87% |\\n| Product Adoption Rate | 78% |\\n| Revenue Growth | 45% |\\n| Operating Margin | 34% |\\n| Market Share | 23% |\\n| Previous Customer Churn | 8% |\\n| Customer Churn | 5% |\\n| New User Acquisition Cost | $43 | \\n\\nNote: I kept the New User Acquisition Cost as $43, since it's not a percentage value. If you'd like, I can format it as a decimal (43.00) instead. Let me know!\",\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '79d7729c-9b66-49de-95ba-142572825873',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 12, 2, 168026, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': \"| Metric | Value |\\n|:--|--:|\\n| Customer Satisfaction | 92% |\\n| Employee Satisfaction | 87% |\\n| Product Adoption Rate | 78% |\\n| Revenue Growth | 45% |\\n| Operating Margin | 34% |\\n| Market Share | 23% |\\n| Previous Customer Churn | 8% |\\n| Customer Churn | 5% |\\n| New User Acquisition Cost | $43 | \\n\\nNote: I kept the New User Acquisition Cost as $43, since it's not a percentage value. If you'd like, I can format it as a decimal (43.00) instead. Let me know!\",\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'ecd77af7-f96c-40c2-ba08-1b1484dd7eaa',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '6e22b536-9a3b-4f80-b2e4-6aafb6c033d1',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 12, 3, 296859, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 15, 12, 2, 179243, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '6e22b536-9a3b-4f80-b2e4-6aafb6c033d1',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 15, 12, 3, 308421, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'79d7729c-9b66-49de-95ba-142572825873'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'vanilla_agent_9cbc951e-26c0-40b3-ad88-a4879492a1d4'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m58\u001b[0m, \u001b[1;36m812136\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Extract only the numerical values and their associated metrics from the text.\\n Format each as 'value: metric' on a new line.\\n Example format:\\n 92: customer satisfaction\\n 45%: revenue growth\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'92: customer satisfaction score\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n43: new user acquisition cost\\n78%: product adoption rate\\n87: employee satisfaction\\n34%: operating margin\\n8%: customer churn \u001b[0m\u001b[32m(\u001b[0m\u001b[32mprevious\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'79d7729c-9b66-49de-95ba-142572825873'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m58\u001b[0m, \u001b[1;36m823529\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'92: customer satisfaction score\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n43: new user acquisition cost\\n78%: product adoption rate\\n87: employee satisfaction\\n34%: operating margin\\n8%: customer churn \u001b[0m\u001b[32m(\u001b[0m\u001b[32mprevious\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'b4155057-1d6e-4f6d-9ff5-2dd608590c31'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'4c94adf7-3fe1-497e-8219-e68eab6d9fc1'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m59\u001b[0m, \u001b[1;36m676732\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m58\u001b[0m, \u001b[1;36m833807\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[32m'turn_id'\u001b[0m: \u001b[32m'4c94adf7-3fe1-497e-8219-e68eab6d9fc1'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m59\u001b[0m, \u001b[1;36m688854\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[32m'output_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[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Convert all numerical values to percentages where possible.\\n If not a percentage or points, convert to decimal \u001b[0m\u001b[32m(\u001b[0m\u001b[32me.g., 92 points -> 92%\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n Keep one number per line.\\n Example format:\\n 92%: customer satisfaction\\n 45%: revenue growth'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'92%: customer satisfaction\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n8%: previous customer churn\\n78%: product adoption rate\\n87%: employee satisfaction\\n34%: operating margin\\n43: new user acquisition cost \\n\u001b[0m\u001b[32m(\u001b[0m\u001b[32mNote: new user acquisition cost is in dollars, not a percentage or points, so it remains as is, but in decimal format it would be 43.00, however the original was not in decimal, it was in whole dollar amount\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'79d7729c-9b66-49de-95ba-142572825873'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m59\u001b[0m, \u001b[1;36m712725\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'92%: customer satisfaction\\n45%: revenue growth\\n23%: market share\\n5%: customer churn\\n8%: previous customer churn\\n78%: product adoption rate\\n87%: employee satisfaction\\n34%: operating margin\\n43: new user acquisition cost \\n\u001b[0m\u001b[32m(\u001b[0m\u001b[32mNote: new user acquisition cost is in dollars, not a percentage or points, so it remains as is, but in decimal format it would be 43.00, however the original was not in decimal, it was in whole dollar amount\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'aea721fa-3a39-40eb-8d96-50703f10c090'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'e043b951-33d5-49a7-8350-f887500ee767'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m956951\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m59\u001b[0m, \u001b[1;36m724201\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[32m'turn_id'\u001b[0m: \u001b[32m'e043b951-33d5-49a7-8350-f887500ee767'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m970930\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[32m'output_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[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Sort all lines in descending order by numerical value.\\n Keep the format 'value: metric' on each line.\\n Example:\\n 92%: customer satisfaction\\n 87%: employee satisfaction\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'92%: customer satisfaction\\n87%: employee satisfaction\\n78%: product adoption rate\\n45%: revenue growth\\n43: new user acquisition cost\\n34%: operating margin\\n23%: market share\\n8%: previous customer churn\\n5%: customer churn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'79d7729c-9b66-49de-95ba-142572825873'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m991064\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'92%: customer satisfaction\\n87%: employee satisfaction\\n78%: product adoption rate\\n45%: revenue growth\\n43: new user acquisition cost\\n34%: operating margin\\n23%: market share\\n8%: previous customer churn\\n5%: customer churn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'2d735f42-36ad-4751-b16c-0847b06ebd5b'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'65751002-460d-48b8-ae84-34ecbac01c1b'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m135853\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m1\u001b[0m, \u001b[1;36m2270\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[32m'turn_id'\u001b[0m: \u001b[32m'65751002-460d-48b8-ae84-34ecbac01c1b'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m148764\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[32m'output_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[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Format the sorted data as a markdown table with columns:\\n | Metric | Value |\\n |:--|--:|\\n | Customer Satisfaction | 92% |'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"| Metric | Value |\\n|:--|--:|\\n| Customer Satisfaction | 92% |\\n| Employee Satisfaction | 87% |\\n| Product Adoption Rate | 78% |\\n| Revenue Growth | 45% |\\n| Operating Margin | 34% |\\n| Market Share | 23% |\\n| Previous Customer Churn | 8% |\\n| Customer Churn | 5% |\\n| New User Acquisition Cost | $43 | \\n\\nNote: I kept the New User Acquisition Cost as $43, since it's not a percentage value. If you'd like, I can format it as a decimal \u001b[0m\u001b[32m(\u001b[0m\u001b[32m43.00\u001b[0m\u001b[32m)\u001b[0m\u001b[32m instead. Let me know!\"\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'79d7729c-9b66-49de-95ba-142572825873'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m168026\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"| Metric | Value |\\n|:--|--:|\\n| Customer Satisfaction | 92% |\\n| Employee Satisfaction | 87% |\\n| Product Adoption Rate | 78% |\\n| Revenue Growth | 45% |\\n| Operating Margin | 34% |\\n| Market Share | 23% |\\n| Previous Customer Churn | 8% |\\n| Customer Churn | 5% |\\n| New User Acquisition Cost | $43 | \\n\\nNote: I kept the New User Acquisition Cost as $43, since it's not a percentage value. If you'd like, I can format it as a decimal \u001b[0m\u001b[32m(\u001b[0m\u001b[32m43.00\u001b[0m\u001b[32m)\u001b[0m\u001b[32m instead. Let me know!\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'ecd77af7-f96c-40c2-ba08-1b1484dd7eaa'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'6e22b536-9a3b-4f80-b2e4-6aafb6c033d1'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m296859\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m179243\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[32m'turn_id'\u001b[0m: \u001b[32m'6e22b536-9a3b-4f80-b2e4-6aafb6c033d1'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m15\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m308421\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[32m'output_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" + } + ], + "source": [ + "vanilla_agent_session = client.agents.session.retrieve(session_id=prompt_chaining_session_id, agent_id=vanilla_agent.agent_id)\n", + "pprint(vanilla_agent_session.to_dict())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1.2 Routing\n", + "\n", + "**Routing** classifies an input and directs it to a specialized followup task. This workflow allows for separation of concerns, and building more specialized prompts. \n", + "\n", + "\n", + "\n", + "**Example: Routing to Support Teams**\n", + "We'll demonstrating how routing workflows works with: \n", + " - **4 specialized agents**, each specializes in a different support team from billing, technical, account, and product\n", + " - **1 routing agent** that decides which specialized agent to route the user's request to based on the user's request." + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Processing ticket 1: =========\n" + ] + }, + { + "data": { + "text/html": [ + "
π Routing Result: The user is having trouble accessing their account due to an 'invalid password' error, despite \n", + "being certain they are using the correct password. This issue is related to account access and authentication, \n", + "which falls under the responsibility of the account support team. \n", + "\n" + ], + "text/plain": [ + "π \u001b[36m Routing Result: The user is having trouble accessing their account due to an \u001b[0m\u001b[36m'invalid password'\u001b[0m\u001b[36m error, despite \u001b[0m\n", + "\u001b[36mbeing certain they are using the correct password. This issue is related to account access and authentication, \u001b[0m\n", + "\u001b[36mwhich falls under the responsibility of the account support team. \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
π Routing to account... \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "π \u001b[36m Routing to account\u001b[0m\u001b[36m...\u001b[0m\u001b[36m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Account Support Response:\n",
+ "\n",
+ "Dear John,\n",
+ "\n",
+ "We take account security and accessibility very seriously. To ensure the integrity of your account, we must follow a thorough verification process. Before we can assist you with regaining access, we need to confirm your identity.\n",
+ "\n",
+ "To initiate the account recovery process, please follow these steps:\n",
+ "\n",
+ "1. **Verify your account information**: Please reply to this email with your full name, the email address associated with your account, and the last 4 digits of your phone number (if you have one listed on your account).\n",
+ "2. **Password reset**: We will send you a password reset link to the email address associated with your account. This link will allow you to create a new password. Please note that this link will only be valid for 24 hours.\n",
+ "3. **Security questions**: You may be prompted to answer security questions to further verify your identity.\n",
+ "\n",
+ "**Important Security Note**: If you are using a public computer or network, please be cautious when accessing your account. Public computers and networks may be vulnerable to malware and other security risks. We recommend using a secure, private device and network to access your account.\n",
+ "\n",
+ "**Resolution Timeframe**: Our goal is to resolve account access issues within 2-4 hours. However, this may vary depending on the complexity of the issue and the verification process.\n",
+ "\n",
+ "**Security Tips**:\n",
+ "\n",
+ "* Use a unique and complex password for your account.\n",
+ "* Avoid using public computers or networks to access sensitive information.\n",
+ "* Enable two-factor authentication (2FA) whenever possible.\n",
+ "* Regularly monitor your account activity and report any suspicious behavior to our support team.\n",
+ "\n",
+ "We appreciate your cooperation and understanding in this matter. If you have any further questions or concerns, please do not hesitate to reach out to us.\n",
+ "\n",
+ "Sincerely,\n",
+ "Account Support Team\n",
+ "\n",
+ "\n",
+ "========= Processing ticket 2: =========\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "π Routing Result: The user is inquiring about an unexpected charge on their credit card, which suggests a \n", + "billing-related issue. They are also requesting an explanation and potential adjustment of the charge, which \n", + "further indicates that the issue is related to payment or billing. \n", + "\n" + ], + "text/plain": [ + "π \u001b[36m Routing Result: The user is inquiring about an unexpected charge on their credit card, which suggests a \u001b[0m\n", + "\u001b[36mbilling-related issue. They are also requesting an explanation and potential adjustment of the charge, which \u001b[0m\n", + "\u001b[36mfurther indicates that the issue is related to payment or billing. \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
π Routing to billing... \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "π \u001b[36m Routing to billing\u001b[0m\u001b[36m...\u001b[0m\u001b[36m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Billing Support Response:\n",
+ "\n",
+ "I apologize for the unexpected charge on your credit card, Sarah. I understand that you were expecting to be billed $29.99, but instead, you were charged $49.99. I'm here to help you resolve this issue.\n",
+ "\n",
+ "After reviewing your account, I found that the $49.99 charge is due to an upgrade to our premium plan, which was accidentally applied to your account during a recent system update. This upgrade includes additional features that are not part of the standard $29.99 plan.\n",
+ "\n",
+ "To correct this, I will immediately downgrade your account back to the $29.99 plan, and I will also process a refund of $20.00, which is the difference between the two plans. You can expect to see the refund credited back to your credit card within the next 3-5 business days.\n",
+ "\n",
+ "In the meantime, I will also send you a confirmation email with the updated account details and a receipt for the corrected charge. If you have any further questions or concerns, please don't hesitate to reach out to me directly.\n",
+ "\n",
+ "If you would like to make a payment for the corrected $29.99 charge, you can do so by visiting our website and logging into your account, or by calling our automated payment system at 1-800-XXX-XXXX. We accept all major credit cards, including Visa, Mastercard, and American Express.\n",
+ "\n",
+ "\n",
+ "========= Processing ticket 3: =========\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "π Routing Result: The user is seeking assistance with a specific feature or functionality of the product, namely \n", + "exporting data to Excel. This type of inquiry is related to understanding and using the product's capabilities, \n", + "which falls under the scope of the product support team or technical support team. Since the issue is more about \n", + "how to use a feature rather than a technical fault, it leans more towards product support. However, given the \n", + "nature of the request, which involves understanding the technical capabilities of the product, it could also be \n", + "argued that it falls under technical support. Between the two, technical support is more appropriate because it \n", + "often deals with the 'how-to' aspects of using the product's features. \n", + "\n" + ], + "text/plain": [ + "π \u001b[36m Routing Result: The user is seeking assistance with a specific feature or functionality of the product, namely \u001b[0m\n", + "\u001b[36mexporting data to Excel. This type of inquiry is related to understanding and using the product's capabilities, \u001b[0m\n", + "\u001b[36mwhich falls under the scope of the product support team or technical support team. Since the issue is more about \u001b[0m\n", + "\u001b[36mhow to use a feature rather than a technical fault, it leans more towards product support. However, given the \u001b[0m\n", + "\u001b[36mnature of the request, which involves understanding the technical capabilities of the product, it could also be \u001b[0m\n", + "\u001b[36margued that it falls under technical support. Between the two, technical support is more appropriate because it \u001b[0m\n", + "\u001b[36moften deals with the \u001b[0m\u001b[36m'how-to'\u001b[0m\u001b[36m aspects of using the product's features. \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
π Routing to technical... \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "π \u001b[36m Routing to technical\u001b[0m\u001b[36m...\u001b[0m\u001b[36m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Technical Support Response:\n",
+ "\n",
+ "Exporting data in bulk to Excel is a feature available in our system. To achieve this, follow these steps:\n",
+ "\n",
+ "1. **Login to the system**: Ensure you are logged in with the correct credentials and have the necessary permissions to access and export project data.\n",
+ "2. **Navigate to the Project Dashboard**: Click on the \"Projects\" tab and select the project for which you want to export data.\n",
+ "3. **Access the Data Export Tool**: In the project dashboard, click on the \"Tools\" menu and select \"Data Export\" from the dropdown list.\n",
+ "4. **Select Export Options**: In the Data Export tool, choose the data types you want to export (e.g., tasks, issues, users, etc.). You can select all data types or specific ones based on your requirements.\n",
+ "5. **Choose the Export Format**: Select \"Excel (.xlsx)\" as the export format from the available options.\n",
+ "6. **Configure Export Settings**: You can configure additional settings such as:\n",
+ "\t* Date range: Specify a date range for the data to be exported.\n",
+ "\t* Data filtering: Apply filters to export specific data based on conditions (e.g., status, priority, etc.).\n",
+ "7. **Initiate the Export**: Click the \"Export\" button to start the export process. Depending on the amount of data, this may take a few minutes.\n",
+ "8. **Download the Exported File**: Once the export is complete, you will receive a notification. Click on the \"Download\" button to save the exported Excel file to your local machine.\n",
+ "\n",
+ "System Requirements:\n",
+ "- Ensure you have the latest version of our software installed (v2.5 or later).\n",
+ "- Microsoft Excel 2013 or later is recommended for compatibility.\n",
+ "\n",
+ "Workarounds for Common Problems:\n",
+ "- If you encounter issues with large data exports, try breaking down the export into smaller chunks using the date range or data filtering options.\n",
+ "- If you experience errors during the export process, check the system logs for more information and contact support if needed.\n",
+ "\n",
+ "If you need further assistance or encounter any issues during the export process, please don't hesitate to reach out. You can escalate this issue by replying to this email or contacting our support team directly at [support@example.com](mailto:support@example.com) or by calling +1-800-EXAMPLE.\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 1. Define a couple of specialized agents\n",
+ "billing_agent_config = {\n",
+ " **base_agent_config,\n",
+ " \"instructions\": \"\"\"You are a billing support specialist. Follow these guidelines:\n",
+ " 1. Always start with \"Billing Support Response:\"\n",
+ " 2. First acknowledge the specific billing issue\n",
+ " 3. Explain any charges or discrepancies clearly\n",
+ " 4. List concrete next steps with timeline\n",
+ " 5. End with payment options if relevant\n",
+ " \n",
+ " Keep responses professional but friendly.\n",
+ " \"\"\",\n",
+ "}\n",
+ "\n",
+ "technical_agent_config = {\n",
+ " **base_agent_config,\n",
+ " \"instructions\": \"\"\"You are a technical support engineer. Follow these guidelines:\n",
+ " 1. Always start with \"Technical Support Response:\"\n",
+ " 2. List exact steps to resolve the issue\n",
+ " 3. Include system requirements if relevant\n",
+ " 4. Provide workarounds for common problems\n",
+ " 5. End with escalation path if needed\n",
+ " \n",
+ " Use clear, numbered steps and technical details.\n",
+ " \"\"\",\n",
+ "}\n",
+ "\n",
+ "account_agent_config = {\n",
+ " **base_agent_config,\n",
+ " \"instructions\": \"\"\"You are an account security specialist. Follow these guidelines:\n",
+ " 1. Always start with \"Account Support Response:\"\n",
+ " 2. Prioritize account security and verification\n",
+ " 3. Provide clear steps for account recovery/changes\n",
+ " 4. Include security tips and warnings\n",
+ " 5. Set clear expectations for resolution time\n",
+ " \n",
+ " Maintain a serious, security-focused tone.\n",
+ " \"\"\",\n",
+ "}\n",
+ "\n",
+ "product_agent_config = {\n",
+ " **base_agent_config,\n",
+ " \"instructions\": \"\"\"You are a product specialist. Follow these guidelines:\n",
+ " 1. Always start with \"Product Support Response:\"\n",
+ " 2. Focus on feature education and best practices\n",
+ " 3. Include specific examples of usage\n",
+ " 4. Link to relevant documentation sections\n",
+ " 5. Suggest related features that might help\n",
+ " \n",
+ " Be educational and encouraging in tone.\n",
+ " \"\"\",\n",
+ "}\n",
+ "\n",
+ "specialized_agents = {\n",
+ " \"billing\": Agent(client, **billing_agent_config),\n",
+ " \"technical\": Agent(client, **technical_agent_config),\n",
+ " \"account\": Agent(client, **account_agent_config),\n",
+ " \"product\": Agent(client, **product_agent_config),\n",
+ "}\n",
+ "\n",
+ "# 2. Define a routing agent\n",
+ "class OutputSchema(BaseModel):\n",
+ " reasoning: str\n",
+ " support_team: str\n",
+ "\n",
+ "routing_agent_config = {\n",
+ " **base_agent_config,\n",
+ " \"instructions\": f\"\"\"You are a routing agent. Analyze the user's input and select the most appropriate support team from these options: \n",
+ "\n",
+ " {list(specialized_agents.keys())}\n",
+ "\n",
+ " Return the name of the support team in JSON format.\n",
+ "\n",
+ " First explain your reasoning, then provide your selection in this JSON format: \n",
+ " {{\n",
+ " \"reasoning\": \"{\n", + "β 'session_id': 'd9d8542b-1265-45a5-9a1d-ae114f760602',\n", + "β 'session_name': 'routing_agent_a85f38ad-fc09-41ed-b36a-f3b684d6f090',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 68139),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Subject: Can't access my account\\n Message: Hi, I've been trying to log in for the past hour but keep getting an 'invalid password' error. \\n I'm sure I'm using the right password. Can you help me regain access? This is urgent as I need to \\n submit a report by end of day.\\n - John\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '{\"reasoning\": \"The user is having trouble accessing their account due to an \\'invalid password\\' error, despite being certain they are using the correct password. This issue is related to account access and authentication, which falls under the responsibility of the account support team.\", \"support_team\": \"account\"}',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': 'd9d8542b-1265-45a5-9a1d-ae114f760602',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 93824, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '{\"reasoning\": \"The user is having trouble accessing their account due to an \\'invalid password\\' error, despite being certain they are using the correct password. This issue is related to account access and authentication, which falls under the responsibility of the account support team.\", \"support_team\": \"account\"}',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '41c4770e-0b28-4dbc-aef7-96512cef5fce',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '78c37ef0-965d-4565-8a6a-b59be860a884',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 37, 56558, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 104502, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '78c37ef0-965d-4565-8a6a-b59be860a884',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 37, 76781, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β },\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Subject: Unexpected charge on my card\\n Message: Hello, I just noticed a charge of $49.99 on my credit card from your company, but I thought\\n I was on the $29.99 plan. Can you explain this charge and adjust it if it's a mistake?\\n Thanks,\\n Sarah\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '{\"reasoning\": \"The user is inquiring about an unexpected charge on their credit card, which suggests a billing-related issue. They are also requesting an explanation and potential adjustment of the charge, which further indicates that the issue is related to payment or billing.\", \"support_team\": \"billing\"}',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': 'd9d8542b-1265-45a5-9a1d-ae114f760602',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 41, 560541, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '{\"reasoning\": \"The user is inquiring about an unexpected charge on their credit card, which suggests a billing-related issue. They are also requesting an explanation and potential adjustment of the charge, which further indicates that the issue is related to payment or billing.\", \"support_team\": \"billing\"}',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '3bd4c234-482c-42c5-a64f-41d1a20a5815',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': 'f76c1abe-30e6-4f60-b2c0-ad45bbf6a54e',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 44, 555772, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 41, 571809, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': 'f76c1abe-30e6-4f60-b2c0-ad45bbf6a54e',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 44, 569793, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β },\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Subject: How to export data?\\n Message: I need to export all my project data to Excel. I've looked through the docs but can't\\n figure out how to do a bulk export. Is this possible? If so, could you walk me through the steps?\\n Best regards,\\n Mike\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '{\"reasoning\": \"The user is seeking assistance with a specific feature or functionality of the product, namely exporting data to Excel. This type of inquiry is related to understanding and using the product\\'s capabilities, which falls under the scope of the product support team or technical support team. Since the issue is more about how to use a feature rather than a technical fault, it leans more towards product support. However, given the nature of the request, which involves understanding the technical capabilities of the product, it could also be argued that it falls under technical support. Between the two, technical support is more appropriate because it often deals with the \\'how-to\\' aspects of using the product\\'s features.\", \"support_team\": \"technical\"}',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': 'd9d8542b-1265-45a5-9a1d-ae114f760602',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 48, 183532, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '{\"reasoning\": \"The user is seeking assistance with a specific feature or functionality of the product, namely exporting data to Excel. This type of inquiry is related to understanding and using the product\\'s capabilities, which falls under the scope of the product support team or technical support team. Since the issue is more about how to use a feature rather than a technical fault, it leans more towards product support. However, given the nature of the request, which involves understanding the technical capabilities of the product, it could also be argued that it falls under technical support. Between the two, technical support is more appropriate because it often deals with the \\'how-to\\' aspects of using the product\\'s features.\", \"support_team\": \"technical\"}',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '0d21ca92-dead-4d38-91b0-ff91ef28d0aa',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': 'e08b071a-101f-4f0c-a8b9-aed9b6bcd563',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 51, 123810, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 48, 194709, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': 'e08b071a-101f-4f0c-a8b9-aed9b6bcd563',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 51, 143749, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'd9d8542b-1265-45a5-9a1d-ae114f760602'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'routing_agent_a85f38ad-fc09-41ed-b36a-f3b684d6f090'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m68139\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Subject: Can't access my account\\n Message: Hi, I've been trying to log in for the past hour but keep getting an 'invalid password' error. \\n I'm sure I'm using the right password. Can you help me regain access? This is urgent as I need to \\n submit a report by end of day.\\n - John\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"reasoning\": \"The user is having trouble accessing their account due to an \\'invalid password\\' error, despite being certain they are using the correct password. This issue is related to account access and authentication, which falls under the responsibility of the account support team.\", \"support_team\": \"account\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'd9d8542b-1265-45a5-9a1d-ae114f760602'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m93824\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"reasoning\": \"The user is having trouble accessing their account due to an \\'invalid password\\' error, despite being certain they are using the correct password. This issue is related to account access and authentication, which falls under the responsibility of the account support team.\", \"support_team\": \"account\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'41c4770e-0b28-4dbc-aef7-96512cef5fce'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'78c37ef0-965d-4565-8a6a-b59be860a884'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m56558\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m104502\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[32m'turn_id'\u001b[0m: \u001b[32m'78c37ef0-965d-4565-8a6a-b59be860a884'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m76781\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[32m'output_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[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Subject: Unexpected charge on my card\\n Message: Hello, I just noticed a charge of $49.99 on my credit card from your company, but I thought\\n I was on the $29.99 plan. Can you explain this charge and adjust it if it's a mistake?\\n Thanks,\\n Sarah\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"reasoning\": \"The user is inquiring about an unexpected charge on their credit card, which suggests a billing-related issue. They are also requesting an explanation and potential adjustment of the charge, which further indicates that the issue is related to payment or billing.\", \"support_team\": \"billing\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'd9d8542b-1265-45a5-9a1d-ae114f760602'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m41\u001b[0m, \u001b[1;36m560541\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"reasoning\": \"The user is inquiring about an unexpected charge on their credit card, which suggests a billing-related issue. They are also requesting an explanation and potential adjustment of the charge, which further indicates that the issue is related to payment or billing.\", \"support_team\": \"billing\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'3bd4c234-482c-42c5-a64f-41d1a20a5815'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'f76c1abe-30e6-4f60-b2c0-ad45bbf6a54e'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m44\u001b[0m, \u001b[1;36m555772\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m41\u001b[0m, \u001b[1;36m571809\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[32m'turn_id'\u001b[0m: \u001b[32m'f76c1abe-30e6-4f60-b2c0-ad45bbf6a54e'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m44\u001b[0m, \u001b[1;36m569793\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[32m'output_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[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Subject: How to export data?\\n Message: I need to export all my project data to Excel. I've looked through the docs but can't\\n figure out how to do a bulk export. Is this possible? If so, could you walk me through the steps?\\n Best regards,\\n Mike\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"reasoning\": \"The user is seeking assistance with a specific feature or functionality of the product, namely exporting data to Excel. This type of inquiry is related to understanding and using the product\\'s capabilities, which falls under the scope of the product support team or technical support team. Since the issue is more about how to use a feature rather than a technical fault, it leans more towards product support. However, given the nature of the request, which involves understanding the technical capabilities of the product, it could also be argued that it falls under technical support. Between the two, technical support is more appropriate because it often deals with the \\'how-to\\' aspects of using the product\\'s features.\", \"support_team\": \"technical\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'd9d8542b-1265-45a5-9a1d-ae114f760602'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m48\u001b[0m, \u001b[1;36m183532\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"reasoning\": \"The user is seeking assistance with a specific feature or functionality of the product, namely exporting data to Excel. This type of inquiry is related to understanding and using the product\\'s capabilities, which falls under the scope of the product support team or technical support team. Since the issue is more about how to use a feature rather than a technical fault, it leans more towards product support. However, given the nature of the request, which involves understanding the technical capabilities of the product, it could also be argued that it falls under technical support. Between the two, technical support is more appropriate because it often deals with the \\'how-to\\' aspects of using the product\\'s features.\", \"support_team\": \"technical\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'0d21ca92-dead-4d38-91b0-ff91ef28d0aa'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'e08b071a-101f-4f0c-a8b9-aed9b6bcd563'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m51\u001b[0m, \u001b[1;36m123810\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m48\u001b[0m, \u001b[1;36m194709\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[32m'turn_id'\u001b[0m: \u001b[32m'e08b071a-101f-4f0c-a8b9-aed9b6bcd563'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m51\u001b[0m, \u001b[1;36m143749\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Specialized Agent billing Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '15f5cf5c-8534-4c29-babf-45fa18cf821f',\n", + "β 'session_name': 'billing_agent_639b351b-12c0-4d5a-8fd3-61dc75692e81',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 74152),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Subject: Unexpected charge on my card\\n Message: Hello, I just noticed a charge of $49.99 on my credit card from your company, but I thought\\n I was on the $29.99 plan. Can you explain this charge and adjust it if it's a mistake?\\n Thanks,\\n Sarah\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': \"Billing Support Response:\\n\\nI apologize for the unexpected charge on your credit card, Sarah. I understand that you were expecting to be billed $29.99, but instead, you were charged $49.99. I'm here to help you resolve this issue.\\n\\nAfter reviewing your account, I found that the $49.99 charge is due to an upgrade to our premium plan, which was accidentally applied to your account during a recent system update. This upgrade includes additional features that are not part of the standard $29.99 plan.\\n\\nTo correct this, I will immediately downgrade your account back to the $29.99 plan, and I will also process a refund of $20.00, which is the difference between the two plans. You can expect to see the refund credited back to your credit card within the next 3-5 business days.\\n\\nIn the meantime, I will also send you a confirmation email with the updated account details and a receipt for the corrected charge. If you have any further questions or concerns, please don't hesitate to reach out to me directly.\\n\\nIf you would like to make a payment for the corrected $29.99 charge, you can do so by visiting our website and logging into your account, or by calling our automated payment system at 1-800-XXX-XXXX. We accept all major credit cards, including Visa, Mastercard, and American Express.\",\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '15f5cf5c-8534-4c29-babf-45fa18cf821f',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 44, 598852, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': \"Billing Support Response:\\n\\nI apologize for the unexpected charge on your credit card, Sarah. I understand that you were expecting to be billed $29.99, but instead, you were charged $49.99. I'm here to help you resolve this issue.\\n\\nAfter reviewing your account, I found that the $49.99 charge is due to an upgrade to our premium plan, which was accidentally applied to your account during a recent system update. This upgrade includes additional features that are not part of the standard $29.99 plan.\\n\\nTo correct this, I will immediately downgrade your account back to the $29.99 plan, and I will also process a refund of $20.00, which is the difference between the two plans. You can expect to see the refund credited back to your credit card within the next 3-5 business days.\\n\\nIn the meantime, I will also send you a confirmation email with the updated account details and a receipt for the corrected charge. If you have any further questions or concerns, please don't hesitate to reach out to me directly.\\n\\nIf you would like to make a payment for the corrected $29.99 charge, you can do so by visiting our website and logging into your account, or by calling our automated payment system at 1-800-XXX-XXXX. We accept all major credit cards, including Visa, Mastercard, and American Express.\",\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'e935df7e-5d40-4310-936d-c8079ab04e8b',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '9bf1ee3d-8885-45aa-9dc7-72d2b4d2e83d',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 48, 147355, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 44, 610302, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '9bf1ee3d-8885-45aa-9dc7-72d2b4d2e83d',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 48, 160327, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'15f5cf5c-8534-4c29-babf-45fa18cf821f'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'billing_agent_639b351b-12c0-4d5a-8fd3-61dc75692e81'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m74152\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Subject: Unexpected charge on my card\\n Message: Hello, I just noticed a charge of $49.99 on my credit card from your company, but I thought\\n I was on the $29.99 plan. Can you explain this charge and adjust it if it's a mistake?\\n Thanks,\\n Sarah\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Billing Support Response:\\n\\nI apologize for the unexpected charge on your credit card, Sarah. I understand that you were expecting to be billed $29.99, but instead, you were charged $49.99. I'm here to help you resolve this issue.\\n\\nAfter reviewing your account, I found that the $49.99 charge is due to an upgrade to our premium plan, which was accidentally applied to your account during a recent system update. This upgrade includes additional features that are not part of the standard $29.99 plan.\\n\\nTo correct this, I will immediately downgrade your account back to the $29.99 plan, and I will also process a refund of $20.00, which is the difference between the two plans. You can expect to see the refund credited back to your credit card within the next 3-5 business days.\\n\\nIn the meantime, I will also send you a confirmation email with the updated account details and a receipt for the corrected charge. If you have any further questions or concerns, please don't hesitate to reach out to me directly.\\n\\nIf you would like to make a payment for the corrected $29.99 charge, you can do so by visiting our website and logging into your account, or by calling our automated payment system at 1-800-XXX-XXXX. We accept all major credit cards, including Visa, Mastercard, and American Express.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'15f5cf5c-8534-4c29-babf-45fa18cf821f'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m44\u001b[0m, \u001b[1;36m598852\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Billing Support Response:\\n\\nI apologize for the unexpected charge on your credit card, Sarah. I understand that you were expecting to be billed $29.99, but instead, you were charged $49.99. I'm here to help you resolve this issue.\\n\\nAfter reviewing your account, I found that the $49.99 charge is due to an upgrade to our premium plan, which was accidentally applied to your account during a recent system update. This upgrade includes additional features that are not part of the standard $29.99 plan.\\n\\nTo correct this, I will immediately downgrade your account back to the $29.99 plan, and I will also process a refund of $20.00, which is the difference between the two plans. You can expect to see the refund credited back to your credit card within the next 3-5 business days.\\n\\nIn the meantime, I will also send you a confirmation email with the updated account details and a receipt for the corrected charge. If you have any further questions or concerns, please don't hesitate to reach out to me directly.\\n\\nIf you would like to make a payment for the corrected $29.99 charge, you can do so by visiting our website and logging into your account, or by calling our automated payment system at 1-800-XXX-XXXX. We accept all major credit cards, including Visa, Mastercard, and American Express.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'e935df7e-5d40-4310-936d-c8079ab04e8b'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'9bf1ee3d-8885-45aa-9dc7-72d2b4d2e83d'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m48\u001b[0m, \u001b[1;36m147355\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m44\u001b[0m, \u001b[1;36m610302\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[32m'turn_id'\u001b[0m: \u001b[32m'9bf1ee3d-8885-45aa-9dc7-72d2b4d2e83d'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m48\u001b[0m, \u001b[1;36m160327\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Specialized Agent technical Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '7ac4b688-66b9-4c88-92e5-eebe74c89848',\n", + "β 'session_name': 'technical_agent_ad214895-1419-414a-a53c-95be2410b2ce',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 77754),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Subject: How to export data?\\n Message: I need to export all my project data to Excel. I've looked through the docs but can't\\n figure out how to do a bulk export. Is this possible? If so, could you walk me through the steps?\\n Best regards,\\n Mike\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': 'Technical Support Response:\\n\\nExporting data in bulk to Excel is a feature available in our system. To achieve this, follow these steps:\\n\\n1. **Login to the system**: Ensure you are logged in with the correct credentials and have the necessary permissions to access and export project data.\\n2. **Navigate to the Project Dashboard**: Click on the \"Projects\" tab and select the project for which you want to export data.\\n3. **Access the Data Export Tool**: In the project dashboard, click on the \"Tools\" menu and select \"Data Export\" from the dropdown list.\\n4. **Select Export Options**: In the Data Export tool, choose the data types you want to export (e.g., tasks, issues, users, etc.). You can select all data types or specific ones based on your requirements.\\n5. **Choose the Export Format**: Select \"Excel (.xlsx)\" as the export format from the available options.\\n6. **Configure Export Settings**: You can configure additional settings such as:\\n\\t* Date range: Specify a date range for the data to be exported.\\n\\t* Data filtering: Apply filters to export specific data based on conditions (e.g., status, priority, etc.).\\n7. **Initiate the Export**: Click the \"Export\" button to start the export process. Depending on the amount of data, this may take a few minutes.\\n8. **Download the Exported File**: Once the export is complete, you will receive a notification. Click on the \"Download\" button to save the exported Excel file to your local machine.\\n\\nSystem Requirements:\\n- Ensure you have the latest version of our software installed (v2.5 or later).\\n- Microsoft Excel 2013 or later is recommended for compatibility.\\n\\nWorkarounds for Common Problems:\\n- If you encounter issues with large data exports, try breaking down the export into smaller chunks using the date range or data filtering options.\\n- If you experience errors during the export process, check the system logs for more information and contact support if needed.\\n\\nIf you need further assistance or encounter any issues during the export process, please don\\'t hesitate to reach out. You can escalate this issue by replying to this email or contacting our support team directly at [support@example.com](mailto:support@example.com) or by calling +1-800-EXAMPLE.',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '7ac4b688-66b9-4c88-92e5-eebe74c89848',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 51, 173315, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': 'Technical Support Response:\\n\\nExporting data in bulk to Excel is a feature available in our system. To achieve this, follow these steps:\\n\\n1. **Login to the system**: Ensure you are logged in with the correct credentials and have the necessary permissions to access and export project data.\\n2. **Navigate to the Project Dashboard**: Click on the \"Projects\" tab and select the project for which you want to export data.\\n3. **Access the Data Export Tool**: In the project dashboard, click on the \"Tools\" menu and select \"Data Export\" from the dropdown list.\\n4. **Select Export Options**: In the Data Export tool, choose the data types you want to export (e.g., tasks, issues, users, etc.). You can select all data types or specific ones based on your requirements.\\n5. **Choose the Export Format**: Select \"Excel (.xlsx)\" as the export format from the available options.\\n6. **Configure Export Settings**: You can configure additional settings such as:\\n\\t* Date range: Specify a date range for the data to be exported.\\n\\t* Data filtering: Apply filters to export specific data based on conditions (e.g., status, priority, etc.).\\n7. **Initiate the Export**: Click the \"Export\" button to start the export process. Depending on the amount of data, this may take a few minutes.\\n8. **Download the Exported File**: Once the export is complete, you will receive a notification. Click on the \"Download\" button to save the exported Excel file to your local machine.\\n\\nSystem Requirements:\\n- Ensure you have the latest version of our software installed (v2.5 or later).\\n- Microsoft Excel 2013 or later is recommended for compatibility.\\n\\nWorkarounds for Common Problems:\\n- If you encounter issues with large data exports, try breaking down the export into smaller chunks using the date range or data filtering options.\\n- If you experience errors during the export process, check the system logs for more information and contact support if needed.\\n\\nIf you need further assistance or encounter any issues during the export process, please don\\'t hesitate to reach out. You can escalate this issue by replying to this email or contacting our support team directly at [support@example.com](mailto:support@example.com) or by calling +1-800-EXAMPLE.',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'f23ef431-c6d1-4fb0-8f4b-7aca7f318aee',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': 'b723839f-7b94-410a-9ab6-ae5b396390a7',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 58, 492987, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 51, 184964, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': 'b723839f-7b94-410a-9ab6-ae5b396390a7',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 58, 506965, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'7ac4b688-66b9-4c88-92e5-eebe74c89848'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'technical_agent_ad214895-1419-414a-a53c-95be2410b2ce'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m77754\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Subject: How to export data?\\n Message: I need to export all my project data to Excel. I've looked through the docs but can't\\n figure out how to do a bulk export. Is this possible? If so, could you walk me through the steps?\\n Best regards,\\n Mike\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Technical Support Response:\\n\\nExporting data in bulk to Excel is a feature available in our system. To achieve this, follow these steps:\\n\\n1. **Login to the system**: Ensure you are logged in with the correct credentials and have the necessary permissions to access and export project data.\\n2. **Navigate to the Project Dashboard**: Click on the \"Projects\" tab and select the project for which you want to export data.\\n3. **Access the Data Export Tool**: In the project dashboard, click on the \"Tools\" menu and select \"Data Export\" from the dropdown list.\\n4. **Select Export Options**: In the Data Export tool, choose the data types you want to export \u001b[0m\u001b[32m(\u001b[0m\u001b[32me.g., tasks, issues, users, etc.\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. You can select all data types or specific ones based on your requirements.\\n5. **Choose the Export Format**: Select \"Excel \u001b[0m\u001b[32m(\u001b[0m\u001b[32m.xlsx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\" as the export format from the available options.\\n6. **Configure Export Settings**: You can configure additional settings such as:\\n\\t* Date range: Specify a date range for the data to be exported.\\n\\t* Data filtering: Apply filters to export specific data based on conditions \u001b[0m\u001b[32m(\u001b[0m\u001b[32me.g., status, priority, etc.\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n7. **Initiate the Export**: Click the \"Export\" button to start the export process. Depending on the amount of data, this may take a few minutes.\\n8. **Download the Exported File**: Once the export is complete, you will receive a notification. Click on the \"Download\" button to save the exported Excel file to your local machine.\\n\\nSystem Requirements:\\n- Ensure you have the latest version of our software installed \u001b[0m\u001b[32m(\u001b[0m\u001b[32mv2.5 or later\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n- Microsoft Excel 2013 or later is recommended for compatibility.\\n\\nWorkarounds for Common Problems:\\n- If you encounter issues with large data exports, try breaking down the export into smaller chunks using the date range or data filtering options.\\n- If you experience errors during the export process, check the system logs for more information and contact support if needed.\\n\\nIf you need further assistance or encounter any issues during the export process, please don\\'t hesitate to reach out. You can escalate this issue by replying to this email or contacting our support team directly at \u001b[0m\u001b[32m[\u001b[0m\u001b[32msupport@example.com\u001b[0m\u001b[32m]\u001b[0m\u001b[32m(\u001b[0m\u001b[32mmailto:support@example.com\u001b[0m\u001b[32m)\u001b[0m\u001b[32m or by calling +1-800-EXAMPLE.'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'7ac4b688-66b9-4c88-92e5-eebe74c89848'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m51\u001b[0m, \u001b[1;36m173315\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Technical Support Response:\\n\\nExporting data in bulk to Excel is a feature available in our system. To achieve this, follow these steps:\\n\\n1. **Login to the system**: Ensure you are logged in with the correct credentials and have the necessary permissions to access and export project data.\\n2. **Navigate to the Project Dashboard**: Click on the \"Projects\" tab and select the project for which you want to export data.\\n3. **Access the Data Export Tool**: In the project dashboard, click on the \"Tools\" menu and select \"Data Export\" from the dropdown list.\\n4. **Select Export Options**: In the Data Export tool, choose the data types you want to export \u001b[0m\u001b[32m(\u001b[0m\u001b[32me.g., tasks, issues, users, etc.\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. You can select all data types or specific ones based on your requirements.\\n5. **Choose the Export Format**: Select \"Excel \u001b[0m\u001b[32m(\u001b[0m\u001b[32m.xlsx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\" as the export format from the available options.\\n6. **Configure Export Settings**: You can configure additional settings such as:\\n\\t* Date range: Specify a date range for the data to be exported.\\n\\t* Data filtering: Apply filters to export specific data based on conditions \u001b[0m\u001b[32m(\u001b[0m\u001b[32me.g., status, priority, etc.\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n7. **Initiate the Export**: Click the \"Export\" button to start the export process. Depending on the amount of data, this may take a few minutes.\\n8. **Download the Exported File**: Once the export is complete, you will receive a notification. Click on the \"Download\" button to save the exported Excel file to your local machine.\\n\\nSystem Requirements:\\n- Ensure you have the latest version of our software installed \u001b[0m\u001b[32m(\u001b[0m\u001b[32mv2.5 or later\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n- Microsoft Excel 2013 or later is recommended for compatibility.\\n\\nWorkarounds for Common Problems:\\n- If you encounter issues with large data exports, try breaking down the export into smaller chunks using the date range or data filtering options.\\n- If you experience errors during the export process, check the system logs for more information and contact support if needed.\\n\\nIf you need further assistance or encounter any issues during the export process, please don\\'t hesitate to reach out. You can escalate this issue by replying to this email or contacting our support team directly at \u001b[0m\u001b[32m[\u001b[0m\u001b[32msupport@example.com\u001b[0m\u001b[32m]\u001b[0m\u001b[32m(\u001b[0m\u001b[32mmailto:support@example.com\u001b[0m\u001b[32m)\u001b[0m\u001b[32m or by calling +1-800-EXAMPLE.'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'f23ef431-c6d1-4fb0-8f4b-7aca7f318aee'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'b723839f-7b94-410a-9ab6-ae5b396390a7'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m58\u001b[0m, \u001b[1;36m492987\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m51\u001b[0m, \u001b[1;36m184964\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[32m'turn_id'\u001b[0m: \u001b[32m'b723839f-7b94-410a-9ab6-ae5b396390a7'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m58\u001b[0m, \u001b[1;36m506965\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Specialized Agent account Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': 'ce055c73-5ebe-4b15-9a23-4bce22def0c7',\n", + "β 'session_name': 'account_agent_31fb704d-7e3a-4fd4-8597-46f9d932b11b',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 82980),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Subject: Can't access my account\\n Message: Hi, I've been trying to log in for the past hour but keep getting an 'invalid password' error. \\n I'm sure I'm using the right password. Can you help me regain access? This is urgent as I need to \\n submit a report by end of day.\\n - John\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': 'Account Support Response:\\n\\nDear John,\\n\\nWe take account security and accessibility very seriously. To ensure the integrity of your account, we must follow a thorough verification process. Before we can assist you with regaining access, we need to confirm your identity.\\n\\nTo initiate the account recovery process, please follow these steps:\\n\\n1. **Verify your account information**: Please reply to this email with your full name, the email address associated with your account, and the last 4 digits of your phone number (if you have one listed on your account).\\n2. **Password reset**: We will send you a password reset link to the email address associated with your account. This link will allow you to create a new password. Please note that this link will only be valid for 24 hours.\\n3. **Security questions**: You may be prompted to answer security questions to further verify your identity.\\n\\n**Important Security Note**: If you are using a public computer or network, please be cautious when accessing your account. Public computers and networks may be vulnerable to malware and other security risks. We recommend using a secure, private device and network to access your account.\\n\\n**Resolution Timeframe**: Our goal is to resolve account access issues within 2-4 hours. However, this may vary depending on the complexity of the issue and the verification process.\\n\\n**Security Tips**:\\n\\n* Use a unique and complex password for your account.\\n* Avoid using public computers or networks to access sensitive information.\\n* Enable two-factor authentication (2FA) whenever possible.\\n* Regularly monitor your account activity and report any suspicious behavior to our support team.\\n\\nWe appreciate your cooperation and understanding in this matter. If you have any further questions or concerns, please do not hesitate to reach out to us.\\n\\nSincerely,\\nAccount Support Team',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': 'ce055c73-5ebe-4b15-9a23-4bce22def0c7',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 37, 108517, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': 'Account Support Response:\\n\\nDear John,\\n\\nWe take account security and accessibility very seriously. To ensure the integrity of your account, we must follow a thorough verification process. Before we can assist you with regaining access, we need to confirm your identity.\\n\\nTo initiate the account recovery process, please follow these steps:\\n\\n1. **Verify your account information**: Please reply to this email with your full name, the email address associated with your account, and the last 4 digits of your phone number (if you have one listed on your account).\\n2. **Password reset**: We will send you a password reset link to the email address associated with your account. This link will allow you to create a new password. Please note that this link will only be valid for 24 hours.\\n3. **Security questions**: You may be prompted to answer security questions to further verify your identity.\\n\\n**Important Security Note**: If you are using a public computer or network, please be cautious when accessing your account. Public computers and networks may be vulnerable to malware and other security risks. We recommend using a secure, private device and network to access your account.\\n\\n**Resolution Timeframe**: Our goal is to resolve account access issues within 2-4 hours. However, this may vary depending on the complexity of the issue and the verification process.\\n\\n**Security Tips**:\\n\\n* Use a unique and complex password for your account.\\n* Avoid using public computers or networks to access sensitive information.\\n* Enable two-factor authentication (2FA) whenever possible.\\n* Regularly monitor your account activity and report any suspicious behavior to our support team.\\n\\nWe appreciate your cooperation and understanding in this matter. If you have any further questions or concerns, please do not hesitate to reach out to us.\\n\\nSincerely,\\nAccount Support Team',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '66bd14b9-8f3f-4cf2-b53e-9aab7dd04e69',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '1d9a4038-29ca-4339-97bc-d836b0d5f0d6',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 41, 527934, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 37, 120263, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '1d9a4038-29ca-4339-97bc-d836b0d5f0d6',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 12, 41, 539663, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'ce055c73-5ebe-4b15-9a23-4bce22def0c7'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'account_agent_31fb704d-7e3a-4fd4-8597-46f9d932b11b'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m82980\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Subject: Can't access my account\\n Message: Hi, I've been trying to log in for the past hour but keep getting an 'invalid password' error. \\n I'm sure I'm using the right password. Can you help me regain access? This is urgent as I need to \\n submit a report by end of day.\\n - John\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Account Support Response:\\n\\nDear John,\\n\\nWe take account security and accessibility very seriously. To ensure the integrity of your account, we must follow a thorough verification process. Before we can assist you with regaining access, we need to confirm your identity.\\n\\nTo initiate the account recovery process, please follow these steps:\\n\\n1. **Verify your account information**: Please reply to this email with your full name, the email address associated with your account, and the last 4 digits of your phone number \u001b[0m\u001b[32m(\u001b[0m\u001b[32mif you have one listed on your account\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n2. **Password reset**: We will send you a password reset link to the email address associated with your account. This link will allow you to create a new password. Please note that this link will only be valid for 24 hours.\\n3. **Security questions**: You may be prompted to answer security questions to further verify your identity.\\n\\n**Important Security Note**: If you are using a public computer or network, please be cautious when accessing your account. Public computers and networks may be vulnerable to malware and other security risks. We recommend using a secure, private device and network to access your account.\\n\\n**Resolution Timeframe**: Our goal is to resolve account access issues within 2-4 hours. However, this may vary depending on the complexity of the issue and the verification process.\\n\\n**Security Tips**:\\n\\n* Use a unique and complex password for your account.\\n* Avoid using public computers or networks to access sensitive information.\\n* Enable two-factor authentication \u001b[0m\u001b[32m(\u001b[0m\u001b[32m2FA\u001b[0m\u001b[32m)\u001b[0m\u001b[32m whenever possible.\\n* Regularly monitor your account activity and report any suspicious behavior to our support team.\\n\\nWe appreciate your cooperation and understanding in this matter. If you have any further questions or concerns, please do not hesitate to reach out to us.\\n\\nSincerely,\\nAccount Support Team'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'ce055c73-5ebe-4b15-9a23-4bce22def0c7'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m108517\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Account Support Response:\\n\\nDear John,\\n\\nWe take account security and accessibility very seriously. To ensure the integrity of your account, we must follow a thorough verification process. Before we can assist you with regaining access, we need to confirm your identity.\\n\\nTo initiate the account recovery process, please follow these steps:\\n\\n1. **Verify your account information**: Please reply to this email with your full name, the email address associated with your account, and the last 4 digits of your phone number \u001b[0m\u001b[32m(\u001b[0m\u001b[32mif you have one listed on your account\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n2. **Password reset**: We will send you a password reset link to the email address associated with your account. This link will allow you to create a new password. Please note that this link will only be valid for 24 hours.\\n3. **Security questions**: You may be prompted to answer security questions to further verify your identity.\\n\\n**Important Security Note**: If you are using a public computer or network, please be cautious when accessing your account. Public computers and networks may be vulnerable to malware and other security risks. We recommend using a secure, private device and network to access your account.\\n\\n**Resolution Timeframe**: Our goal is to resolve account access issues within 2-4 hours. However, this may vary depending on the complexity of the issue and the verification process.\\n\\n**Security Tips**:\\n\\n* Use a unique and complex password for your account.\\n* Avoid using public computers or networks to access sensitive information.\\n* Enable two-factor authentication \u001b[0m\u001b[32m(\u001b[0m\u001b[32m2FA\u001b[0m\u001b[32m)\u001b[0m\u001b[32m whenever possible.\\n* Regularly monitor your account activity and report any suspicious behavior to our support team.\\n\\nWe appreciate your cooperation and understanding in this matter. If you have any further questions or concerns, please do not hesitate to reach out to us.\\n\\nSincerely,\\nAccount Support Team'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'66bd14b9-8f3f-4cf2-b53e-9aab7dd04e69'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'1d9a4038-29ca-4339-97bc-d836b0d5f0d6'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m41\u001b[0m, \u001b[1;36m527934\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m120263\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[32m'turn_id'\u001b[0m: \u001b[32m'1d9a4038-29ca-4339-97bc-d836b0d5f0d6'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m41\u001b[0m, \u001b[1;36m539663\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Specialized Agent product Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '14d2dc84-4a52-47db-99b1-854d26fe6301',\n", + "β 'session_name': 'product_agent_f5919d7e-447a-43e2-a901-30724ffaff37',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 12, 36, 86944),\n", + "β 'turns': []\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'14d2dc84-4a52-47db-99b1-854d26fe6301'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'product_agent_f5919d7e-447a-43e2-a901-30724ffaff37'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m36\u001b[0m, \u001b[1;36m86944\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[1m}\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "routing_agent_session = client.agents.session.retrieve(session_id=routing_agent_session_id, agent_id=routing_agent.agent_id)\n", + "print(\"Routing Agent Session:\")\n", + "pprint(routing_agent_session.to_dict())\n", + "\n", + "for specialized_agent_type, specialized_agent in specialized_agents.items():\n", + " specialized_agent_session = client.agents.session.retrieve(session_id=specialized_agent.session_id, agent_id=specialized_agent.agent_id)\n", + " print(f\"Specialized Agent {specialized_agent_type} Session:\")\n", + " pprint(specialized_agent_session.to_dict())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1.3 Parallelization\n", + "\n", + "**Parallelization** divides a task into multiple independent subtasks, which are processed in parallel, and have their outputs aggregated programatically. \n", + "\n", + "\n", + "\n", + "**Example: Stackholder Impact Analysis**" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Stakeholder 1: =========\n", + "**Market Change Impact Analysis: Customers**\n", + "\n", + "### Overview\n", + "The customer stakeholder group is a crucial segment that will be impacted by market changes. As a price-sensitive group, they are likely to be influenced by fluctuations in prices. Additionally, their desire for better technology and environmental concerns will drive their purchasing decisions.\n", + "\n", + "### Specific Impacts\n", + "\n", + "1. **Price Increases**: If market changes lead to price increases, customers may be deterred from making purchases, potentially leading to a decline in sales.\n", + "2. **Technological Advancements**: If competitors introduce new and improved technologies, customers may switch to alternative products or services, leading to a loss of market share.\n", + "3. **Environmental Regulations**: Changes in environmental regulations or increasing consumer awareness of environmental issues may lead to a shift in demand towards more sustainable products or services.\n", + "4. **Supply Chain Disruptions**: Market changes that affect supply chains may lead to stockouts or delays, resulting in customer dissatisfaction and potential losses.\n", + "\n", + "### Recommended Actions\n", + "\n", + "**High Priority**\n", + "\n", + "1. **Monitor Competitor Pricing**: Continuously track competitor pricing to ensure our prices remain competitive and adjust accordingly.\n", + "2. **Invest in Technological Upgrades**: Regularly invest in research and development to stay up-to-date with the latest technologies and innovations.\n", + "3. **Develop Sustainable Products/Services**: Develop and promote environmentally friendly products or services to appeal to the growing demand for sustainable options.\n", + "\n", + "**Medium Priority**\n", + "\n", + "1. **Improve Supply Chain Resilience**: Diversify supply chains and develop contingency plans to minimize the impact of potential disruptions.\n", + "2. **Enhance Customer Communication**: Regularly communicate with customers about product availability, pricing, and any changes to mitigate potential dissatisfaction.\n", + "3. **Offer Price-Matching Guarantees**: Consider offering price-matching guarantees to maintain customer loyalty and competitiveness.\n", + "\n", + "**Low Priority**\n", + "\n", + "1. **Conduct Market Research**: Conduct regular market research to stay informed about customer preferences and trends.\n", + "2. **Develop Loyalty Programs**: Develop loyalty programs to reward repeat customers and encourage retention.\n", + "3. **Explore New Markets**: Explore new markets or customer segments to expand our customer base.\n", + "\n", + "By prioritizing these actions, we can effectively respond to market changes and maintain a competitive edge in the market, ultimately meeting the evolving needs and expectations of our price-sensitive, tech-savvy, and environmentally conscious customers.\n", + "\n", + "\n", + "========= Stakeholder 2: =========\n", + "**Employee Stakeholder Group Analysis**\n", + "\n", + "### Introduction\n", + "The employee stakeholder group is crucial to the success of any organization. Market changes can have a significant impact on employees, affecting their job security, skill requirements, and overall direction. This analysis will outline the specific impacts of market changes on employees and provide recommended actions to mitigate these effects.\n", + "\n", + "### Impacts of Market Changes on Employees\n", + "\n", + "1. **Job Security Worries**: Market changes can lead to restructuring, downsizing, or changes in job roles, causing employees to worry about their job security.\n", + "2. **Need for New Skills**: Market changes often require employees to acquire new skills to remain relevant, which can be a challenge for those who are not adaptable or have limited training opportunities.\n", + "3. **Lack of Clear Direction**: Employees may feel uncertain about the organization's future and their role in it, leading to a lack of clear direction and motivation.\n", + "\n", + "### Recommended Actions\n", + "\n", + "**High Priority**\n", + "\n", + "1. **Communicate Clearly and Transparently**: Provide regular updates on the organization's strategy and plans to address market changes, ensuring employees understand the reasons behind any changes and how they will be affected.\n", + "2. **Training and Development Programs**: Offer training and development opportunities to help employees acquire new skills and adapt to changing market conditions.\n", + "3. **Job Security Assurance**: Provide assurance on job security wherever possible, and offer support for employees who may be impacted by restructuring or downsizing.\n", + "\n", + "**Medium Priority**\n", + "\n", + "1. **Employee Engagement Initiatives**: Implement employee engagement initiatives to boost morale and motivation, such as recognition programs, team-building activities, and feedback mechanisms.\n", + "2. **Mentorship Programs**: Establish mentorship programs to pair employees with experienced colleagues who can provide guidance and support in navigating market changes.\n", + "3. **Performance Management**: Review and update performance management systems to ensure they are aligned with the organization's new strategy and goals.\n", + "\n", + "**Low Priority**\n", + "\n", + "1. **Employee Benefits Review**: Review employee benefits to ensure they are still relevant and competitive in the changing market, and make adjustments as necessary.\n", + "2. **Social Responsibility Initiatives**: Consider implementing social responsibility initiatives that demonstrate the organization's commitment to its employees and the community, such as volunteer programs or charitable donations.\n", + "\n", + "### Conclusion\n", + "By understanding the impacts of market changes on employees and taking proactive steps to address their concerns, organizations can mitigate the negative effects and create a more positive and productive work environment. By prioritizing clear communication, training and development, and job security assurance, organizations can help employees navigate market changes and thrive in a rapidly changing business landscape.\n", + "\n", + "\n", + "========= Stakeholder 3: =========\n", + "**Investor Impact Analysis**\n", + "==========================\n", + "\n", + "### Introduction\n", + "\n", + "Market changes can have a significant impact on investors, who have certain expectations and concerns. This analysis will outline the potential effects of market changes on investors and provide recommended actions to mitigate risks and capitalize on opportunities.\n", + "\n", + "### Expected Impacts\n", + "\n", + "1. **Growth Expectations**: Market changes can affect the growth prospects of investments. For example:\n", + "\t* Economic downturns can reduce revenue and profitability, impacting growth.\n", + "\t* Industry disruptions can create new opportunities for growth, but also increase competition.\n", + "2. **Cost Control**: Investors are concerned about cost control, as market changes can impact operational expenses. For instance:\n", + "\t* Increased regulatory requirements can lead to higher compliance costs.\n", + "\t* Supply chain disruptions can result in higher procurement costs.\n", + "3. **Risk Concerns**: Market changes can introduce new risks or exacerbate existing ones, affecting investor confidence. Examples include:\n", + "\t* Market volatility can increase the risk of investment losses.\n", + "\t* Cybersecurity threats can compromise sensitive investor data.\n", + "\n", + "### Recommended Actions\n", + "\n", + "**High Priority**\n", + "\n", + "1. **Diversification**: Encourage investors to diversify their portfolios to minimize risk and maximize returns.\n", + "2. **Regular Portfolio Reviews**: Conduct regular reviews of investment portfolios to ensure they remain aligned with investor goals and risk tolerance.\n", + "3. **Risk Management**: Implement effective risk management strategies, such as hedging or insurance, to mitigate potential losses.\n", + "\n", + "**Medium Priority**\n", + "\n", + "1. **Cost Optimization**: Help investors optimize costs by identifying areas of inefficiency and implementing cost-saving measures.\n", + "2. **Regulatory Compliance**: Ensure investors are aware of and compliant with changing regulatory requirements to avoid potential fines or penalties.\n", + "3. **Investor Education**: Provide investors with educational resources and updates on market trends and changes to help them make informed decisions.\n", + "\n", + "**Low Priority**\n", + "\n", + "1. **Investment in Emerging Technologies**: Consider investing in emerging technologies, such as blockchain or artificial intelligence, to stay ahead of the curve and capitalize on potential growth opportunities.\n", + "2. **Sustainable Investing**: Encourage investors to consider sustainable investing options, which can provide long-term growth opportunities while minimizing environmental and social risks.\n", + "\n", + "### Conclusion\n", + "\n", + "Market changes can have a significant impact on investors, affecting their growth expectations, cost control, and risk concerns. By understanding these impacts and taking recommended actions, investors can mitigate risks, capitalize on opportunities, and achieve their investment goals. Prioritizing diversification, regular portfolio reviews, and risk management can help investors navigate market changes with confidence.\n", + "\n", + "\n", + "========= Stakeholder 4: =========\n", + "**Market Change Impact Analysis: Suppliers**\n", + "=============================================\n", + "\n", + "### Introduction\n", + "\n", + "The supplier stakeholder group is crucial to the success of any organization, providing essential goods and services that enable operations. Market changes can significantly impact suppliers, and it is essential to analyze these impacts to develop strategies that mitigate risks and capitalize on opportunities.\n", + "\n", + "### Impacts of Market Changes on Suppliers\n", + "\n", + "#### **Capacity Constraints**\n", + "\n", + "* **Impact:** Suppliers may face challenges in meeting demand due to limited production capacity, leading to delays, stockouts, or reduced product quality.\n", + "* **Priority:** High\n", + "* **Recommended Actions:**\n", + "\t1. **Invest in capacity expansion**: Suppliers should consider investing in new equipment, technology, or hiring additional staff to increase production capacity.\n", + "\t2. **Implement lean manufacturing practices**: Suppliers can optimize production processes to reduce waste, improve efficiency, and increase output.\n", + "\t3. **Develop strategic partnerships**: Suppliers can form partnerships with other companies to share resources, expertise, and capacity to meet demand.\n", + "\n", + "#### **Price Pressures**\n", + "\n", + "* **Impact:** Suppliers may face downward pressure on prices, reducing profit margins and making it challenging to maintain quality and invest in research and development.\n", + "* **Priority:** Medium\n", + "* **Recommended Actions:**\n", + "\t1. **Cost reduction initiatives**: Suppliers should identify areas to reduce costs, such as streamlining operations, renegotiating contracts with their own suppliers, or implementing energy-efficient practices.\n", + "\t2. **Value-added services**: Suppliers can offer additional services, such as customization, technical support, or logistics management, to differentiate themselves and command premium prices.\n", + "\t3. **Develop strategic pricing strategies**: Suppliers can use data analytics and market research to develop pricing strategies that balance profitability with customer demand.\n", + "\n", + "#### **Tech Transitions**\n", + "\n", + "* **Impact:** Suppliers may need to invest in new technologies, such as digitalization, automation, or sustainability solutions, to remain competitive and meet changing customer demands.\n", + "* **Priority:** High\n", + "* **Recommended Actions:**\n", + "\t1. **Invest in research and development**: Suppliers should allocate resources to develop new technologies, products, or services that meet emerging customer needs.\n", + "\t2. **Partner with technology providers**: Suppliers can collaborate with technology companies to access new solutions, expertise, and funding.\n", + "\t3. **Develop a digital transformation strategy**: Suppliers should create a roadmap for digitalization, including investments in data analytics, artificial intelligence, and cybersecurity.\n", + "\n", + "### Conclusion\n", + "\n", + "Suppliers face significant challenges due to market changes, including capacity constraints, price pressures, and tech transitions. By understanding these impacts and taking proactive measures, suppliers\n", + "\n", + "\n" + ] + } + ], + "source": [ + "from concurrent.futures import ThreadPoolExecutor\n", + "from typing import List\n", + "\n", + "worker_agent_config = {\n", + " **base_agent_config,\n", + " \"instructions\": \"\"\"You are a helpful assistant that can analyze the impact of market changes on stakeholders.\n", + " Analyze how market changes will impact this stakeholder group.\n", + " Provide specific impacts and recommended actions.\n", + " Format with clear sections and priorities.\n", + " \"\"\",\n", + "}\n", + "\n", + "def create_worker_task(task: str):\n", + " worker_agent = Agent(client, **worker_agent_config)\n", + " worker_session_id = worker_agent.create_session(session_name=f\"worker_agent_{uuid.uuid4()}\")\n", + " task_response = worker_agent.create_turn(\n", + " messages=[{\"role\": \"user\", \"content\": task}],\n", + " stream=False,\n", + " session_id=worker_session_id,\n", + " )\n", + " return {\n", + " \"worker_agent\": worker_agent,\n", + " \"task_response\": task_response.output_message.content,\n", + " }\n", + "\n", + "def parallelization_workflow(tasks: List[str]):\n", + " if isinstance(client, LlamaStackClient):\n", + " # NOTE: LlamaStackAsLibraryClient does not support parallel thread pool execution\n", + " with ThreadPoolExecutor(max_workers=len(tasks)) as executor:\n", + " futures = [executor.submit(create_worker_task, task) for task in tasks]\n", + " results = [future.result() for future in futures]\n", + " return results\n", + " else:\n", + " results = []\n", + " for task in tasks:\n", + " result = create_worker_task(task)\n", + " results.append(result)\n", + " return results\n", + "\n", + "stakeholders = [\n", + " \"\"\"Customers:\n", + " - Price sensitive\n", + " - Want better tech\n", + " - Environmental concerns\"\"\",\n", + " \n", + " \"\"\"Employees:\n", + " - Job security worries\n", + " - Need new skills\n", + " - Want clear direction\"\"\",\n", + " \n", + " \"\"\"Investors:\n", + " - Expect growth\n", + " - Want cost control\n", + " - Risk concerns\"\"\",\n", + " \n", + " \"\"\"Suppliers:\n", + " - Capacity constraints\n", + " - Price pressures\n", + " - Tech transitions\"\"\"\n", + "]\n", + "\n", + "results = parallelization_workflow(stakeholders)\n", + "for i, result in enumerate(results):\n", + " print(f\"========= Stakeholder {i+1}: =========\")\n", + " print(result[\"task_response\"])\n", + " print(\"\\n\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.3.1 Monitor Parallelization Internals\n", + "\n", + "Now, let's see how the worker agents processed the tasks. " + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Worker Agent 1: =========\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '35fd551d-be16-428b-a089-65fc8c33a6e6',\n", + "β 'session_name': 'worker_agent_863af860-7f5a-4396-911d-b390aed0d20a',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 392849),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Customers:\\n - Price sensitive\\n - Want better tech\\n - Environmental concerns',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '**Market Change Impact Analysis: Customers**\\n\\n### Overview\\nThe customer stakeholder group is a crucial segment that will be impacted by market changes. As a price-sensitive group, they are likely to be influenced by fluctuations in prices. Additionally, their desire for better technology and environmental concerns will drive their purchasing decisions.\\n\\n### Specific Impacts\\n\\n1. **Price Increases**: If market changes lead to price increases, customers may be deterred from making purchases, potentially leading to a decline in sales.\\n2. **Technological Advancements**: If competitors introduce new and improved technologies, customers may switch to alternative products or services, leading to a loss of market share.\\n3. **Environmental Regulations**: Changes in environmental regulations or increasing consumer awareness of environmental issues may lead to a shift in demand towards more sustainable products or services.\\n4. **Supply Chain Disruptions**: Market changes that affect supply chains may lead to stockouts or delays, resulting in customer dissatisfaction and potential losses.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Monitor Competitor Pricing**: Continuously track competitor pricing to ensure our prices remain competitive and adjust accordingly.\\n2. **Invest in Technological Upgrades**: Regularly invest in research and development to stay up-to-date with the latest technologies and innovations.\\n3. **Develop Sustainable Products/Services**: Develop and promote environmentally friendly products or services to appeal to the growing demand for sustainable options.\\n\\n**Medium Priority**\\n\\n1. **Improve Supply Chain Resilience**: Diversify supply chains and develop contingency plans to minimize the impact of potential disruptions.\\n2. **Enhance Customer Communication**: Regularly communicate with customers about product availability, pricing, and any changes to mitigate potential dissatisfaction.\\n3. **Offer Price-Matching Guarantees**: Consider offering price-matching guarantees to maintain customer loyalty and competitiveness.\\n\\n**Low Priority**\\n\\n1. **Conduct Market Research**: Conduct regular market research to stay informed about customer preferences and trends.\\n2. **Develop Loyalty Programs**: Develop loyalty programs to reward repeat customers and encourage retention.\\n3. **Explore New Markets**: Explore new markets or customer segments to expand our customer base.\\n\\nBy prioritizing these actions, we can effectively respond to market changes and maintain a competitive edge in the market, ultimately meeting the evolving needs and expectations of our price-sensitive, tech-savvy, and environmentally conscious customers.',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '35fd551d-be16-428b-a089-65fc8c33a6e6',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 399213, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '**Market Change Impact Analysis: Customers**\\n\\n### Overview\\nThe customer stakeholder group is a crucial segment that will be impacted by market changes. As a price-sensitive group, they are likely to be influenced by fluctuations in prices. Additionally, their desire for better technology and environmental concerns will drive their purchasing decisions.\\n\\n### Specific Impacts\\n\\n1. **Price Increases**: If market changes lead to price increases, customers may be deterred from making purchases, potentially leading to a decline in sales.\\n2. **Technological Advancements**: If competitors introduce new and improved technologies, customers may switch to alternative products or services, leading to a loss of market share.\\n3. **Environmental Regulations**: Changes in environmental regulations or increasing consumer awareness of environmental issues may lead to a shift in demand towards more sustainable products or services.\\n4. **Supply Chain Disruptions**: Market changes that affect supply chains may lead to stockouts or delays, resulting in customer dissatisfaction and potential losses.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Monitor Competitor Pricing**: Continuously track competitor pricing to ensure our prices remain competitive and adjust accordingly.\\n2. **Invest in Technological Upgrades**: Regularly invest in research and development to stay up-to-date with the latest technologies and innovations.\\n3. **Develop Sustainable Products/Services**: Develop and promote environmentally friendly products or services to appeal to the growing demand for sustainable options.\\n\\n**Medium Priority**\\n\\n1. **Improve Supply Chain Resilience**: Diversify supply chains and develop contingency plans to minimize the impact of potential disruptions.\\n2. **Enhance Customer Communication**: Regularly communicate with customers about product availability, pricing, and any changes to mitigate potential dissatisfaction.\\n3. **Offer Price-Matching Guarantees**: Consider offering price-matching guarantees to maintain customer loyalty and competitiveness.\\n\\n**Low Priority**\\n\\n1. **Conduct Market Research**: Conduct regular market research to stay informed about customer preferences and trends.\\n2. **Develop Loyalty Programs**: Develop loyalty programs to reward repeat customers and encourage retention.\\n3. **Explore New Markets**: Explore new markets or customer segments to expand our customer base.\\n\\nBy prioritizing these actions, we can effectively respond to market changes and maintain a competitive edge in the market, ultimately meeting the evolving needs and expectations of our price-sensitive, tech-savvy, and environmentally conscious customers.',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '24e614c3-5c93-4673-b848-c04727115c2e',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': 'b054f78c-aff5-41ca-990e-195f4fba2060',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 12018, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 409452, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': 'b054f78c-aff5-41ca-990e-195f4fba2060',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 23415, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'35fd551d-be16-428b-a089-65fc8c33a6e6'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_863af860-7f5a-4396-911d-b390aed0d20a'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m392849\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Customers:\\n - Price sensitive\\n - Want better tech\\n - Environmental concerns'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'**Market Change Impact Analysis: Customers**\\n\\n### Overview\\nThe customer stakeholder group is a crucial segment that will be impacted by market changes. As a price-sensitive group, they are likely to be influenced by fluctuations in prices. Additionally, their desire for better technology and environmental concerns will drive their purchasing decisions.\\n\\n### Specific Impacts\\n\\n1. **Price Increases**: If market changes lead to price increases, customers may be deterred from making purchases, potentially leading to a decline in sales.\\n2. **Technological Advancements**: If competitors introduce new and improved technologies, customers may switch to alternative products or services, leading to a loss of market share.\\n3. **Environmental Regulations**: Changes in environmental regulations or increasing consumer awareness of environmental issues may lead to a shift in demand towards more sustainable products or services.\\n4. **Supply Chain Disruptions**: Market changes that affect supply chains may lead to stockouts or delays, resulting in customer dissatisfaction and potential losses.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Monitor Competitor Pricing**: Continuously track competitor pricing to ensure our prices remain competitive and adjust accordingly.\\n2. **Invest in Technological Upgrades**: Regularly invest in research and development to stay up-to-date with the latest technologies and innovations.\\n3. **Develop Sustainable Products/Services**: Develop and promote environmentally friendly products or services to appeal to the growing demand for sustainable options.\\n\\n**Medium Priority**\\n\\n1. **Improve Supply Chain Resilience**: Diversify supply chains and develop contingency plans to minimize the impact of potential disruptions.\\n2. **Enhance Customer Communication**: Regularly communicate with customers about product availability, pricing, and any changes to mitigate potential dissatisfaction.\\n3. **Offer Price-Matching Guarantees**: Consider offering price-matching guarantees to maintain customer loyalty and competitiveness.\\n\\n**Low Priority**\\n\\n1. **Conduct Market Research**: Conduct regular market research to stay informed about customer preferences and trends.\\n2. **Develop Loyalty Programs**: Develop loyalty programs to reward repeat customers and encourage retention.\\n3. **Explore New Markets**: Explore new markets or customer segments to expand our customer base.\\n\\nBy prioritizing these actions, we can effectively respond to market changes and maintain a competitive edge in the market, ultimately meeting the evolving needs and expectations of our price-sensitive, tech-savvy, and environmentally conscious customers.'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'35fd551d-be16-428b-a089-65fc8c33a6e6'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m399213\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'**Market Change Impact Analysis: Customers**\\n\\n### Overview\\nThe customer stakeholder group is a crucial segment that will be impacted by market changes. As a price-sensitive group, they are likely to be influenced by fluctuations in prices. Additionally, their desire for better technology and environmental concerns will drive their purchasing decisions.\\n\\n### Specific Impacts\\n\\n1. **Price Increases**: If market changes lead to price increases, customers may be deterred from making purchases, potentially leading to a decline in sales.\\n2. **Technological Advancements**: If competitors introduce new and improved technologies, customers may switch to alternative products or services, leading to a loss of market share.\\n3. **Environmental Regulations**: Changes in environmental regulations or increasing consumer awareness of environmental issues may lead to a shift in demand towards more sustainable products or services.\\n4. **Supply Chain Disruptions**: Market changes that affect supply chains may lead to stockouts or delays, resulting in customer dissatisfaction and potential losses.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Monitor Competitor Pricing**: Continuously track competitor pricing to ensure our prices remain competitive and adjust accordingly.\\n2. **Invest in Technological Upgrades**: Regularly invest in research and development to stay up-to-date with the latest technologies and innovations.\\n3. **Develop Sustainable Products/Services**: Develop and promote environmentally friendly products or services to appeal to the growing demand for sustainable options.\\n\\n**Medium Priority**\\n\\n1. **Improve Supply Chain Resilience**: Diversify supply chains and develop contingency plans to minimize the impact of potential disruptions.\\n2. **Enhance Customer Communication**: Regularly communicate with customers about product availability, pricing, and any changes to mitigate potential dissatisfaction.\\n3. **Offer Price-Matching Guarantees**: Consider offering price-matching guarantees to maintain customer loyalty and competitiveness.\\n\\n**Low Priority**\\n\\n1. **Conduct Market Research**: Conduct regular market research to stay informed about customer preferences and trends.\\n2. **Develop Loyalty Programs**: Develop loyalty programs to reward repeat customers and encourage retention.\\n3. **Explore New Markets**: Explore new markets or customer segments to expand our customer base.\\n\\nBy prioritizing these actions, we can effectively respond to market changes and maintain a competitive edge in the market, ultimately meeting the evolving needs and expectations of our price-sensitive, tech-savvy, and environmentally conscious customers.'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'24e614c3-5c93-4673-b848-c04727115c2e'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'b054f78c-aff5-41ca-990e-195f4fba2060'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m12018\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m409452\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[32m'turn_id'\u001b[0m: \u001b[32m'b054f78c-aff5-41ca-990e-195f4fba2060'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m23415\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Worker Agent 2: =========\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '86d5dbc8-4118-47c3-a3ba-70fbf442a8e7',\n", + "β 'session_name': 'worker_agent_1b1bf719-ef3a-4da9-934f-4f4d78c0e2f0',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 376994),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Employees:\\n - Job security worries\\n - Need new skills\\n - Want clear direction',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': \"**Employee Stakeholder Group Analysis**\\n\\n### Introduction\\nThe employee stakeholder group is crucial to the success of any organization. Market changes can have a significant impact on employees, affecting their job security, skill requirements, and overall direction. This analysis will outline the specific impacts of market changes on employees and provide recommended actions to mitigate these effects.\\n\\n### Impacts of Market Changes on Employees\\n\\n1. **Job Security Worries**: Market changes can lead to restructuring, downsizing, or changes in job roles, causing employees to worry about their job security.\\n2. **Need for New Skills**: Market changes often require employees to acquire new skills to remain relevant, which can be a challenge for those who are not adaptable or have limited training opportunities.\\n3. **Lack of Clear Direction**: Employees may feel uncertain about the organization's future and their role in it, leading to a lack of clear direction and motivation.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Communicate Clearly and Transparently**: Provide regular updates on the organization's strategy and plans to address market changes, ensuring employees understand the reasons behind any changes and how they will be affected.\\n2. **Training and Development Programs**: Offer training and development opportunities to help employees acquire new skills and adapt to changing market conditions.\\n3. **Job Security Assurance**: Provide assurance on job security wherever possible, and offer support for employees who may be impacted by restructuring or downsizing.\\n\\n**Medium Priority**\\n\\n1. **Employee Engagement Initiatives**: Implement employee engagement initiatives to boost morale and motivation, such as recognition programs, team-building activities, and feedback mechanisms.\\n2. **Mentorship Programs**: Establish mentorship programs to pair employees with experienced colleagues who can provide guidance and support in navigating market changes.\\n3. **Performance Management**: Review and update performance management systems to ensure they are aligned with the organization's new strategy and goals.\\n\\n**Low Priority**\\n\\n1. **Employee Benefits Review**: Review employee benefits to ensure they are still relevant and competitive in the changing market, and make adjustments as necessary.\\n2. **Social Responsibility Initiatives**: Consider implementing social responsibility initiatives that demonstrate the organization's commitment to its employees and the community, such as volunteer programs or charitable donations.\\n\\n### Conclusion\\nBy understanding the impacts of market changes on employees and taking proactive steps to address their concerns, organizations can mitigate the negative effects and create a more positive and productive work environment. By prioritizing clear communication, training and development, and job security assurance, organizations can help employees navigate market changes and thrive in a rapidly changing business landscape.\",\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '86d5dbc8-4118-47c3-a3ba-70fbf442a8e7',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 395362, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': \"**Employee Stakeholder Group Analysis**\\n\\n### Introduction\\nThe employee stakeholder group is crucial to the success of any organization. Market changes can have a significant impact on employees, affecting their job security, skill requirements, and overall direction. This analysis will outline the specific impacts of market changes on employees and provide recommended actions to mitigate these effects.\\n\\n### Impacts of Market Changes on Employees\\n\\n1. **Job Security Worries**: Market changes can lead to restructuring, downsizing, or changes in job roles, causing employees to worry about their job security.\\n2. **Need for New Skills**: Market changes often require employees to acquire new skills to remain relevant, which can be a challenge for those who are not adaptable or have limited training opportunities.\\n3. **Lack of Clear Direction**: Employees may feel uncertain about the organization's future and their role in it, leading to a lack of clear direction and motivation.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Communicate Clearly and Transparently**: Provide regular updates on the organization's strategy and plans to address market changes, ensuring employees understand the reasons behind any changes and how they will be affected.\\n2. **Training and Development Programs**: Offer training and development opportunities to help employees acquire new skills and adapt to changing market conditions.\\n3. **Job Security Assurance**: Provide assurance on job security wherever possible, and offer support for employees who may be impacted by restructuring or downsizing.\\n\\n**Medium Priority**\\n\\n1. **Employee Engagement Initiatives**: Implement employee engagement initiatives to boost morale and motivation, such as recognition programs, team-building activities, and feedback mechanisms.\\n2. **Mentorship Programs**: Establish mentorship programs to pair employees with experienced colleagues who can provide guidance and support in navigating market changes.\\n3. **Performance Management**: Review and update performance management systems to ensure they are aligned with the organization's new strategy and goals.\\n\\n**Low Priority**\\n\\n1. **Employee Benefits Review**: Review employee benefits to ensure they are still relevant and competitive in the changing market, and make adjustments as necessary.\\n2. **Social Responsibility Initiatives**: Consider implementing social responsibility initiatives that demonstrate the organization's commitment to its employees and the community, such as volunteer programs or charitable donations.\\n\\n### Conclusion\\nBy understanding the impacts of market changes on employees and taking proactive steps to address their concerns, organizations can mitigate the negative effects and create a more positive and productive work environment. By prioritizing clear communication, training and development, and job security assurance, organizations can help employees navigate market changes and thrive in a rapidly changing business landscape.\",\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '75682062-6d12-4d26-ba29-71d206a4b79f',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '37458d30-eb1f-437c-8626-55e0771a01e2',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 419859, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 406072, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '37458d30-eb1f-437c-8626-55e0771a01e2',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 432691, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'86d5dbc8-4118-47c3-a3ba-70fbf442a8e7'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_1b1bf719-ef3a-4da9-934f-4f4d78c0e2f0'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m376994\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Employees:\\n - Job security worries\\n - Need new skills\\n - Want clear direction'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"**Employee Stakeholder Group Analysis**\\n\\n### Introduction\\nThe employee stakeholder group is crucial to the success of any organization. Market changes can have a significant impact on employees, affecting their job security, skill requirements, and overall direction. This analysis will outline the specific impacts of market changes on employees and provide recommended actions to mitigate these effects.\\n\\n### Impacts of Market Changes on Employees\\n\\n1. **Job Security Worries**: Market changes can lead to restructuring, downsizing, or changes in job roles, causing employees to worry about their job security.\\n2. **Need for New Skills**: Market changes often require employees to acquire new skills to remain relevant, which can be a challenge for those who are not adaptable or have limited training opportunities.\\n3. **Lack of Clear Direction**: Employees may feel uncertain about the organization's future and their role in it, leading to a lack of clear direction and motivation.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Communicate Clearly and Transparently**: Provide regular updates on the organization's strategy and plans to address market changes, ensuring employees understand the reasons behind any changes and how they will be affected.\\n2. **Training and Development Programs**: Offer training and development opportunities to help employees acquire new skills and adapt to changing market conditions.\\n3. **Job Security Assurance**: Provide assurance on job security wherever possible, and offer support for employees who may be impacted by restructuring or downsizing.\\n\\n**Medium Priority**\\n\\n1. **Employee Engagement Initiatives**: Implement employee engagement initiatives to boost morale and motivation, such as recognition programs, team-building activities, and feedback mechanisms.\\n2. **Mentorship Programs**: Establish mentorship programs to pair employees with experienced colleagues who can provide guidance and support in navigating market changes.\\n3. **Performance Management**: Review and update performance management systems to ensure they are aligned with the organization's new strategy and goals.\\n\\n**Low Priority**\\n\\n1. **Employee Benefits Review**: Review employee benefits to ensure they are still relevant and competitive in the changing market, and make adjustments as necessary.\\n2. **Social Responsibility Initiatives**: Consider implementing social responsibility initiatives that demonstrate the organization's commitment to its employees and the community, such as volunteer programs or charitable donations.\\n\\n### Conclusion\\nBy understanding the impacts of market changes on employees and taking proactive steps to address their concerns, organizations can mitigate the negative effects and create a more positive and productive work environment. By prioritizing clear communication, training and development, and job security assurance, organizations can help employees navigate market changes and thrive in a rapidly changing business landscape.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'86d5dbc8-4118-47c3-a3ba-70fbf442a8e7'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m395362\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"**Employee Stakeholder Group Analysis**\\n\\n### Introduction\\nThe employee stakeholder group is crucial to the success of any organization. Market changes can have a significant impact on employees, affecting their job security, skill requirements, and overall direction. This analysis will outline the specific impacts of market changes on employees and provide recommended actions to mitigate these effects.\\n\\n### Impacts of Market Changes on Employees\\n\\n1. **Job Security Worries**: Market changes can lead to restructuring, downsizing, or changes in job roles, causing employees to worry about their job security.\\n2. **Need for New Skills**: Market changes often require employees to acquire new skills to remain relevant, which can be a challenge for those who are not adaptable or have limited training opportunities.\\n3. **Lack of Clear Direction**: Employees may feel uncertain about the organization's future and their role in it, leading to a lack of clear direction and motivation.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Communicate Clearly and Transparently**: Provide regular updates on the organization's strategy and plans to address market changes, ensuring employees understand the reasons behind any changes and how they will be affected.\\n2. **Training and Development Programs**: Offer training and development opportunities to help employees acquire new skills and adapt to changing market conditions.\\n3. **Job Security Assurance**: Provide assurance on job security wherever possible, and offer support for employees who may be impacted by restructuring or downsizing.\\n\\n**Medium Priority**\\n\\n1. **Employee Engagement Initiatives**: Implement employee engagement initiatives to boost morale and motivation, such as recognition programs, team-building activities, and feedback mechanisms.\\n2. **Mentorship Programs**: Establish mentorship programs to pair employees with experienced colleagues who can provide guidance and support in navigating market changes.\\n3. **Performance Management**: Review and update performance management systems to ensure they are aligned with the organization's new strategy and goals.\\n\\n**Low Priority**\\n\\n1. **Employee Benefits Review**: Review employee benefits to ensure they are still relevant and competitive in the changing market, and make adjustments as necessary.\\n2. **Social Responsibility Initiatives**: Consider implementing social responsibility initiatives that demonstrate the organization's commitment to its employees and the community, such as volunteer programs or charitable donations.\\n\\n### Conclusion\\nBy understanding the impacts of market changes on employees and taking proactive steps to address their concerns, organizations can mitigate the negative effects and create a more positive and productive work environment. By prioritizing clear communication, training and development, and job security assurance, organizations can help employees navigate market changes and thrive in a rapidly changing business landscape.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'75682062-6d12-4d26-ba29-71d206a4b79f'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'37458d30-eb1f-437c-8626-55e0771a01e2'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m419859\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m406072\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[32m'turn_id'\u001b[0m: \u001b[32m'37458d30-eb1f-437c-8626-55e0771a01e2'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m432691\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Worker Agent 3: =========\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '9aa0dd1b-363e-49c0-b49f-50a8b88c6094',\n", + "β 'session_name': 'worker_agent_1116d05d-41b4-4cae-9d8f-b2bcbe68033b',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 387172),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Investors:\\n - Expect growth\\n - Want cost control\\n - Risk concerns',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '**Investor Impact Analysis**\\n==========================\\n\\n### Introduction\\n\\nMarket changes can have a significant impact on investors, who have certain expectations and concerns. This analysis will outline the potential effects of market changes on investors and provide recommended actions to mitigate risks and capitalize on opportunities.\\n\\n### Expected Impacts\\n\\n1. **Growth Expectations**: Market changes can affect the growth prospects of investments. For example:\\n\\t* Economic downturns can reduce revenue and profitability, impacting growth.\\n\\t* Industry disruptions can create new opportunities for growth, but also increase competition.\\n2. **Cost Control**: Investors are concerned about cost control, as market changes can impact operational expenses. For instance:\\n\\t* Increased regulatory requirements can lead to higher compliance costs.\\n\\t* Supply chain disruptions can result in higher procurement costs.\\n3. **Risk Concerns**: Market changes can introduce new risks or exacerbate existing ones, affecting investor confidence. Examples include:\\n\\t* Market volatility can increase the risk of investment losses.\\n\\t* Cybersecurity threats can compromise sensitive investor data.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Diversification**: Encourage investors to diversify their portfolios to minimize risk and maximize returns.\\n2. **Regular Portfolio Reviews**: Conduct regular reviews of investment portfolios to ensure they remain aligned with investor goals and risk tolerance.\\n3. **Risk Management**: Implement effective risk management strategies, such as hedging or insurance, to mitigate potential losses.\\n\\n**Medium Priority**\\n\\n1. **Cost Optimization**: Help investors optimize costs by identifying areas of inefficiency and implementing cost-saving measures.\\n2. **Regulatory Compliance**: Ensure investors are aware of and compliant with changing regulatory requirements to avoid potential fines or penalties.\\n3. **Investor Education**: Provide investors with educational resources and updates on market trends and changes to help them make informed decisions.\\n\\n**Low Priority**\\n\\n1. **Investment in Emerging Technologies**: Consider investing in emerging technologies, such as blockchain or artificial intelligence, to stay ahead of the curve and capitalize on potential growth opportunities.\\n2. **Sustainable Investing**: Encourage investors to consider sustainable investing options, which can provide long-term growth opportunities while minimizing environmental and social risks.\\n\\n### Conclusion\\n\\nMarket changes can have a significant impact on investors, affecting their growth expectations, cost control, and risk concerns. By understanding these impacts and taking recommended actions, investors can mitigate risks, capitalize on opportunities, and achieve their investment goals. Prioritizing diversification, regular portfolio reviews, and risk management can help investors navigate market changes with confidence.',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '9aa0dd1b-363e-49c0-b49f-50a8b88c6094',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 398507, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '**Investor Impact Analysis**\\n==========================\\n\\n### Introduction\\n\\nMarket changes can have a significant impact on investors, who have certain expectations and concerns. This analysis will outline the potential effects of market changes on investors and provide recommended actions to mitigate risks and capitalize on opportunities.\\n\\n### Expected Impacts\\n\\n1. **Growth Expectations**: Market changes can affect the growth prospects of investments. For example:\\n\\t* Economic downturns can reduce revenue and profitability, impacting growth.\\n\\t* Industry disruptions can create new opportunities for growth, but also increase competition.\\n2. **Cost Control**: Investors are concerned about cost control, as market changes can impact operational expenses. For instance:\\n\\t* Increased regulatory requirements can lead to higher compliance costs.\\n\\t* Supply chain disruptions can result in higher procurement costs.\\n3. **Risk Concerns**: Market changes can introduce new risks or exacerbate existing ones, affecting investor confidence. Examples include:\\n\\t* Market volatility can increase the risk of investment losses.\\n\\t* Cybersecurity threats can compromise sensitive investor data.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Diversification**: Encourage investors to diversify their portfolios to minimize risk and maximize returns.\\n2. **Regular Portfolio Reviews**: Conduct regular reviews of investment portfolios to ensure they remain aligned with investor goals and risk tolerance.\\n3. **Risk Management**: Implement effective risk management strategies, such as hedging or insurance, to mitigate potential losses.\\n\\n**Medium Priority**\\n\\n1. **Cost Optimization**: Help investors optimize costs by identifying areas of inefficiency and implementing cost-saving measures.\\n2. **Regulatory Compliance**: Ensure investors are aware of and compliant with changing regulatory requirements to avoid potential fines or penalties.\\n3. **Investor Education**: Provide investors with educational resources and updates on market trends and changes to help them make informed decisions.\\n\\n**Low Priority**\\n\\n1. **Investment in Emerging Technologies**: Consider investing in emerging technologies, such as blockchain or artificial intelligence, to stay ahead of the curve and capitalize on potential growth opportunities.\\n2. **Sustainable Investing**: Encourage investors to consider sustainable investing options, which can provide long-term growth opportunities while minimizing environmental and social risks.\\n\\n### Conclusion\\n\\nMarket changes can have a significant impact on investors, affecting their growth expectations, cost control, and risk concerns. By understanding these impacts and taking recommended actions, investors can mitigate risks, capitalize on opportunities, and achieve their investment goals. Prioritizing diversification, regular portfolio reviews, and risk management can help investors navigate market changes with confidence.',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '80af1566-d3f0-4342-8625-17f7a811f8ed',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '31c3ba6c-7e56-4c61-a2b8-35d4119a54c9',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 88378, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 408838, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '31c3ba6c-7e56-4c61-a2b8-35d4119a54c9',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 104580, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'9aa0dd1b-363e-49c0-b49f-50a8b88c6094'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_1116d05d-41b4-4cae-9d8f-b2bcbe68033b'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m387172\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Investors:\\n - Expect growth\\n - Want cost control\\n - Risk concerns'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'**Investor Impact Analysis**\\\u001b[0m\u001b[32mn\u001b[0m\u001b[32m==========================\\n\\n### Introduction\\n\\nMarket changes can have a significant impact on investors, who have certain expectations and concerns. This analysis will outline the potential effects of market changes on investors and provide recommended actions to mitigate risks and capitalize on opportunities.\\n\\n### Expected Impacts\\n\\n1. **Growth Expectations**: Market changes can affect the growth prospects of investments. For example:\\n\\t* Economic downturns can reduce revenue and profitability, impacting growth.\\n\\t* Industry disruptions can create new opportunities for growth, but also increase competition.\\n2. **Cost Control**: Investors are concerned about cost control, as market changes can impact operational expenses. For instance:\\n\\t* Increased regulatory requirements can lead to higher compliance costs.\\n\\t* Supply chain disruptions can result in higher procurement costs.\\n3. **Risk Concerns**: Market changes can introduce new risks or exacerbate existing ones, affecting investor confidence. Examples include:\\n\\t* Market volatility can increase the risk of investment losses.\\n\\t* Cybersecurity threats can compromise sensitive investor data.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Diversification**: Encourage investors to diversify their portfolios to minimize risk and maximize returns.\\n2. **Regular Portfolio Reviews**: Conduct regular reviews of investment portfolios to ensure they remain aligned with investor goals and risk tolerance.\\n3. **Risk Management**: Implement effective risk management strategies, such as hedging or insurance, to mitigate potential losses.\\n\\n**Medium Priority**\\n\\n1. **Cost Optimization**: Help investors optimize costs by identifying areas of inefficiency and implementing cost-saving measures.\\n2. **Regulatory Compliance**: Ensure investors are aware of and compliant with changing regulatory requirements to avoid potential fines or penalties.\\n3. **Investor Education**: Provide investors with educational resources and updates on market trends and changes to help them make informed decisions.\\n\\n**Low Priority**\\n\\n1. **Investment in Emerging Technologies**: Consider investing in emerging technologies, such as blockchain or artificial intelligence, to stay ahead of the curve and capitalize on potential growth opportunities.\\n2. **Sustainable Investing**: Encourage investors to consider sustainable investing options, which can provide long-term growth opportunities while minimizing environmental and social risks.\\n\\n### Conclusion\\n\\nMarket changes can have a significant impact on investors, affecting their growth expectations, cost control, and risk concerns. By understanding these impacts and taking recommended actions, investors can mitigate risks, capitalize on opportunities, and achieve their investment goals. Prioritizing diversification, regular portfolio reviews, and risk management can help investors navigate market changes with confidence.'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'9aa0dd1b-363e-49c0-b49f-50a8b88c6094'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m398507\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'**Investor Impact Analysis**\\\u001b[0m\u001b[32mn\u001b[0m\u001b[32m==========================\\n\\n### Introduction\\n\\nMarket changes can have a significant impact on investors, who have certain expectations and concerns. This analysis will outline the potential effects of market changes on investors and provide recommended actions to mitigate risks and capitalize on opportunities.\\n\\n### Expected Impacts\\n\\n1. **Growth Expectations**: Market changes can affect the growth prospects of investments. For example:\\n\\t* Economic downturns can reduce revenue and profitability, impacting growth.\\n\\t* Industry disruptions can create new opportunities for growth, but also increase competition.\\n2. **Cost Control**: Investors are concerned about cost control, as market changes can impact operational expenses. For instance:\\n\\t* Increased regulatory requirements can lead to higher compliance costs.\\n\\t* Supply chain disruptions can result in higher procurement costs.\\n3. **Risk Concerns**: Market changes can introduce new risks or exacerbate existing ones, affecting investor confidence. Examples include:\\n\\t* Market volatility can increase the risk of investment losses.\\n\\t* Cybersecurity threats can compromise sensitive investor data.\\n\\n### Recommended Actions\\n\\n**High Priority**\\n\\n1. **Diversification**: Encourage investors to diversify their portfolios to minimize risk and maximize returns.\\n2. **Regular Portfolio Reviews**: Conduct regular reviews of investment portfolios to ensure they remain aligned with investor goals and risk tolerance.\\n3. **Risk Management**: Implement effective risk management strategies, such as hedging or insurance, to mitigate potential losses.\\n\\n**Medium Priority**\\n\\n1. **Cost Optimization**: Help investors optimize costs by identifying areas of inefficiency and implementing cost-saving measures.\\n2. **Regulatory Compliance**: Ensure investors are aware of and compliant with changing regulatory requirements to avoid potential fines or penalties.\\n3. **Investor Education**: Provide investors with educational resources and updates on market trends and changes to help them make informed decisions.\\n\\n**Low Priority**\\n\\n1. **Investment in Emerging Technologies**: Consider investing in emerging technologies, such as blockchain or artificial intelligence, to stay ahead of the curve and capitalize on potential growth opportunities.\\n2. **Sustainable Investing**: Encourage investors to consider sustainable investing options, which can provide long-term growth opportunities while minimizing environmental and social risks.\\n\\n### Conclusion\\n\\nMarket changes can have a significant impact on investors, affecting their growth expectations, cost control, and risk concerns. By understanding these impacts and taking recommended actions, investors can mitigate risks, capitalize on opportunities, and achieve their investment goals. Prioritizing diversification, regular portfolio reviews, and risk management can help investors navigate market changes with confidence.'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'80af1566-d3f0-4342-8625-17f7a811f8ed'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'31c3ba6c-7e56-4c61-a2b8-35d4119a54c9'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m88378\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m408838\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[32m'turn_id'\u001b[0m: \u001b[32m'31c3ba6c-7e56-4c61-a2b8-35d4119a54c9'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m104580\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "========= Worker Agent 4: =========\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '24a1d443-5fa2-435f-960b-314790d8600e',\n", + "β 'session_name': 'worker_agent_f53a1b9b-a979-4c5e-999e-e4dcaf67411f',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 397578),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Suppliers:\\n - Capacity constraints\\n - Price pressures\\n - Tech transitions',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '**Market Change Impact Analysis: Suppliers**\\n=============================================\\n\\n### Introduction\\n\\nThe supplier stakeholder group is crucial to the success of any organization, providing essential goods and services that enable operations. Market changes can significantly impact suppliers, and it is essential to analyze these impacts to develop strategies that mitigate risks and capitalize on opportunities.\\n\\n### Impacts of Market Changes on Suppliers\\n\\n#### **Capacity Constraints**\\n\\n* **Impact:** Suppliers may face challenges in meeting demand due to limited production capacity, leading to delays, stockouts, or reduced product quality.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in capacity expansion**: Suppliers should consider investing in new equipment, technology, or hiring additional staff to increase production capacity.\\n\\t2. **Implement lean manufacturing practices**: Suppliers can optimize production processes to reduce waste, improve efficiency, and increase output.\\n\\t3. **Develop strategic partnerships**: Suppliers can form partnerships with other companies to share resources, expertise, and capacity to meet demand.\\n\\n#### **Price Pressures**\\n\\n* **Impact:** Suppliers may face downward pressure on prices, reducing profit margins and making it challenging to maintain quality and invest in research and development.\\n* **Priority:** Medium\\n* **Recommended Actions:**\\n\\t1. **Cost reduction initiatives**: Suppliers should identify areas to reduce costs, such as streamlining operations, renegotiating contracts with their own suppliers, or implementing energy-efficient practices.\\n\\t2. **Value-added services**: Suppliers can offer additional services, such as customization, technical support, or logistics management, to differentiate themselves and command premium prices.\\n\\t3. **Develop strategic pricing strategies**: Suppliers can use data analytics and market research to develop pricing strategies that balance profitability with customer demand.\\n\\n#### **Tech Transitions**\\n\\n* **Impact:** Suppliers may need to invest in new technologies, such as digitalization, automation, or sustainability solutions, to remain competitive and meet changing customer demands.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in research and development**: Suppliers should allocate resources to develop new technologies, products, or services that meet emerging customer needs.\\n\\t2. **Partner with technology providers**: Suppliers can collaborate with technology companies to access new solutions, expertise, and funding.\\n\\t3. **Develop a digital transformation strategy**: Suppliers should create a roadmap for digitalization, including investments in data analytics, artificial intelligence, and cybersecurity.\\n\\n### Conclusion\\n\\nSuppliers face significant challenges due to market changes, including capacity constraints, price pressures, and tech transitions. By understanding these impacts and taking proactive measures, suppliers',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '24a1d443-5fa2-435f-960b-314790d8600e',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 402483, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '**Market Change Impact Analysis: Suppliers**\\n=============================================\\n\\n### Introduction\\n\\nThe supplier stakeholder group is crucial to the success of any organization, providing essential goods and services that enable operations. Market changes can significantly impact suppliers, and it is essential to analyze these impacts to develop strategies that mitigate risks and capitalize on opportunities.\\n\\n### Impacts of Market Changes on Suppliers\\n\\n#### **Capacity Constraints**\\n\\n* **Impact:** Suppliers may face challenges in meeting demand due to limited production capacity, leading to delays, stockouts, or reduced product quality.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in capacity expansion**: Suppliers should consider investing in new equipment, technology, or hiring additional staff to increase production capacity.\\n\\t2. **Implement lean manufacturing practices**: Suppliers can optimize production processes to reduce waste, improve efficiency, and increase output.\\n\\t3. **Develop strategic partnerships**: Suppliers can form partnerships with other companies to share resources, expertise, and capacity to meet demand.\\n\\n#### **Price Pressures**\\n\\n* **Impact:** Suppliers may face downward pressure on prices, reducing profit margins and making it challenging to maintain quality and invest in research and development.\\n* **Priority:** Medium\\n* **Recommended Actions:**\\n\\t1. **Cost reduction initiatives**: Suppliers should identify areas to reduce costs, such as streamlining operations, renegotiating contracts with their own suppliers, or implementing energy-efficient practices.\\n\\t2. **Value-added services**: Suppliers can offer additional services, such as customization, technical support, or logistics management, to differentiate themselves and command premium prices.\\n\\t3. **Develop strategic pricing strategies**: Suppliers can use data analytics and market research to develop pricing strategies that balance profitability with customer demand.\\n\\n#### **Tech Transitions**\\n\\n* **Impact:** Suppliers may need to invest in new technologies, such as digitalization, automation, or sustainability solutions, to remain competitive and meet changing customer demands.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in research and development**: Suppliers should allocate resources to develop new technologies, products, or services that meet emerging customer needs.\\n\\t2. **Partner with technology providers**: Suppliers can collaborate with technology companies to access new solutions, expertise, and funding.\\n\\t3. **Develop a digital transformation strategy**: Suppliers should create a roadmap for digitalization, including investments in data analytics, artificial intelligence, and cybersecurity.\\n\\n### Conclusion\\n\\nSuppliers face significant challenges due to market changes, including capacity constraints, price pressures, and tech transitions. By understanding these impacts and taking proactive measures, suppliers',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '25c84fca-18da-4371-9d92-f35e286fbdce',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '3117bed6-b3b5-40e1-a215-4f4950895019',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 569478, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 16, 2, 21, 413067, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '3117bed6-b3b5-40e1-a215-4f4950895019',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 16, 2, 28, 582120, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'24a1d443-5fa2-435f-960b-314790d8600e'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_f53a1b9b-a979-4c5e-999e-e4dcaf67411f'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m397578\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Suppliers:\\n - Capacity constraints\\n - Price pressures\\n - Tech transitions'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'**Market Change Impact Analysis: Suppliers**\\\u001b[0m\u001b[32mn\u001b[0m\u001b[32m=============================================\\n\\n### Introduction\\n\\nThe supplier stakeholder group is crucial to the success of any organization, providing essential goods and services that enable operations. Market changes can significantly impact suppliers, and it is essential to analyze these impacts to develop strategies that mitigate risks and capitalize on opportunities.\\n\\n### Impacts of Market Changes on Suppliers\\n\\n#### **Capacity Constraints**\\n\\n* **Impact:** Suppliers may face challenges in meeting demand due to limited production capacity, leading to delays, stockouts, or reduced product quality.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in capacity expansion**: Suppliers should consider investing in new equipment, technology, or hiring additional staff to increase production capacity.\\n\\t2. **Implement lean manufacturing practices**: Suppliers can optimize production processes to reduce waste, improve efficiency, and increase output.\\n\\t3. **Develop strategic partnerships**: Suppliers can form partnerships with other companies to share resources, expertise, and capacity to meet demand.\\n\\n#### **Price Pressures**\\n\\n* **Impact:** Suppliers may face downward pressure on prices, reducing profit margins and making it challenging to maintain quality and invest in research and development.\\n* **Priority:** Medium\\n* **Recommended Actions:**\\n\\t1. **Cost reduction initiatives**: Suppliers should identify areas to reduce costs, such as streamlining operations, renegotiating contracts with their own suppliers, or implementing energy-efficient practices.\\n\\t2. **Value-added services**: Suppliers can offer additional services, such as customization, technical support, or logistics management, to differentiate themselves and command premium prices.\\n\\t3. **Develop strategic pricing strategies**: Suppliers can use data analytics and market research to develop pricing strategies that balance profitability with customer demand.\\n\\n#### **Tech Transitions**\\n\\n* **Impact:** Suppliers may need to invest in new technologies, such as digitalization, automation, or sustainability solutions, to remain competitive and meet changing customer demands.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in research and development**: Suppliers should allocate resources to develop new technologies, products, or services that meet emerging customer needs.\\n\\t2. **Partner with technology providers**: Suppliers can collaborate with technology companies to access new solutions, expertise, and funding.\\n\\t3. **Develop a digital transformation strategy**: Suppliers should create a roadmap for digitalization, including investments in data analytics, artificial intelligence, and cybersecurity.\\n\\n### Conclusion\\n\\nSuppliers face significant challenges due to market changes, including capacity constraints, price pressures, and tech transitions. By understanding these impacts and taking proactive measures, suppliers'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'24a1d443-5fa2-435f-960b-314790d8600e'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m402483\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'**Market Change Impact Analysis: Suppliers**\\\u001b[0m\u001b[32mn\u001b[0m\u001b[32m=============================================\\n\\n### Introduction\\n\\nThe supplier stakeholder group is crucial to the success of any organization, providing essential goods and services that enable operations. Market changes can significantly impact suppliers, and it is essential to analyze these impacts to develop strategies that mitigate risks and capitalize on opportunities.\\n\\n### Impacts of Market Changes on Suppliers\\n\\n#### **Capacity Constraints**\\n\\n* **Impact:** Suppliers may face challenges in meeting demand due to limited production capacity, leading to delays, stockouts, or reduced product quality.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in capacity expansion**: Suppliers should consider investing in new equipment, technology, or hiring additional staff to increase production capacity.\\n\\t2. **Implement lean manufacturing practices**: Suppliers can optimize production processes to reduce waste, improve efficiency, and increase output.\\n\\t3. **Develop strategic partnerships**: Suppliers can form partnerships with other companies to share resources, expertise, and capacity to meet demand.\\n\\n#### **Price Pressures**\\n\\n* **Impact:** Suppliers may face downward pressure on prices, reducing profit margins and making it challenging to maintain quality and invest in research and development.\\n* **Priority:** Medium\\n* **Recommended Actions:**\\n\\t1. **Cost reduction initiatives**: Suppliers should identify areas to reduce costs, such as streamlining operations, renegotiating contracts with their own suppliers, or implementing energy-efficient practices.\\n\\t2. **Value-added services**: Suppliers can offer additional services, such as customization, technical support, or logistics management, to differentiate themselves and command premium prices.\\n\\t3. **Develop strategic pricing strategies**: Suppliers can use data analytics and market research to develop pricing strategies that balance profitability with customer demand.\\n\\n#### **Tech Transitions**\\n\\n* **Impact:** Suppliers may need to invest in new technologies, such as digitalization, automation, or sustainability solutions, to remain competitive and meet changing customer demands.\\n* **Priority:** High\\n* **Recommended Actions:**\\n\\t1. **Invest in research and development**: Suppliers should allocate resources to develop new technologies, products, or services that meet emerging customer needs.\\n\\t2. **Partner with technology providers**: Suppliers can collaborate with technology companies to access new solutions, expertise, and funding.\\n\\t3. **Develop a digital transformation strategy**: Suppliers should create a roadmap for digitalization, including investments in data analytics, artificial intelligence, and cybersecurity.\\n\\n### Conclusion\\n\\nSuppliers face significant challenges due to market changes, including capacity constraints, price pressures, and tech transitions. By understanding these impacts and taking proactive measures, suppliers'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'25c84fca-18da-4371-9d92-f35e286fbdce'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'3117bed6-b3b5-40e1-a215-4f4950895019'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m569478\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m21\u001b[0m, \u001b[1;36m413067\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[32m'turn_id'\u001b[0m: \u001b[32m'3117bed6-b3b5-40e1-a215-4f4950895019'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m16\u001b[0m, \u001b[1;36m2\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m582120\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[32m'output_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" + } + ], + "source": [ + "for i, result in enumerate(results):\n", + " print(f\"========= Worker Agent {i+1}: =========\")\n", + " session_response = client.agents.session.retrieve(session_id=result[\"worker_agent\"].session_id, agent_id=result[\"worker_agent\"].agent_id)\n", + " pprint(session_response.to_dict())\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2. Evaluator-Optimizer Workflow\n", + "\n", + "In the evaluator-optimizer workflow, one LLM call generates a response while another provider evaluation and feedback in a loop. \n", + "\n", + "\n", + "\n", + "**Example: Code Generation**\n", + "\n", + "We'll showcase how to use the evaluator-optimizer workflow to generate a code implementation. \n", + "- **Generator agent** generates a code implementation\n", + "- **Evaluator agent** evaluates the code implementation\n", + "- Loop until the evaluator returns \"PASS\"" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "metadata": {}, + "outputs": [], + "source": [ + "class GeneratorOutputSchema(BaseModel):\n", + " thoughts: str\n", + " response: str\n", + "\n", + "generator_agent_config = {\n", + " **base_agent_config,\n", + " \"instructions\": \"\"\"Your goal is to complete the task based on
{\n", + "β 'session_id': 'a2a3b149-0bf3-40a2-86d4-facf3f162014',\n", + "β 'session_name': 'generator_agent_e334542d-5c66-4136-94ce-f751c64eb9a5',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 35, 49, 860141),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': '\\nImplement a Stack with:\\n1. push(x)\\n2. pop()\\n3. getMin()\\nAll operations should be O(1).\\n',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '{\\n\"thoughts\": \"To implement a Stack with push, pop, and getMin operations all in O(1) time complexity, we need to use two stacks. One stack will be used to store the actual elements (main stack), and the other stack will be used to keep track of the minimum elements seen so far (min stack). When an element is pushed onto the main stack, we check if the min stack is empty or if the top element of the min stack is greater than or equal to the element being pushed. If either condition is true, we push the element onto the min stack as well. When popping an element from the main stack, we check if the top element of the main stack is equal to the top element of the min stack. If they are equal, we pop the element from the min stack as well. The getMin operation simply returns the top element of the min stack.\",\\n\"response\": \"```python\\\\nclass MinStack:\\\\n def __init__(self):\\\\n self.main_stack = []\\\\n self.min_stack = []\\\\n\\\\n def push(self, x: int) -> None:\\\\n self.main_stack.append(x)\\\\n if not self.min_stack or x <= self.min_stack[-1]:\\\\n self.min_stack.append(x)\\\\n\\\\n def pop(self) -> None:\\\\n if self.main_stack:\\\\n if self.main_stack[-1] == self.min_stack[-1]:\\\\n self.min_stack.pop()\\\\n self.main_stack.pop()\\\\n\\\\n def getMin(self) -> int:\\\\n return self.min_stack[-1]\\\\n```\"\\n}',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': 'a2a3b149-0bf3-40a2-86d4-facf3f162014',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 35, 51, 801415, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '{\\n\"thoughts\": \"To implement a Stack with push, pop, and getMin operations all in O(1) time complexity, we need to use two stacks. One stack will be used to store the actual elements (main stack), and the other stack will be used to keep track of the minimum elements seen so far (min stack). When an element is pushed onto the main stack, we check if the min stack is empty or if the top element of the min stack is greater than or equal to the element being pushed. If either condition is true, we push the element onto the min stack as well. When popping an element from the main stack, we check if the top element of the main stack is equal to the top element of the min stack. If they are equal, we pop the element from the min stack as well. The getMin operation simply returns the top element of the min stack.\",\\n\"response\": \"```python\\\\nclass MinStack:\\\\n def __init__(self):\\\\n self.main_stack = []\\\\n self.min_stack = []\\\\n\\\\n def push(self, x: int) -> None:\\\\n self.main_stack.append(x)\\\\n if not self.min_stack or x <= self.min_stack[-1]:\\\\n self.min_stack.append(x)\\\\n\\\\n def pop(self) -> None:\\\\n if self.main_stack:\\\\n if self.main_stack[-1] == self.min_stack[-1]:\\\\n self.min_stack.pop()\\\\n self.main_stack.pop()\\\\n\\\\n def getMin(self) -> int:\\\\n return self.min_stack[-1]\\\\n```\"\\n}',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '4c4e54a6-c3e3-4d30-8da7-10003c59bfc7',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '73ece739-af65-4c0b-97c9-d2fbb0b84234',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 35, 55, 346289, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 35, 51, 812800, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '73ece739-af65-4c0b-97c9-d2fbb0b84234',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 35, 55, 364553, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'a2a3b149-0bf3-40a2-86d4-facf3f162014'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'generator_agent_e334542d-5c66-4136-94ce-f751c64eb9a5'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m49\u001b[0m, \u001b[1;36m860141\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\\nImplement a Stack with:\\n1. push\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n2. pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n3. getMin\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\nAll operations should be O\u001b[0m\u001b[32m(\u001b[0m\u001b[32m1\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"thoughts\": \"To implement a Stack with push, pop, and getMin operations all in O\u001b[0m\u001b[32m(\u001b[0m\u001b[32m1\u001b[0m\u001b[32m)\u001b[0m\u001b[32m time complexity, we need to use two stacks. One stack will be used to store the actual elements \u001b[0m\u001b[32m(\u001b[0m\u001b[32mmain stack\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, and the other stack will be used to keep track of the minimum elements seen so far \u001b[0m\u001b[32m(\u001b[0m\u001b[32mmin stack\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. When an element is pushed onto the main stack, we check if the min stack is empty or if the top element of the min stack is greater than or equal to the element being pushed. If either condition is true, we push the element onto the min stack as well. When popping an element from the main stack, we check if the top element of the main stack is equal to the top element of the min stack. If they are equal, we pop the element from the min stack as well. The getMin operation simply returns the top element of the min stack.\",\\n\"response\": \"```python\\\\nclass MinStack:\\\\n def __init__\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m:\\\\n self.main_stack = \u001b[0m\u001b[32m[\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\\\n self.min_stack = \u001b[0m\u001b[32m[\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\\\n\\\\n def push\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself, x: int\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> None:\\\\n self.main_stack.append\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n if not self.min_stack or x \u001b[0m\u001b[32m<\u001b[0m\u001b[32m= self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m:\\\\n self.min_stack.append\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n\\\\n def pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> None:\\\\n if self.main_stack:\\\\n if self.main_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m == self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m:\\\\n self.min_stack.pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n self.main_stack.pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n\\\\n def getMin\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> int:\\\\n return self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\\\n```\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m\u001b[39m,\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m\u001b[39m: \u001b[0m\u001b[32m'assistant'\u001b[0m\u001b[39m,\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m\u001b[39m: \u001b[0m\u001b[32m'end_of_turn'\u001b[0m\u001b[39m,\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_calls'\u001b[0m\u001b[39m: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[1;39m}\u001b[0m\u001b[39m,\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'session_id'\u001b[0m\u001b[39m: \u001b[0m\u001b[32m'a2a3b149-0bf3-40a2-86d4-facf3f162014'\u001b[0m\u001b[39m,\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m\u001b[39m: \u001b[0m\u001b[1;35mdatetime.datetime\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m3\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m3\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m35\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m51\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m801415\u001b[0m\u001b[39m, \u001b[0m\u001b[33mtzinfo\u001b[0m\u001b[39m=\u001b[0m\u001b[1;35mdatetime\u001b[0m\u001b[1;35m.timezone\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;35mdatetime.timedelta\u001b[0m\u001b[1;39m(\u001b[0m\u001b[33mdays\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m-1\u001b[0m\u001b[39m, \u001b[0m\u001b[33mseconds\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m57600\u001b[0m\u001b[1;39m)\u001b[0m\u001b[1;39m)\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m,\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'steps'\u001b[0m\u001b[39m: \u001b[0m\u001b[1;39m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1;39m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m\u001b[39m: \u001b[0m\u001b[1;39m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m\u001b[39m: \u001b[0m\u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"thoughts\": \"To implement a Stack with push, pop, and getMin operations all in O\u001b[0m\u001b[32m(\u001b[0m\u001b[32m1\u001b[0m\u001b[32m)\u001b[0m\u001b[32m time complexity, we need to use two stacks. One stack will be used to store the actual elements \u001b[0m\u001b[32m(\u001b[0m\u001b[32mmain stack\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, and the other stack will be used to keep track of the minimum elements seen so far \u001b[0m\u001b[32m(\u001b[0m\u001b[32mmin stack\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. When an element is pushed onto the main stack, we check if the min stack is empty or if the top element of the min stack is greater than or equal to the element being pushed. If either condition is true, we push the element onto the min stack as well. When popping an element from the main stack, we check if the top element of the main stack is equal to the top element of the min stack. If they are equal, we pop the element from the min stack as well. The getMin operation simply returns the top element of the min stack.\",\\n\"response\": \"```python\\\\nclass MinStack:\\\\n def __init__\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m:\\\\n self.main_stack = \u001b[0m\u001b[32m[\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\\\n self.min_stack = \u001b[0m\u001b[32m[\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\\\n\\\\n def push\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself, x: int\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> None:\\\\n self.main_stack.append\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n if not self.min_stack or x <= self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m:\\\\n self.min_stack.append\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n\\\\n def pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> None:\\\\n if self.main_stack:\\\\n if self.main_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m == self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m:\\\\n self.min_stack.pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n self.main_stack.pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\\\n\\\\n def getMin\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -\u001b[0m\u001b[32m>\u001b[0m\u001b[32m int:\\\\n return self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\\\n```\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'4c4e54a6-c3e3-4d30-8da7-10003c59bfc7'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'73ece739-af65-4c0b-97c9-d2fbb0b84234'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m55\u001b[0m, \u001b[1;36m346289\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m51\u001b[0m, \u001b[1;36m812800\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[32m'turn_id'\u001b[0m: \u001b[32m'73ece739-af65-4c0b-97c9-d2fbb0b84234'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m55\u001b[0m, \u001b[1;36m364553\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[32m'output_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": [ + "
{\n", + "β 'session_id': '2beb59a8-c81d-4655-ab8e-cd0b6c6d83d0',\n", + "β 'session_name': 'evaluator_agent_0deb09c5-1204-49c6-8e91-51f73d883195',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 11, 35, 49, 863796),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': '```python\\nclass MinStack:\\n def __init__(self):\\n self.main_stack = []\\n self.min_stack = []\\n\\n def push(self, x: int) -> None:\\n self.main_stack.append(x)\\n if not self.min_stack or x <= self.min_stack[-1]:\\n self.min_stack.append(x)\\n\\n def pop(self) -> None:\\n if self.main_stack:\\n if self.main_stack[-1] == self.min_stack[-1]:\\n self.min_stack.pop()\\n self.main_stack.pop()\\n\\n def getMin(self) -> int:\\n return self.min_stack[-1]\\n```',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '{\"evaluation\": \"PASS\", \"feedback\": \"The provided code is correct, efficient, and well-structured. It correctly implements a MinStack with O(1) time complexity for push, pop, and getMin operations. The use of two stacks to keep track of the minimum element is a good approach. The code also follows best practices, with clear and concise method names, and proper handling of edge cases.\"}',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '2beb59a8-c81d-4655-ab8e-cd0b6c6d83d0',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 35, 55, 387165, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '{\"evaluation\": \"PASS\", \"feedback\": \"The provided code is correct, efficient, and well-structured. It correctly implements a MinStack with O(1) time complexity for push, pop, and getMin operations. The use of two stacks to keep track of the minimum element is a good approach. The code also follows best practices, with clear and concise method names, and proper handling of edge cases.\"}',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '01fccf0e-bc87-450e-9673-7a222d8b2044',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': 'cb4310bf-e31f-476f-9ca2-18f5dcfd16c9',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 35, 57, 294525, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 11, 35, 55, 398588, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': 'cb4310bf-e31f-476f-9ca2-18f5dcfd16c9',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 11, 35, 57, 306549, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'2beb59a8-c81d-4655-ab8e-cd0b6c6d83d0'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'evaluator_agent_0deb09c5-1204-49c6-8e91-51f73d883195'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m49\u001b[0m, \u001b[1;36m863796\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'```python\\nclass MinStack:\\n def __init__\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m:\\n self.main_stack = \u001b[0m\u001b[32m[\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n self.min_stack = \u001b[0m\u001b[32m[\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n\\n def push\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself, x: int\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> None:\\n self.main_stack.append\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n if not self.min_stack or x \u001b[0m\u001b[32m<\u001b[0m\u001b[32m= self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m:\\n self.min_stack.append\u001b[0m\u001b[32m(\u001b[0m\u001b[32mx\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n\\n def pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -> None:\\n if self.main_stack:\\n if self.main_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m == self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m:\\n self.min_stack.pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n self.main_stack.pop\u001b[0m\u001b[32m(\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n\\n def getMin\u001b[0m\u001b[32m(\u001b[0m\u001b[32mself\u001b[0m\u001b[32m)\u001b[0m\u001b[32m -\u001b[0m\u001b[32m>\u001b[0m\u001b[32m int:\\n return self.min_stack\u001b[0m\u001b[32m[\u001b[0m\u001b[32m-1\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n```'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"evaluation\": \"PASS\", \"feedback\": \"The provided code is correct, efficient, and well-structured. It correctly implements a MinStack with O\u001b[0m\u001b[32m(\u001b[0m\u001b[32m1\u001b[0m\u001b[32m)\u001b[0m\u001b[32m time complexity for push, pop, and getMin operations. The use of two stacks to keep track of the minimum element is a good approach. The code also follows best practices, with clear and concise method names, and proper handling of edge cases.\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'2beb59a8-c81d-4655-ab8e-cd0b6c6d83d0'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m55\u001b[0m, \u001b[1;36m387165\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"evaluation\": \"PASS\", \"feedback\": \"The provided code is correct, efficient, and well-structured. It correctly implements a MinStack with O\u001b[0m\u001b[32m(\u001b[0m\u001b[32m1\u001b[0m\u001b[32m)\u001b[0m\u001b[32m time complexity for push, pop, and getMin operations. The use of two stacks to keep track of the minimum element is a good approach. The code also follows best practices, with clear and concise method names, and proper handling of edge cases.\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'01fccf0e-bc87-450e-9673-7a222d8b2044'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'cb4310bf-e31f-476f-9ca2-18f5dcfd16c9'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m57\u001b[0m, \u001b[1;36m294525\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m55\u001b[0m, \u001b[1;36m398588\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[32m'turn_id'\u001b[0m: \u001b[32m'cb4310bf-e31f-476f-9ca2-18f5dcfd16c9'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m11\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m57\u001b[0m, \u001b[1;36m306549\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[32m'output_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" + } + ], + "source": [ + "generator_agent_session = client.agents.session.retrieve(session_id=generator_session_id, agent_id=generator_agent.agent_id)\n", + "pprint(generator_agent_session.to_dict())\n", + "\n", + "evaluator_agent_session = client.agents.session.retrieve(session_id=evaluator_session_id, agent_id=evaluator_agent.agent_id)\n", + "pprint(evaluator_agent_session.to_dict())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3. Orchestrator-Workers Workflow\n", + "\n", + "In the orchestrator-workers workflow, a central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results.\n", + "\n", + "\n", + "\n", + "**Example: Content Generation**\n", + "\n", + "We'll showcase how to use the orchestrator-workers workflow to generate a content. \n", + "- **Orchestrator agent** analyzes the user's request and breaks it down into 2-3 distinct approaches\n", + "- **Worker agents** are spawn up by the orchestrator agent to generate content based on each approach" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [], + "source": [ + "from typing import List, Dict\n", + "class OrchestratorOutputSchema(BaseModel):\n", + " analysis: str\n", + " tasks: List[Dict[str, str]]\n", + "\n", + "orchestrator_agent_config = {\n", + " **base_agent_config,\n", + " \"instructions\": \"\"\"Your job is to analyize the task provided by the user andbreak it down into 2-3 distinct approaches:\n", + "\n", + " Return your response in the following JSON format:\n", + " {{\n", + " \"analysis\": \"
Orchestrator Analysis: \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36m Orchestrator Analysis: \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "{\n", + "β 'analysis': \"To create an effective product description for the new eco-friendly water bottle, it's essential to consider the target audience of environmentally conscious millennials. This demographic values sustainability and is likely to be drawn to products that not only reduce waste but also offer long-term durability. The key features of the water bottle, including its plastic-free construction, insulated design, and lifetime warranty, should be highlighted in a way that resonates with this audience. Different approaches can serve various aspects of the task, such as emphasizing the technical specifications for a formal tone or focusing on the environmental benefits and user experience for a more conversational tone.\",\n", + "β 'tasks': [\n", + "β β {\n", + "β β β 'type': 'formal',\n", + "β β β 'description': 'Write a detailed, technical product description that outlines the specifications and features of the eco-friendly water bottle, including its plastic-free materials, insulation properties, and lifetime warranty.'\n", + "β β },\n", + "β β {\n", + "β β β 'type': 'conversational',\n", + "β β β 'description': \"Craft an engaging product description that speaks directly to environmentally conscious millennials, highlighting how the water bottle's eco-friendly design, insulated performance, and lifetime warranty align with their values and lifestyle.\"\n", + "β β },\n", + "β β {\n", + "β β β 'type': 'creative',\n", + "β β β 'description': 'Develop a compelling narrative around the eco-friendly water bottle, incorporating storytelling elements that illustrate the positive impact of choosing a plastic-free, insulated, and durable product on both personal health and the environment.'\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'analysis'\u001b[0m: \u001b[32m\"To create an effective product description for the new eco-friendly water bottle, it's essential to consider the target audience of environmentally conscious millennials. This demographic values sustainability and is likely to be drawn to products that not only reduce waste but also offer long-term durability. The key features of the water bottle, including its plastic-free construction, insulated design, and lifetime warranty, should be highlighted in a way that resonates with this audience. Different approaches can serve various aspects of the task, such as emphasizing the technical specifications for a formal tone or focusing on the environmental benefits and user experience for a more conversational tone.\"\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'tasks'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'type'\u001b[0m: \u001b[32m'formal'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'description'\u001b[0m: \u001b[32m'Write a detailed, technical product description that outlines the specifications and features of the eco-friendly water bottle, including its plastic-free materials, insulation properties, and lifetime warranty.'\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[32m'type'\u001b[0m: \u001b[32m'conversational'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'description'\u001b[0m: \u001b[32m\"Craft an engaging product description that speaks directly to environmentally conscious millennials, highlighting how the water bottle's eco-friendly design, insulated performance, and lifetime warranty align with their values and lifestyle.\"\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[32m'type'\u001b[0m: \u001b[32m'creative'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'description'\u001b[0m: \u001b[32m'Develop a compelling narrative around the eco-friendly water bottle, incorporating storytelling elements that illustrate the positive impact of choosing a plastic-free, insulated, and durable product on both personal health and the environment.'\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": [ + "
>>> Worker formal <<< \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;33m >>> Worker formal <<< \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Response: \n", + "\n", + "**Introduction to the EcoPro Water Bottle**\n", + "\n", + "The EcoPro Water Bottle is a revolutionary, eco-friendly hydration solution designed for the environmentally \n", + "conscious consumer. This premium water bottle is crafted from high-quality, plastic-free materials that not only \n", + "reduce waste but also provide superior insulation and durability. With its innovative design and commitment to \n", + "sustainability, the EcoPro Water Bottle is the perfect accessory for outdoor enthusiasts, commuters, and anyone \n", + "seeking a reliable and guilt-free drinking experience.\n", + "\n", + "**Plastic-Free Materials**\n", + "\n", + "The EcoPro Water Bottle is made from a unique blend of 18/8 stainless steel and natural, non-toxic materials. The \n", + "bottle's body is constructed from a single piece of stainless steel, ensuring a seamless and leak-proof design. The\n", + "lid and cap are crafted from a plant-based, bioplastic material derived from renewable resources such as corn \n", + "starch and sugarcane. This eco-friendly material is not only compostable but also resistant to extreme temperatures\n", + "and UV light.\n", + "\n", + "**Insulation Properties**\n", + "\n", + "The EcoPro Water Bottle features advanced insulation technology that keeps drinks hot or cold for hours. The \n", + "bottle's double-walled design, combined with a proprietary insulation material, provides exceptional thermal \n", + "performance. This means that your beverage will remain at the optimal temperature, whether you're sipping hot \n", + "coffee on a chilly morning or enjoying a refreshing cold drink on a sweltering summer day. The insulation \n", + "properties of the EcoPro Water Bottle are as follows:\n", + "\n", + "* Keeps drinks hot for up to 12 hours\n", + "* Keeps drinks cold for up to 24 hours\n", + "* Resistant to condensation and sweating\n", + "\n", + "**Lifetime Warranty**\n", + "\n", + "At EcoPro, we stand behind the quality and durability of our water bottles. That's why we offer a lifetime warranty\n", + "on all our products. If your EcoPro Water Bottle ever leaks, cracks, or fails to perform as expected, we will \n", + "replace it free of charge. This warranty is a testament to our commitment to producing high-quality, sustainable \n", + "products that will last a lifetime.\n", + "\n", + "**Additional Features**\n", + "\n", + "The EcoPro Water Bottle boasts a range of innovative features that make it a joy to use. These include:\n", + "\n", + "* **Wide Mouth**: The bottle's wide mouth makes it easy to clean and fill with ice or your favorite beverage.\n", + "* **Spout Lid**: The spout lid allows for easy sipping and is designed to prevent spills and leaks.\n", + "* **Carry Loop**: The carry loop provides a secure and comfortable way to transport your bottle on-the-go.\n", + "* **Measurement Markings**: The bottle features measurement markings, making it easy to track\n", + "\n" + ], + "text/plain": [ + "Response: \n", + "\n", + "**Introduction to the EcoPro Water Bottle**\n", + "\n", + "The EcoPro Water Bottle is a revolutionary, eco-friendly hydration solution designed for the environmentally \n", + "conscious consumer. This premium water bottle is crafted from high-quality, plastic-free materials that not only \n", + "reduce waste but also provide superior insulation and durability. With its innovative design and commitment to \n", + "sustainability, the EcoPro Water Bottle is the perfect accessory for outdoor enthusiasts, commuters, and anyone \n", + "seeking a reliable and guilt-free drinking experience.\n", + "\n", + "**Plastic-Free Materials**\n", + "\n", + "The EcoPro Water Bottle is made from a unique blend of \u001b[1;36m18\u001b[0m/\u001b[1;36m8\u001b[0m stainless steel and natural, non-toxic materials. The \n", + "bottle's body is constructed from a single piece of stainless steel, ensuring a seamless and leak-proof design. The\n", + "lid and cap are crafted from a plant-based, bioplastic material derived from renewable resources such as corn \n", + "starch and sugarcane. This eco-friendly material is not only compostable but also resistant to extreme temperatures\n", + "and UV light.\n", + "\n", + "**Insulation Properties**\n", + "\n", + "The EcoPro Water Bottle features advanced insulation technology that keeps drinks hot or cold for hours. The \n", + "bottle's double-walled design, combined with a proprietary insulation material, provides exceptional thermal \n", + "performance. This means that your beverage will remain at the optimal temperature, whether you're sipping hot \n", + "coffee on a chilly morning or enjoying a refreshing cold drink on a sweltering summer day. The insulation \n", + "properties of the EcoPro Water Bottle are as follows:\n", + "\n", + "* Keeps drinks hot for up to \u001b[1;36m12\u001b[0m hours\n", + "* Keeps drinks cold for up to \u001b[1;36m24\u001b[0m hours\n", + "* Resistant to condensation and sweating\n", + "\n", + "**Lifetime Warranty**\n", + "\n", + "At EcoPro, we stand behind the quality and durability of our water bottles. That's why we offer a lifetime warranty\n", + "on all our products. If your EcoPro Water Bottle ever leaks, cracks, or fails to perform as expected, we will \n", + "replace it free of charge. This warranty is a testament to our commitment to producing high-quality, sustainable \n", + "products that will last a lifetime.\n", + "\n", + "**Additional Features**\n", + "\n", + "The EcoPro Water Bottle boasts a range of innovative features that make it a joy to use. These include:\n", + "\n", + "* **Wide Mouth**: The bottle's wide mouth makes it easy to clean and fill with ice or your favorite beverage.\n", + "* **Spout Lid**: The spout lid allows for easy sipping and is designed to prevent spills and leaks.\n", + "* **Carry Loop**: The carry loop provides a secure and comfortable way to transport your bottle on-the-go.\n", + "* **Measurement Markings**: The bottle features measurement markings, making it easy to track\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
>>> Worker conversational <<< \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;33m >>> Worker conversational <<< \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Response:\n",
+ "\n",
+ "**Introducing the Ultimate Eco-Friendly Companion for the Conscious Adventurer**\n",
+ "\n",
+ "Are you tired of contributing to the staggering 8 million tons of plastic waste that enter our oceans every year? \n",
+ "Do you believe that staying hydrated on-the-go shouldn't come at the cost of the planet? Look no further! Our \n",
+ "eco-friendly water bottle is designed specifically with you, the environmentally conscious millennial, in mind.\n",
+ "\n",
+ "**Designed with the Planet in Mind**\n",
+ "\n",
+ "Our water bottle is crafted from high-quality, BPA-free materials that are not only durable but also fully \n",
+ "recyclable. The sleek and modern design is inspired by nature, with a minimalist aesthetic that reflects your \n",
+ "values of simplicity and sustainability. By choosing our water bottle, you're reducing your reliance on single-use \n",
+ "plastics and helping to minimize the staggering amount of waste that ends up in our landfills and oceans.\n",
+ "\n",
+ "**Performance that Keeps Up with Your Active Lifestyle**\n",
+ "\n",
+ "But our water bottle is more than just a pretty face. Its insulated design keeps your drinks hot or cold for hours,\n",
+ "whether you're hiking through the mountains, exploring the city, or simply need a refreshing pick-me-up at your \n",
+ "desk. The double-walled insulation ensures that your hands stay cool and dry, even when filled with scorching hot \n",
+ "coffee or icy cold water.\n",
+ "\n",
+ "**A Lifetime of Hydration, Guaranteed**\n",
+ "\n",
+ "We're so confident in the quality and durability of our water bottle that we're backing it with a lifetime \n",
+ "warranty. That's right - if your bottle ever breaks or malfunctions, we'll replace it free of charge. This means \n",
+ "you can enjoy years of hassle-free hydration, without worrying about the environmental or financial costs of \n",
+ "constantly replacing disposable water bottles.\n",
+ "\n",
+ "**Join a Community of Like-Minded Individuals**\n",
+ "\n",
+ "By choosing our eco-friendly water bottle, you're not just making a statement - you're joining a movement. You're \n",
+ "part of a community that values sustainability, simplicity, and the great outdoors. You're a conscious consumer who\n",
+ "demands more from the products you use and the companies you support. And we're proud to be a part of that journey \n",
+ "with you.\n",
+ "\n",
+ "**Upgrade to a Better Way of Hydrating**\n",
+ "\n",
+ "So why wait? Ditch the disposable water bottles and upgrade to a hydration companion that aligns with your values \n",
+ "and lifestyle. Our eco-friendly water bottle is the perfect accessory for any conscious adventurer, whether you're \n",
+ "a busy professional, an outdoor enthusiast, or simply someone who cares about the planet. Join the movement and \n",
+ "experience the freedom of hydration that's as sustainable as it is stylish.\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "Response:\n",
+ "\n",
+ "**Introducing the Ultimate Eco-Friendly Companion for the Conscious Adventurer**\n",
+ "\n",
+ "Are you tired of contributing to the staggering \u001b[1;36m8\u001b[0m million tons of plastic waste that enter our oceans every year? \n",
+ "Do you believe that staying hydrated on-the-go shouldn't come at the cost of the planet? Look no further! Our \n",
+ "eco-friendly water bottle is designed specifically with you, the environmentally conscious millennial, in mind.\n",
+ "\n",
+ "**Designed with the Planet in Mind**\n",
+ "\n",
+ "Our water bottle is crafted from high-quality, BPA-free materials that are not only durable but also fully \n",
+ "recyclable. The sleek and modern design is inspired by nature, with a minimalist aesthetic that reflects your \n",
+ "values of simplicity and sustainability. By choosing our water bottle, you're reducing your reliance on single-use \n",
+ "plastics and helping to minimize the staggering amount of waste that ends up in our landfills and oceans.\n",
+ "\n",
+ "**Performance that Keeps Up with Your Active Lifestyle**\n",
+ "\n",
+ "But our water bottle is more than just a pretty face. Its insulated design keeps your drinks hot or cold for hours,\n",
+ "whether you're hiking through the mountains, exploring the city, or simply need a refreshing pick-me-up at your \n",
+ "desk. The double-walled insulation ensures that your hands stay cool and dry, even when filled with scorching hot \n",
+ "coffee or icy cold water.\n",
+ "\n",
+ "**A Lifetime of Hydration, Guaranteed**\n",
+ "\n",
+ "We're so confident in the quality and durability of our water bottle that we're backing it with a lifetime \n",
+ "warranty. That's right - if your bottle ever breaks or malfunctions, we'll replace it free of charge. This means \n",
+ "you can enjoy years of hassle-free hydration, without worrying about the environmental or financial costs of \n",
+ "constantly replacing disposable water bottles.\n",
+ "\n",
+ "**Join a Community of Like-Minded Individuals**\n",
+ "\n",
+ "By choosing our eco-friendly water bottle, you're not just making a statement - you're joining a movement. You're \n",
+ "part of a community that values sustainability, simplicity, and the great outdoors. You're a conscious consumer who\n",
+ "demands more from the products you use and the companies you support. And we're proud to be a part of that journey \n",
+ "with you.\n",
+ "\n",
+ "**Upgrade to a Better Way of Hydrating**\n",
+ "\n",
+ "So why wait? Ditch the disposable water bottles and upgrade to a hydration companion that aligns with your values \n",
+ "and lifestyle. Our eco-friendly water bottle is the perfect accessory for any conscious adventurer, whether you're \n",
+ "a busy professional, an outdoor enthusiast, or simply someone who cares about the planet. Join the movement and \n",
+ "experience the freedom of hydration that's as sustainable as it is stylish.\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " >>> Worker creative <<< \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;33m >>> Worker creative <<< \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Response:\n",
+ "\n",
+ "In a world where single-use plastics have become an epidemic, threatening the very foundations of our ecosystems, a\n",
+ "hero emerges in the form of an eco-friendly water bottle. This isn't just any water bottle; it's a symbol of a \n",
+ "movement, a beacon of hope for a healthier planet and a healthier you. Let's dive into the story of how this \n",
+ "simple, yet powerful, product can change your life and the lives of those around you.\n",
+ "\n",
+ "Meet Emma, a young professional who, like many of us, was accustomed to grabbing a plastic water bottle on the go. \n",
+ "Every day, she'd use one, sometimes two, without giving it a second thought. But Emma began to notice the toll this\n",
+ "habit was taking. Her body wasn't retaining heat well, and she found herself constantly buying new bottles, \n",
+ "contributing to the plastic waste that was polluting her beloved local park and, ultimately, the oceans. The guilt \n",
+ "was creeping in, but the convenience was hard to give up.\n",
+ "\n",
+ "That was until Emma discovered the eco-friendly water bottle. Made from durable, BPA-free materials and designed \n",
+ "with insulation that keeps drinks hot or cold for hours, this bottle quickly became her constant companion. Not \n",
+ "only did it reduce her reliance on single-use plastics, but it also improved her hydration habits. The insulation \n",
+ "meant her drinks stayed at the perfect temperature, encouraging her to drink more throughout the day. Her energy \n",
+ "levels soared, and she noticed an improvement in her overall health.\n",
+ "\n",
+ "But the impact didn't stop there. Emma soon realized that her choice was part of a larger movement. By opting for a\n",
+ "plastic-free, insulated, and durable water bottle, she was contributing to a reduction in plastic waste. It's \n",
+ "estimated that if we don't change our ways, there will be more plastic than fish in the ocean by 2050. Emma's small\n",
+ "action, multiplied by millions of others making the same choice, could significantly alter this grim forecast.\n",
+ "\n",
+ "As word of her eco-friendly water bottle spread, Emma found herself at the forefront of a local initiative to \n",
+ "reduce plastic use in her community. Together with friends, family, and like-minded individuals, they organized \n",
+ "clean-up events, spread awareness about the dangers of single-use plastics, and encouraged others to make the \n",
+ "switch to reusable products. The community began to flourish, not just environmentally, but socially as well. \n",
+ "People from all walks of life came together, united by a common goal: to protect their home, the Earth.\n",
+ "\n",
+ "The story of Emma and her eco-friendly water bottle serves as a powerful reminder that our daily choices have the\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "Response:\n",
+ "\n",
+ "In a world where single-use plastics have become an epidemic, threatening the very foundations of our ecosystems, a\n",
+ "hero emerges in the form of an eco-friendly water bottle. This isn't just any water bottle; it's a symbol of a \n",
+ "movement, a beacon of hope for a healthier planet and a healthier you. Let's dive into the story of how this \n",
+ "simple, yet powerful, product can change your life and the lives of those around you.\n",
+ "\n",
+ "Meet Emma, a young professional who, like many of us, was accustomed to grabbing a plastic water bottle on the go. \n",
+ "Every day, she'd use one, sometimes two, without giving it a second thought. But Emma began to notice the toll this\n",
+ "habit was taking. Her body wasn't retaining heat well, and she found herself constantly buying new bottles, \n",
+ "contributing to the plastic waste that was polluting her beloved local park and, ultimately, the oceans. The guilt \n",
+ "was creeping in, but the convenience was hard to give up.\n",
+ "\n",
+ "That was until Emma discovered the eco-friendly water bottle. Made from durable, BPA-free materials and designed \n",
+ "with insulation that keeps drinks hot or cold for hours, this bottle quickly became her constant companion. Not \n",
+ "only did it reduce her reliance on single-use plastics, but it also improved her hydration habits. The insulation \n",
+ "meant her drinks stayed at the perfect temperature, encouraging her to drink more throughout the day. Her energy \n",
+ "levels soared, and she noticed an improvement in her overall health.\n",
+ "\n",
+ "But the impact didn't stop there. Emma soon realized that her choice was part of a larger movement. By opting for a\n",
+ "plastic-free, insulated, and durable water bottle, she was contributing to a reduction in plastic waste. It's \n",
+ "estimated that if we don't change our ways, there will be more plastic than fish in the ocean by \u001b[1;36m2050\u001b[0m. Emma's small\n",
+ "action, multiplied by millions of others making the same choice, could significantly alter this grim forecast.\n",
+ "\n",
+ "As word of her eco-friendly water bottle spread, Emma found herself at the forefront of a local initiative to \n",
+ "reduce plastic use in her community. Together with friends, family, and like-minded individuals, they organized \n",
+ "clean-up events, spread awareness about the dangers of single-use plastics, and encouraged others to make the \n",
+ "switch to reusable products. The community began to flourish, not just environmentally, but socially as well. \n",
+ "People from all walks of life came together, united by a common goal: to protect their home, the Earth.\n",
+ "\n",
+ "The story of Emma and her eco-friendly water bottle serves as a powerful reminder that our daily choices have the\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "orchestrator_agent, workers = orchestrator_worker_workflow(\n",
+ " task=\"Write a product description for a new eco-friendly water bottle\",\n",
+ " context={\n",
+ " \"target_audience\": \"environmentally conscious millennials\",\n",
+ " \"key_features\": [\"plastic-free\", \"insulated\", \"lifetime warranty\"]\n",
+ " }\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### 3.2. Monitor Orchestrator-Workers Workflow's Internals\n",
+ "\n",
+ "Let's see what happened with the orchestrator agent and worker agents it spawn up. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 91,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "{\n", + "β 'session_id': '8e765c0f-e71d-4c0c-9986-ee729d73966e',\n", + "β 'session_name': 'orchestrator_agent_976ef2f2-911c-47ac-9860-1c38d9038a91',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 28, 669769),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Your task is to Write a product description for a new eco-friendly water bottle. Here is some context: {'target_audience': 'environmentally conscious millennials', 'key_features': ['plastic-free', 'insulated', 'lifetime warranty']}\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': '{\\n\"analysis\": \"The task of writing a product description for a new eco-friendly water bottle requires a deep understanding of the target audience, which is environmentally conscious millennials. To effectively connect with this audience, the description should highlight the key features of the product, such as being plastic-free, insulated, and having a lifetime warranty. A valuable approach would be to emphasize the eco-friendly aspects of the product, as this aligns with the values and concerns of the target audience. Additionally, emphasizing the practical benefits of the product, such as its insulation and durability, would also be effective. Lastly, using a tone that is both informative and engaging would help to capture the reader\\'s attention and convey the product\\'s value.\",\\n\"tasks\": [\\n{\\n\"type\": \"formal\",\\n\"description\": \"Write a precise, technical description that highlights the product\\'s key features, such as its plastic-free construction, insulation capabilities, and lifetime warranty. This approach would serve the aspect of providing a clear and concise overview of the product\\'s specifications.\"\\n},\\n{\\n\"type\": \"conversational\",\\n\"description\": \"Write an engaging, friendly description that connects with the target audience on an emotional level, emphasizing the eco-friendly benefits of the product and how it aligns with their values. This approach would serve the aspect of building a relationship with the reader and creating a sense of shared values.\"\\n},\\n{\\n\"type\": \"creative\",\\n\"description\": \"Write a descriptive and imaginative piece that brings the product to life, highlighting its unique features and benefits in a way that is both informative and compelling. This approach would serve the aspect of captivating the reader\\'s attention and leaving a lasting impression.\"\\n}\\n]\\n}',\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '8e765c0f-e71d-4c0c-9986-ee729d73966e',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 28, 687648, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': '{\\n\"analysis\": \"The task of writing a product description for a new eco-friendly water bottle requires a deep understanding of the target audience, which is environmentally conscious millennials. To effectively connect with this audience, the description should highlight the key features of the product, such as being plastic-free, insulated, and having a lifetime warranty. A valuable approach would be to emphasize the eco-friendly aspects of the product, as this aligns with the values and concerns of the target audience. Additionally, emphasizing the practical benefits of the product, such as its insulation and durability, would also be effective. Lastly, using a tone that is both informative and engaging would help to capture the reader\\'s attention and convey the product\\'s value.\",\\n\"tasks\": [\\n{\\n\"type\": \"formal\",\\n\"description\": \"Write a precise, technical description that highlights the product\\'s key features, such as its plastic-free construction, insulation capabilities, and lifetime warranty. This approach would serve the aspect of providing a clear and concise overview of the product\\'s specifications.\"\\n},\\n{\\n\"type\": \"conversational\",\\n\"description\": \"Write an engaging, friendly description that connects with the target audience on an emotional level, emphasizing the eco-friendly benefits of the product and how it aligns with their values. This approach would serve the aspect of building a relationship with the reader and creating a sense of shared values.\"\\n},\\n{\\n\"type\": \"creative\",\\n\"description\": \"Write a descriptive and imaginative piece that brings the product to life, highlighting its unique features and benefits in a way that is both informative and compelling. This approach would serve the aspect of captivating the reader\\'s attention and leaving a lasting impression.\"\\n}\\n]\\n}',\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'd340d9ae-3aed-4042-aefd-9d9ce9448bee',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '0ceb314a-82e0-4728-9b08-0dbb89ee6f25',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 32, 72702, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 28, 698909, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '0ceb314a-82e0-4728-9b08-0dbb89ee6f25',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 32, 86428, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'8e765c0f-e71d-4c0c-9986-ee729d73966e'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'orchestrator_agent_976ef2f2-911c-47ac-9860-1c38d9038a91'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m669769\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Your task is to Write a product description for a new eco-friendly water bottle. Here is some context: \u001b[0m\u001b[32m{\u001b[0m\u001b[32m'target_audience': 'environmentally conscious millennials', 'key_features': \u001b[0m\u001b[32m[\u001b[0m\u001b[32m'plastic-free', 'insulated', 'lifetime warranty'\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"analysis\": \"The task of writing a product description for a new eco-friendly water bottle requires a deep understanding of the target audience, which is environmentally conscious millennials. To effectively connect with this audience, the description should highlight the key features of the product, such as being plastic-free, insulated, and having a lifetime warranty. A valuable approach would be to emphasize the eco-friendly aspects of the product, as this aligns with the values and concerns of the target audience. Additionally, emphasizing the practical benefits of the product, such as its insulation and durability, would also be effective. Lastly, using a tone that is both informative and engaging would help to capture the reader\\'s attention and convey the product\\'s value.\",\\n\"tasks\": \u001b[0m\u001b[32m[\u001b[0m\u001b[32m\\n\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"type\": \"formal\",\\n\"description\": \"Write a precise, technical description that highlights the product\\'s key features, such as its plastic-free construction, insulation capabilities, and lifetime warranty. This approach would serve the aspect of providing a clear and concise overview of the product\\'s specifications.\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\\n\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"type\": \"conversational\",\\n\"description\": \"Write an engaging, friendly description that connects with the target audience on an emotional level, emphasizing the eco-friendly benefits of the product and how it aligns with their values. This approach would serve the aspect of building a relationship with the reader and creating a sense of shared values.\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\\n\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"type\": \"creative\",\\n\"description\": \"Write a descriptive and imaginative piece that brings the product to life, highlighting its unique features and benefits in a way that is both informative and compelling. This approach would serve the aspect of captivating the reader\\'s attention and leaving a lasting impression.\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\\n\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'8e765c0f-e71d-4c0c-9986-ee729d73966e'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m687648\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"analysis\": \"The task of writing a product description for a new eco-friendly water bottle requires a deep understanding of the target audience, which is environmentally conscious millennials. To effectively connect with this audience, the description should highlight the key features of the product, such as being plastic-free, insulated, and having a lifetime warranty. A valuable approach would be to emphasize the eco-friendly aspects of the product, as this aligns with the values and concerns of the target audience. Additionally, emphasizing the practical benefits of the product, such as its insulation and durability, would also be effective. Lastly, using a tone that is both informative and engaging would help to capture the reader\\'s attention and convey the product\\'s value.\",\\n\"tasks\": \u001b[0m\u001b[32m[\u001b[0m\u001b[32m\\n\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"type\": \"formal\",\\n\"description\": \"Write a precise, technical description that highlights the product\\'s key features, such as its plastic-free construction, insulation capabilities, and lifetime warranty. This approach would serve the aspect of providing a clear and concise overview of the product\\'s specifications.\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\\n\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"type\": \"conversational\",\\n\"description\": \"Write an engaging, friendly description that connects with the target audience on an emotional level, emphasizing the eco-friendly benefits of the product and how it aligns with their values. This approach would serve the aspect of building a relationship with the reader and creating a sense of shared values.\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\\n\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\n\"type\": \"creative\",\\n\"description\": \"Write a descriptive and imaginative piece that brings the product to life, highlighting its unique features and benefits in a way that is both informative and compelling. This approach would serve the aspect of captivating the reader\\'s attention and leaving a lasting impression.\"\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\\n\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'd340d9ae-3aed-4042-aefd-9d9ce9448bee'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'0ceb314a-82e0-4728-9b08-0dbb89ee6f25'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m32\u001b[0m, \u001b[1;36m72702\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m28\u001b[0m, \u001b[1;36m698909\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[32m'turn_id'\u001b[0m: \u001b[32m'0ceb314a-82e0-4728-9b08-0dbb89ee6f25'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m32\u001b[0m, \u001b[1;36m86428\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Worker formal Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '30a5e169-2aeb-4e20-99b9-f060349b6b55',\n", + "β 'session_name': 'worker_agent_2824b8d3-3059-4862-966d-12ce895d6c0b',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 32, 154138),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Your task is to Write a precise, technical description that highlights the product's key features, such as its plastic-free construction, insulation capabilities, and lifetime warranty. This approach would serve the aspect of providing a clear and concise overview of the product's specifications..\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': \"Response: \\n\\nThe product in question is a cutting-edge, eco-friendly solution designed to provide superior performance while minimizing environmental impact. Its key features include a plastic-free construction, leveraging high-quality, sustainable materials that not only reduce waste but also ensure durability and longevity. \\n\\nOne of the standout aspects of this product is its exceptional insulation capabilities. Engineered with advanced technology, it effectively retains heat in colder conditions and keeps warmth at bay in hotter environments, thereby optimizing energy efficiency and comfort. This feature is particularly beneficial for applications where temperature control is crucial, making it an ideal choice for a wide range of uses.\\n\\nFurthermore, the product comes with a comprehensive lifetime warranty, reflecting the manufacturer's confidence in its quality and performance. This warranty provides users with peace of mind, knowing that they are protected against defects and functional failures for the entire lifespan of the product. It underscores the commitment to customer satisfaction and the dedication to delivering products that meet the highest standards of excellence.\\n\\nIn terms of specifications, the product boasts a robust design that is both lightweight and easy to use, making it versatile and adaptable to various settings. Its plastic-free construction not only supports eco-friendly initiatives but also contributes to a healthier indoor air quality by eliminating the potential for plastic off-gassing.\\n\\nThe insulation properties are further enhanced by a unique design that minimizes thermal bridging, ensuring consistent and reliable performance. Whether used in residential, commercial, or industrial applications, this product is designed to deliver consistent results, combining sustainability with functional superiority.\\n\\nOverall, the product represents a significant advancement in eco-friendly technology, combining a plastic-free construction, superior insulation capabilities, and a lifetime warranty to offer a solution that is as environmentally responsible as it is effective. It is an exemplary model of innovative design and manufacturing excellence, catering to the evolving needs of consumers who prioritize both performance and sustainability.\",\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '30a5e169-2aeb-4e20-99b9-f060349b6b55',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 32, 161464, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': \"Response: \\n\\nThe product in question is a cutting-edge, eco-friendly solution designed to provide superior performance while minimizing environmental impact. Its key features include a plastic-free construction, leveraging high-quality, sustainable materials that not only reduce waste but also ensure durability and longevity. \\n\\nOne of the standout aspects of this product is its exceptional insulation capabilities. Engineered with advanced technology, it effectively retains heat in colder conditions and keeps warmth at bay in hotter environments, thereby optimizing energy efficiency and comfort. This feature is particularly beneficial for applications where temperature control is crucial, making it an ideal choice for a wide range of uses.\\n\\nFurthermore, the product comes with a comprehensive lifetime warranty, reflecting the manufacturer's confidence in its quality and performance. This warranty provides users with peace of mind, knowing that they are protected against defects and functional failures for the entire lifespan of the product. It underscores the commitment to customer satisfaction and the dedication to delivering products that meet the highest standards of excellence.\\n\\nIn terms of specifications, the product boasts a robust design that is both lightweight and easy to use, making it versatile and adaptable to various settings. Its plastic-free construction not only supports eco-friendly initiatives but also contributes to a healthier indoor air quality by eliminating the potential for plastic off-gassing.\\n\\nThe insulation properties are further enhanced by a unique design that minimizes thermal bridging, ensuring consistent and reliable performance. Whether used in residential, commercial, or industrial applications, this product is designed to deliver consistent results, combining sustainability with functional superiority.\\n\\nOverall, the product represents a significant advancement in eco-friendly technology, combining a plastic-free construction, superior insulation capabilities, and a lifetime warranty to offer a solution that is as environmentally responsible as it is effective. It is an exemplary model of innovative design and manufacturing excellence, catering to the evolving needs of consumers who prioritize both performance and sustainability.\",\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '259985a9-7571-4b03-af86-758e6b17beb8',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '4d569b07-a68a-44b6-9e19-2841d1d1f002',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 37, 623431, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 32, 172831, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '4d569b07-a68a-44b6-9e19-2841d1d1f002',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 37, 636202, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'30a5e169-2aeb-4e20-99b9-f060349b6b55'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_2824b8d3-3059-4862-966d-12ce895d6c0b'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m32\u001b[0m, \u001b[1;36m154138\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Your task is to Write a precise, technical description that highlights the product's key features, such as its plastic-free construction, insulation capabilities, and lifetime warranty. This approach would serve the aspect of providing a clear and concise overview of the product's specifications..\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Response: \\n\\nThe product in question is a cutting-edge, eco-friendly solution designed to provide superior performance while minimizing environmental impact. Its key features include a plastic-free construction, leveraging high-quality, sustainable materials that not only reduce waste but also ensure durability and longevity. \\n\\nOne of the standout aspects of this product is its exceptional insulation capabilities. Engineered with advanced technology, it effectively retains heat in colder conditions and keeps warmth at bay in hotter environments, thereby optimizing energy efficiency and comfort. This feature is particularly beneficial for applications where temperature control is crucial, making it an ideal choice for a wide range of uses.\\n\\nFurthermore, the product comes with a comprehensive lifetime warranty, reflecting the manufacturer's confidence in its quality and performance. This warranty provides users with peace of mind, knowing that they are protected against defects and functional failures for the entire lifespan of the product. It underscores the commitment to customer satisfaction and the dedication to delivering products that meet the highest standards of excellence.\\n\\nIn terms of specifications, the product boasts a robust design that is both lightweight and easy to use, making it versatile and adaptable to various settings. Its plastic-free construction not only supports eco-friendly initiatives but also contributes to a healthier indoor air quality by eliminating the potential for plastic off-gassing.\\n\\nThe insulation properties are further enhanced by a unique design that minimizes thermal bridging, ensuring consistent and reliable performance. Whether used in residential, commercial, or industrial applications, this product is designed to deliver consistent results, combining sustainability with functional superiority.\\n\\nOverall, the product represents a significant advancement in eco-friendly technology, combining a plastic-free construction, superior insulation capabilities, and a lifetime warranty to offer a solution that is as environmentally responsible as it is effective. It is an exemplary model of innovative design and manufacturing excellence, catering to the evolving needs of consumers who prioritize both performance and sustainability.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'30a5e169-2aeb-4e20-99b9-f060349b6b55'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m32\u001b[0m, \u001b[1;36m161464\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Response: \\n\\nThe product in question is a cutting-edge, eco-friendly solution designed to provide superior performance while minimizing environmental impact. Its key features include a plastic-free construction, leveraging high-quality, sustainable materials that not only reduce waste but also ensure durability and longevity. \\n\\nOne of the standout aspects of this product is its exceptional insulation capabilities. Engineered with advanced technology, it effectively retains heat in colder conditions and keeps warmth at bay in hotter environments, thereby optimizing energy efficiency and comfort. This feature is particularly beneficial for applications where temperature control is crucial, making it an ideal choice for a wide range of uses.\\n\\nFurthermore, the product comes with a comprehensive lifetime warranty, reflecting the manufacturer's confidence in its quality and performance. This warranty provides users with peace of mind, knowing that they are protected against defects and functional failures for the entire lifespan of the product. It underscores the commitment to customer satisfaction and the dedication to delivering products that meet the highest standards of excellence.\\n\\nIn terms of specifications, the product boasts a robust design that is both lightweight and easy to use, making it versatile and adaptable to various settings. Its plastic-free construction not only supports eco-friendly initiatives but also contributes to a healthier indoor air quality by eliminating the potential for plastic off-gassing.\\n\\nThe insulation properties are further enhanced by a unique design that minimizes thermal bridging, ensuring consistent and reliable performance. Whether used in residential, commercial, or industrial applications, this product is designed to deliver consistent results, combining sustainability with functional superiority.\\n\\nOverall, the product represents a significant advancement in eco-friendly technology, combining a plastic-free construction, superior insulation capabilities, and a lifetime warranty to offer a solution that is as environmentally responsible as it is effective. It is an exemplary model of innovative design and manufacturing excellence, catering to the evolving needs of consumers who prioritize both performance and sustainability.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'259985a9-7571-4b03-af86-758e6b17beb8'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'4d569b07-a68a-44b6-9e19-2841d1d1f002'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m623431\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m32\u001b[0m, \u001b[1;36m172831\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[32m'turn_id'\u001b[0m: \u001b[32m'4d569b07-a68a-44b6-9e19-2841d1d1f002'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m636202\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Worker conversational Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': '254cf164-52f4-4b7f-ba92-996e97725c12',\n", + "β 'session_name': 'worker_agent_b83fb070-705b-4e58-8146-84970328bea0',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 37, 686501),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': 'Your task is to Write an engaging, friendly description that connects with the target audience on an emotional level, emphasizing the eco-friendly benefits of the product and how it aligns with their values. This approach would serve the aspect of building a relationship with the reader and creating a sense of shared values..',\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': \"Response:\\n\\nImagine a world where every small choice you make can contribute to a bigger, more beautiful picture - a world where the air is fresh, the oceans are clean, and the future is bright. At [Brand Name], we believe that this world is not just a dream, but a reality that we can create together, one step at a time. That's why we're passionate about introducing you to our eco-friendly product, designed with love for the planet and a deep respect for the values that you hold dear.\\n\\nOur product is more than just a solution to your everyday needs; it's a statement of your commitment to the well-being of our planet. Made from sustainable materials and designed with recyclability in mind, every aspect of our product reflects our shared desire to reduce waste and live in harmony with nature. Whether you're a long-time advocate for environmental causes or just starting your journey towards a more sustainable lifestyle, our product is here to support and enhance your efforts.\\n\\nWhat sets us apart is not just our product's eco-friendly features, but the community of like-minded individuals who believe, as we do, that small actions today can lead to a significant positive impact tomorrow. By choosing our product, you're not only making a responsible choice for the planet, but you're also becoming part of a movement - a movement that values the beauty of nature, the importance of community, and the power of collective action.\\n\\nAt [Brand Name], we're dedicated to more than just selling a product; we're committed to fostering a relationship with you, our customer, and with the Earth. We believe in transparency, in honesty, and in the open sharing of our processes and materials. We want you to feel confident and proud of the choices you make, knowing that you're supporting a brand that genuinely cares about the same things you do.\\n\\nSo, join us on this journey towards a greener, brighter future. Together, let's embrace the power of sustainable living, celebrate the beauty of our planet, and create a world that is healthier, happier, and more vibrant for all of us. With every purchase, every share, and every conversation, we're one step closer to making our vision a reality. Thank you for being part of our community, and for believing, as we do, that together, we can make a difference.\",\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': '254cf164-52f4-4b7f-ba92-996e97725c12',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 37, 692969, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': \"Response:\\n\\nImagine a world where every small choice you make can contribute to a bigger, more beautiful picture - a world where the air is fresh, the oceans are clean, and the future is bright. At [Brand Name], we believe that this world is not just a dream, but a reality that we can create together, one step at a time. That's why we're passionate about introducing you to our eco-friendly product, designed with love for the planet and a deep respect for the values that you hold dear.\\n\\nOur product is more than just a solution to your everyday needs; it's a statement of your commitment to the well-being of our planet. Made from sustainable materials and designed with recyclability in mind, every aspect of our product reflects our shared desire to reduce waste and live in harmony with nature. Whether you're a long-time advocate for environmental causes or just starting your journey towards a more sustainable lifestyle, our product is here to support and enhance your efforts.\\n\\nWhat sets us apart is not just our product's eco-friendly features, but the community of like-minded individuals who believe, as we do, that small actions today can lead to a significant positive impact tomorrow. By choosing our product, you're not only making a responsible choice for the planet, but you're also becoming part of a movement - a movement that values the beauty of nature, the importance of community, and the power of collective action.\\n\\nAt [Brand Name], we're dedicated to more than just selling a product; we're committed to fostering a relationship with you, our customer, and with the Earth. We believe in transparency, in honesty, and in the open sharing of our processes and materials. We want you to feel confident and proud of the choices you make, knowing that you're supporting a brand that genuinely cares about the same things you do.\\n\\nSo, join us on this journey towards a greener, brighter future. Together, let's embrace the power of sustainable living, celebrate the beauty of our planet, and create a world that is healthier, happier, and more vibrant for all of us. With every purchase, every share, and every conversation, we're one step closer to making our vision a reality. Thank you for being part of our community, and for believing, as we do, that together, we can make a difference.\",\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': '6e454ed2-6dc0-469f-aba6-854a3f52093b',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '3e0e5e28-9693-4535-ae54-cb00ba977a4e',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 47, 299500, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 37, 703303, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '3e0e5e28-9693-4535-ae54-cb00ba977a4e',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 47, 313355, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'254cf164-52f4-4b7f-ba92-996e97725c12'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_b83fb070-705b-4e58-8146-84970328bea0'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m686501\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m'Your task is to Write an engaging, friendly description that connects with the target audience on an emotional level, emphasizing the eco-friendly benefits of the product and how it aligns with their values. This approach would serve the aspect of building a relationship with the reader and creating a sense of shared values..'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Response:\\n\\nImagine a world where every small choice you make can contribute to a bigger, more beautiful picture - a world where the air is fresh, the oceans are clean, and the future is bright. At \u001b[0m\u001b[32m[\u001b[0m\u001b[32mBrand Name\u001b[0m\u001b[32m]\u001b[0m\u001b[32m, we believe that this world is not just a dream, but a reality that we can create together, one step at a time. That's why we're passionate about introducing you to our eco-friendly product, designed with love for the planet and a deep respect for the values that you hold dear.\\n\\nOur product is more than just a solution to your everyday needs; it's a statement of your commitment to the well-being of our planet. Made from sustainable materials and designed with recyclability in mind, every aspect of our product reflects our shared desire to reduce waste and live in harmony with nature. Whether you're a long-time advocate for environmental causes or just starting your journey towards a more sustainable lifestyle, our product is here to support and enhance your efforts.\\n\\nWhat sets us apart is not just our product's eco-friendly features, but the community of like-minded individuals who believe, as we do, that small actions today can lead to a significant positive impact tomorrow. By choosing our product, you're not only making a responsible choice for the planet, but you're also becoming part of a movement - a movement that values the beauty of nature, the importance of community, and the power of collective action.\\n\\nAt \u001b[0m\u001b[32m[\u001b[0m\u001b[32mBrand Name\u001b[0m\u001b[32m]\u001b[0m\u001b[32m, we're dedicated to more than just selling a product; we're committed to fostering a relationship with you, our customer, and with the Earth. We believe in transparency, in honesty, and in the open sharing of our processes and materials. We want you to feel confident and proud of the choices you make, knowing that you're supporting a brand that genuinely cares about the same things you do.\\n\\nSo, join us on this journey towards a greener, brighter future. Together, let's embrace the power of sustainable living, celebrate the beauty of our planet, and create a world that is healthier, happier, and more vibrant for all of us. With every purchase, every share, and every conversation, we're one step closer to making our vision a reality. Thank you for being part of our community, and for believing, as we do, that together, we can make a difference.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'254cf164-52f4-4b7f-ba92-996e97725c12'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m692969\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Response:\\n\\nImagine a world where every small choice you make can contribute to a bigger, more beautiful picture - a world where the air is fresh, the oceans are clean, and the future is bright. At \u001b[0m\u001b[32m[\u001b[0m\u001b[32mBrand Name\u001b[0m\u001b[32m]\u001b[0m\u001b[32m, we believe that this world is not just a dream, but a reality that we can create together, one step at a time. That's why we're passionate about introducing you to our eco-friendly product, designed with love for the planet and a deep respect for the values that you hold dear.\\n\\nOur product is more than just a solution to your everyday needs; it's a statement of your commitment to the well-being of our planet. Made from sustainable materials and designed with recyclability in mind, every aspect of our product reflects our shared desire to reduce waste and live in harmony with nature. Whether you're a long-time advocate for environmental causes or just starting your journey towards a more sustainable lifestyle, our product is here to support and enhance your efforts.\\n\\nWhat sets us apart is not just our product's eco-friendly features, but the community of like-minded individuals who believe, as we do, that small actions today can lead to a significant positive impact tomorrow. By choosing our product, you're not only making a responsible choice for the planet, but you're also becoming part of a movement - a movement that values the beauty of nature, the importance of community, and the power of collective action.\\n\\nAt \u001b[0m\u001b[32m[\u001b[0m\u001b[32mBrand Name\u001b[0m\u001b[32m]\u001b[0m\u001b[32m, we're dedicated to more than just selling a product; we're committed to fostering a relationship with you, our customer, and with the Earth. We believe in transparency, in honesty, and in the open sharing of our processes and materials. We want you to feel confident and proud of the choices you make, knowing that you're supporting a brand that genuinely cares about the same things you do.\\n\\nSo, join us on this journey towards a greener, brighter future. Together, let's embrace the power of sustainable living, celebrate the beauty of our planet, and create a world that is healthier, happier, and more vibrant for all of us. With every purchase, every share, and every conversation, we're one step closer to making our vision a reality. Thank you for being part of our community, and for believing, as we do, that together, we can make a difference.\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'6e454ed2-6dc0-469f-aba6-854a3f52093b'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'3e0e5e28-9693-4535-ae54-cb00ba977a4e'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m47\u001b[0m, \u001b[1;36m299500\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m37\u001b[0m, \u001b[1;36m703303\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[32m'turn_id'\u001b[0m: \u001b[32m'3e0e5e28-9693-4535-ae54-cb00ba977a4e'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m47\u001b[0m, \u001b[1;36m313355\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[32m'output_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" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Worker creative Session:\n" + ] + }, + { + "data": { + "text/html": [ + "
{\n", + "β 'session_id': 'a4caaaa3-4074-48cc-884e-70e1ea08988e',\n", + "β 'session_name': 'worker_agent_947325ae-2234-497e-82d7-ca54fa6f5f64',\n", + "β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 47, 364200),\n", + "β 'turns': [\n", + "β β {\n", + "β β β 'input_messages': [\n", + "β β β β {\n", + "β β β β β 'content': \"Your task is to Write a descriptive and imaginative piece that brings the product to life, highlighting its unique features and benefits in a way that is both informative and compelling. This approach would serve the aspect of captivating the reader's attention and leaving a lasting impression..\",\n", + "β β β β β 'role': 'user',\n", + "β β β β β 'context': None\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'output_message': {\n", + "β β β β 'content': \"Response: \\n\\nImagine stepping into a world where technology seamlessly blends with art, where innovation knows no bounds, and where the ordinary becomes extraordinary. Welcome to the realm of Lumina, a revolutionary smartwatch that redefines the boundaries of timekeeping and personal style. This masterpiece is not just a device; it's an experience that wraps around your wrist, a constant companion that adapts to your every move, desire, and dream.\\n\\nAs you slip on Lumina, the soft, sleek strap molds to your skin, comfortable against your pulse. The face, a vibrant canvas of light and color, comes alive with every glance. It's not just a screen; it's a window to a universe of possibilities. With a mere touch, the interface unfolds, revealing a tapestry of features designed to elevate your daily life. From tracking the intricacies of your health and fitness journey to keeping you connected with loved ones, Lumina is your personal gateway to a world of wellness and communication.\\n\\nOne of the standout features of Lumina is its advanced health monitoring system. It's equipped with cutting-edge technology that not only tracks your heart rate and sleep patterns but also provides insightful analysis to help you understand your body better. Imagine being able to optimize your workout sessions based on real-time feedback, or receiving alerts that remind you to stay hydrated throughout the day. Lumina doesn't just monitor your health; it empowers you to take control of it.\\n\\nBut Lumina is more than just a health companion; it's also a style statement. Its design is a symphony of elegance and modernity, with interchangeable straps that allow you to match your watch to your mood, outfit, or occasion. Whether you're heading to a boardroom meeting or a casual evening out with friends, Lumina adapts, ensuring you always make a statement. It's the perfect blend of form and function, where every detail has been meticulously crafted to provide a seamless user experience.\\n\\nWhat truly sets Lumina apart, however, is its integration with your digital life. With seamless connectivity to your smartphone, you can receive notifications, control your music playlists, and even make hands-free calls. The voice assistant feature allows you to command your day with ease, from setting reminders to sending messages, all without needing to reach for your phone. It's the epitome of convenience, streamlining your interactions and letting you live more in the moment.\\n\\nAs the sun dips and the stars begin to twinkle, Lumina transforms once more. Its face glows softly in the dark, a beacon of innovation\",\n", + "β β β β 'role': 'assistant',\n", + "β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β 'tool_calls': []\n", + "β β β },\n", + "β β β 'session_id': 'a4caaaa3-4074-48cc-884e-70e1ea08988e',\n", + "β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 47, 372175, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β β 'steps': [\n", + "β β β β {\n", + "β β β β β 'model_response': {\n", + "β β β β β β 'content': \"Response: \\n\\nImagine stepping into a world where technology seamlessly blends with art, where innovation knows no bounds, and where the ordinary becomes extraordinary. Welcome to the realm of Lumina, a revolutionary smartwatch that redefines the boundaries of timekeeping and personal style. This masterpiece is not just a device; it's an experience that wraps around your wrist, a constant companion that adapts to your every move, desire, and dream.\\n\\nAs you slip on Lumina, the soft, sleek strap molds to your skin, comfortable against your pulse. The face, a vibrant canvas of light and color, comes alive with every glance. It's not just a screen; it's a window to a universe of possibilities. With a mere touch, the interface unfolds, revealing a tapestry of features designed to elevate your daily life. From tracking the intricacies of your health and fitness journey to keeping you connected with loved ones, Lumina is your personal gateway to a world of wellness and communication.\\n\\nOne of the standout features of Lumina is its advanced health monitoring system. It's equipped with cutting-edge technology that not only tracks your heart rate and sleep patterns but also provides insightful analysis to help you understand your body better. Imagine being able to optimize your workout sessions based on real-time feedback, or receiving alerts that remind you to stay hydrated throughout the day. Lumina doesn't just monitor your health; it empowers you to take control of it.\\n\\nBut Lumina is more than just a health companion; it's also a style statement. Its design is a symphony of elegance and modernity, with interchangeable straps that allow you to match your watch to your mood, outfit, or occasion. Whether you're heading to a boardroom meeting or a casual evening out with friends, Lumina adapts, ensuring you always make a statement. It's the perfect blend of form and function, where every detail has been meticulously crafted to provide a seamless user experience.\\n\\nWhat truly sets Lumina apart, however, is its integration with your digital life. With seamless connectivity to your smartphone, you can receive notifications, control your music playlists, and even make hands-free calls. The voice assistant feature allows you to command your day with ease, from setting reminders to sending messages, all without needing to reach for your phone. It's the epitome of convenience, streamlining your interactions and letting you live more in the moment.\\n\\nAs the sun dips and the stars begin to twinkle, Lumina transforms once more. Its face glows softly in the dark, a beacon of innovation\",\n", + "β β β β β β 'role': 'assistant',\n", + "β β β β β β 'stop_reason': 'end_of_turn',\n", + "β β β β β β 'tool_calls': []\n", + "β β β β β },\n", + "β β β β β 'step_id': 'd459749c-f883-4d96-acb3-723164ed92b1',\n", + "β β β β β 'step_type': 'inference',\n", + "β β β β β 'turn_id': '47645e95-f606-4bec-ad1e-cc471c78dcd2',\n", + "β β β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 56, 306242, tzinfo=TzInfo(-08:00)),\n", + "β β β β β 'started_at': datetime.datetime(2025, 3, 3, 12, 45, 47, 383443, tzinfo=TzInfo(-08:00))\n", + "β β β β }\n", + "β β β ],\n", + "β β β 'turn_id': '47645e95-f606-4bec-ad1e-cc471c78dcd2',\n", + "β β β 'completed_at': datetime.datetime(2025, 3, 3, 12, 45, 56, 319286, tzinfo=TzInfo(-08:00)),\n", + "β β β 'output_attachments': []\n", + "β β }\n", + "β ]\n", + "}\n", + "\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_id'\u001b[0m: \u001b[32m'a4caaaa3-4074-48cc-884e-70e1ea08988e'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'session_name'\u001b[0m: \u001b[32m'worker_agent_947325ae-2234-497e-82d7-ca54fa6f5f64'\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m47\u001b[0m, \u001b[1;36m364200\u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ \u001b[0m\u001b[32m'turns'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'input_messages'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Your task is to Write a descriptive and imaginative piece that brings the product to life, highlighting its unique features and benefits in a way that is both informative and compelling. This approach would serve the aspect of captivating the reader's attention and leaving a lasting impression..\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'user'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'context'\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[32m'output_message'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Response: \\n\\nImagine stepping into a world where technology seamlessly blends with art, where innovation knows no bounds, and where the ordinary becomes extraordinary. Welcome to the realm of Lumina, a revolutionary smartwatch that redefines the boundaries of timekeeping and personal style. This masterpiece is not just a device; it's an experience that wraps around your wrist, a constant companion that adapts to your every move, desire, and dream.\\n\\nAs you slip on Lumina, the soft, sleek strap molds to your skin, comfortable against your pulse. The face, a vibrant canvas of light and color, comes alive with every glance. It's not just a screen; it's a window to a universe of possibilities. With a mere touch, the interface unfolds, revealing a tapestry of features designed to elevate your daily life. From tracking the intricacies of your health and fitness journey to keeping you connected with loved ones, Lumina is your personal gateway to a world of wellness and communication.\\n\\nOne of the standout features of Lumina is its advanced health monitoring system. It's equipped with cutting-edge technology that not only tracks your heart rate and sleep patterns but also provides insightful analysis to help you understand your body better. Imagine being able to optimize your workout sessions based on real-time feedback, or receiving alerts that remind you to stay hydrated throughout the day. Lumina doesn't just monitor your health; it empowers you to take control of it.\\n\\nBut Lumina is more than just a health companion; it's also a style statement. Its design is a symphony of elegance and modernity, with interchangeable straps that allow you to match your watch to your mood, outfit, or occasion. Whether you're heading to a boardroom meeting or a casual evening out with friends, Lumina adapts, ensuring you always make a statement. It's the perfect blend of form and function, where every detail has been meticulously crafted to provide a seamless user experience.\\n\\nWhat truly sets Lumina apart, however, is its integration with your digital life. With seamless connectivity to your smartphone, you can receive notifications, control your music playlists, and even make hands-free calls. The voice assistant feature allows you to command your day with ease, from setting reminders to sending messages, all without needing to reach for your phone. It's the epitome of convenience, streamlining your interactions and letting you live more in the moment.\\n\\nAs the sun dips and the stars begin to twinkle, Lumina transforms once more. Its face glows softly in the dark, a beacon of innovation\"\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[32m'tool_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[32m'session_id'\u001b[0m: \u001b[32m'a4caaaa3-4074-48cc-884e-70e1ea08988e'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m47\u001b[0m, \u001b[1;36m372175\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[32m'steps'\u001b[0m: \u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'model_response'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'content'\u001b[0m: \u001b[32m\"Response: \\n\\nImagine stepping into a world where technology seamlessly blends with art, where innovation knows no bounds, and where the ordinary becomes extraordinary. Welcome to the realm of Lumina, a revolutionary smartwatch that redefines the boundaries of timekeeping and personal style. This masterpiece is not just a device; it's an experience that wraps around your wrist, a constant companion that adapts to your every move, desire, and dream.\\n\\nAs you slip on Lumina, the soft, sleek strap molds to your skin, comfortable against your pulse. The face, a vibrant canvas of light and color, comes alive with every glance. It's not just a screen; it's a window to a universe of possibilities. With a mere touch, the interface unfolds, revealing a tapestry of features designed to elevate your daily life. From tracking the intricacies of your health and fitness journey to keeping you connected with loved ones, Lumina is your personal gateway to a world of wellness and communication.\\n\\nOne of the standout features of Lumina is its advanced health monitoring system. It's equipped with cutting-edge technology that not only tracks your heart rate and sleep patterns but also provides insightful analysis to help you understand your body better. Imagine being able to optimize your workout sessions based on real-time feedback, or receiving alerts that remind you to stay hydrated throughout the day. Lumina doesn't just monitor your health; it empowers you to take control of it.\\n\\nBut Lumina is more than just a health companion; it's also a style statement. Its design is a symphony of elegance and modernity, with interchangeable straps that allow you to match your watch to your mood, outfit, or occasion. Whether you're heading to a boardroom meeting or a casual evening out with friends, Lumina adapts, ensuring you always make a statement. It's the perfect blend of form and function, where every detail has been meticulously crafted to provide a seamless user experience.\\n\\nWhat truly sets Lumina apart, however, is its integration with your digital life. With seamless connectivity to your smartphone, you can receive notifications, control your music playlists, and even make hands-free calls. The voice assistant feature allows you to command your day with ease, from setting reminders to sending messages, all without needing to reach for your phone. It's the epitome of convenience, streamlining your interactions and letting you live more in the moment.\\n\\nAs the sun dips and the stars begin to twinkle, Lumina transforms once more. Its face glows softly in the dark, a beacon of innovation\"\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'role'\u001b[0m: \u001b[32m'assistant'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'stop_reason'\u001b[0m: \u001b[32m'end_of_turn'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'tool_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[32m'step_id'\u001b[0m: \u001b[32m'd459749c-f883-4d96-acb3-723164ed92b1'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'step_type'\u001b[0m: \u001b[32m'inference'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'turn_id'\u001b[0m: \u001b[32m'47645e95-f606-4bec-ad1e-cc471c78dcd2'\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m56\u001b[0m, \u001b[1;36m306242\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[32m'started_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m47\u001b[0m, \u001b[1;36m383443\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[32m'turn_id'\u001b[0m: \u001b[32m'47645e95-f606-4bec-ad1e-cc471c78dcd2'\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[32m'completed_at'\u001b[0m: \u001b[1;35mdatetime.datetime\u001b[0m\u001b[1m(\u001b[0m\u001b[1;36m2025\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m, \u001b[1;36m12\u001b[0m, \u001b[1;36m45\u001b[0m, \u001b[1;36m56\u001b[0m, \u001b[1;36m319286\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[32m'output_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" + } + ], + "source": [ + "orchestrator_session = client.agents.session.retrieve(session_id=orchestrator_agent.session_id, agent_id=orchestrator_agent.agent_id)\n", + "pprint(orchestrator_session.to_dict())\n", + "\n", + "for worker_type, worker in workers.items():\n", + " worker_session = client.agents.session.retrieve(session_id=worker.session_id, agent_id=worker.agent_id)\n", + " print(f\"Worker {worker_type} Session:\")\n", + " pprint(worker_session.to_dict())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "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 +} diff --git a/docs/notebooks/Llama_Stack_RAG_Lifecycle.ipynb b/docs/notebooks/Llama_Stack_RAG_Lifecycle.ipynb new file mode 100644 index 000000000..0d7b462cc --- /dev/null +++ b/docs/notebooks/Llama_Stack_RAG_Lifecycle.ipynb @@ -0,0 +1,1427 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Llama Stack RAG Lifecycle\n", + "\n", + "In this notebook, we will walk through the lifecycle of building and evaluating a RAG pipeline using Llama Stack. \n", + "\n", + "**Example: Torchtune Knowledge Agent** \n", + "\n", + "Throughout this notebook, we will build a knowledge agent that can answer questions about the Torchtune project. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 0. Setup" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Not in Google Colab environment\n" + ] + } + ], + "source": [ + "from llama_stack_client import LlamaStackClient\n", + "from llama_stack.distribution.library_client import LlamaStackAsLibraryClient\n", + "from llama_stack_client.types.agent_create_params import AgentConfig\n", + "from llama_stack_client.lib.agents.agent import Agent\n", + "from rich.pretty import pprint\n", + "import json\n", + "import uuid\n", + "from pydantic import BaseModel\n", + "import rich\n", + "import os\n", + "try:\n", + " from google.colab import userdata\n", + " os.environ['FIREWORKS_API_KEY'] = userdata.get('FIREWORKS_API_KEY')\n", + "except ImportError:\n", + " print(\"Not in Google Colab environment\")\n", + "\n", + "# client = LlamaStackAsLibraryClient(\"fireworks\", provider_data = {\"fireworks_api_key\": os.environ['FIREWORKS_API_KEY']})\n", + "# _ = client.initialize()\n", + "\n", + "# Uncomment to run on a hosted Llama Stack server\n", + "client = LlamaStackClient(base_url=\"http://localhost:8321\")\n", + "\n", + "MODEL_ID = \"meta-llama/Llama-3.3-70B-Instruct\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Simple Vanilla Agent\n", + "\n", + "First, we will build a simple vanilla agent without any access to external knowledge base or tools, and check how it performs on a couple of questions. \n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "# First, let's come up with a couple of examples to test the agent\n", + "examples = [\n", + " {\n", + " \"input_query\": \"What precision formats does torchtune support?\",\n", + " \"expected_answer\": \"Torchtune supports two data types for precision: fp32 (full-precision) which uses 4 bytes per model and optimizer parameter, and bfloat16 (half-precision) which uses 2 bytes per model and optimizer parameter.\"\n", + " },\n", + " {\n", + " \"input_query\": \"What does DoRA stand for in torchtune?\",\n", + " \"expected_answer\": \"Weight-Decomposed Low-Rank Adaptation\"\n", + " },\n", + " {\n", + " \"input_query\": \"How does the CPUOffloadOptimizer reduce GPU memory usage?\",\n", + " \"expected_answer\": \"The CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on CPU and performing optimizer steps on CPU. It can also optionally offload gradients to CPU by using offload_gradients=True\"\n", + " },\n", + " {\n", + " \"input_query\": \"How do I ensure only LoRA parameters are trainable when fine-tuning?\",\n", + " \"expected_answer\": \"You can set only LoRA parameters to trainable using torchtune's utility functions: first fetch all LoRA parameters with lora_params = get_adapter_params(lora_model), then set them as trainable with set_trainable_params(lora_model, lora_params). The LoRA recipe handles this automatically.\"\n", + " }\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Question: What precision formats does torchtune support?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m What precision formats does torchtune support?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: Torchtune supports the following precision formats:\n", + "\n", + "* Full precision (FP32)\n", + "* Mixed precision (FP16)\n", + "\n", + "It may also support other formats such as INT8 and BF16 in the future, but currently, it primarily focuses on FP32 \n", + "and FP16. \n", + "\n", + "Please note that the specific precision formats supported by Torchtune may change over time, and it's always best \n", + "to check the official documentation for the most up-to-date information.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m Torchtune supports the following precision formats:\n", + "\n", + "* Full precision \u001b[1m(\u001b[0mFP32\u001b[1m)\u001b[0m\n", + "* Mixed precision \u001b[1m(\u001b[0mFP16\u001b[1m)\u001b[0m\n", + "\n", + "It may also support other formats such as INT8 and BF16 in the future, but currently, it primarily focuses on FP32 \n", + "and FP16. \n", + "\n", + "Please note that the specific precision formats supported by Torchtune may change over time, and it's always best \n", + "to check the official documentation for the most up-to-date information.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: What does DoRA stand for in torchtune?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m What does DoRA stand for in torchtune?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: In the context of the Torchtune project, DoRA stands for \"Decoupled Optimizer for Reparameterized \n", + "Architectures\".\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m In the context of the Torchtune project, DoRA stands for \u001b[32m\"Decoupled Optimizer for Reparameterized \u001b[0m\n", + "\u001b[32mArchitectures\"\u001b[0m.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: How does the CPUOffloadOptimizer reduce GPU memory usage?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m How does the CPUOffloadOptimizer reduce GPU memory usage?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: The CPUOffloadOptimizer in the Torchtune project is designed to reduce GPU memory usage by offloading\n", + "certain computations from the GPU to the CPU. Here's how it works:\n", + "\n", + "1. **Identifying offloadable operations**: The optimizer analyzes the computation graph of the model and identifies\n", + "operations that can be offloaded from the GPU to the CPU. These operations are typically those that don't require \n", + "the massive parallel processing capabilities of the GPU, such as data preprocessing, encoding, or decoding.\n", + "2. **Offloading operations to CPU**: The optimizer offloads the identified operations to the CPU, which frees up \n", + "GPU memory and reduces the amount of data that needs to be transferred between the GPU and CPU.\n", + "3. **Minimizing data transfer**: The optimizer minimizes the amount of data that needs to be transferred between \n", + "the GPU and CPU by only transferring the necessary data for the offloaded operations. This reduces the overhead of \n", + "data transfer and helps to conserve GPU memory.\n", + "4. **Optimizing CPU-GPU synchronization**: The optimizer ensures that the CPU and GPU are properly synchronized, \n", + "which helps to prevent unnecessary memory allocations and deallocations on the GPU.\n", + "5. **Dynamic memory allocation**: The optimizer can dynamically allocate and deallocate memory on the GPU as \n", + "needed, which helps to reduce memory fragmentation and waste.\n", + "\n", + "By offloading computations to the CPU and minimizing data transfer, the CPUOffloadOptimizer can significantly \n", + "reduce GPU memory usage, which can lead to:\n", + "\n", + "* Improved model training and inference performance\n", + "* Increased batch sizes and throughput\n", + "* Reduced out-of-memory errors\n", + "* Better support for larger models and datasets\n", + "\n", + "Overall, the CPUOffloadOptimizer is a powerful tool for optimizing GPU memory usage in deep learning workloads, and\n", + "can help to improve the overall performance and efficiency of the Torchtune project.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m The CPUOffloadOptimizer in the Torchtune project is designed to reduce GPU memory usage by offloading\n", + "certain computations from the GPU to the CPU. Here's how it works:\n", + "\n", + "\u001b[1;36m1\u001b[0m. **Identifying offloadable operations**: The optimizer analyzes the computation graph of the model and identifies\n", + "operations that can be offloaded from the GPU to the CPU. These operations are typically those that don't require \n", + "the massive parallel processing capabilities of the GPU, such as data preprocessing, encoding, or decoding.\n", + "\u001b[1;36m2\u001b[0m. **Offloading operations to CPU**: The optimizer offloads the identified operations to the CPU, which frees up \n", + "GPU memory and reduces the amount of data that needs to be transferred between the GPU and CPU.\n", + "\u001b[1;36m3\u001b[0m. **Minimizing data transfer**: The optimizer minimizes the amount of data that needs to be transferred between \n", + "the GPU and CPU by only transferring the necessary data for the offloaded operations. This reduces the overhead of \n", + "data transfer and helps to conserve GPU memory.\n", + "\u001b[1;36m4\u001b[0m. **Optimizing CPU-GPU synchronization**: The optimizer ensures that the CPU and GPU are properly synchronized, \n", + "which helps to prevent unnecessary memory allocations and deallocations on the GPU.\n", + "\u001b[1;36m5\u001b[0m. **Dynamic memory allocation**: The optimizer can dynamically allocate and deallocate memory on the GPU as \n", + "needed, which helps to reduce memory fragmentation and waste.\n", + "\n", + "By offloading computations to the CPU and minimizing data transfer, the CPUOffloadOptimizer can significantly \n", + "reduce GPU memory usage, which can lead to:\n", + "\n", + "* Improved model training and inference performance\n", + "* Increased batch sizes and throughput\n", + "* Reduced out-of-memory errors\n", + "* Better support for larger models and datasets\n", + "\n", + "Overall, the CPUOffloadOptimizer is a powerful tool for optimizing GPU memory usage in deep learning workloads, and\n", + "can help to improve the overall performance and efficiency of the Torchtune project.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: How do I ensure only LoRA parameters are trainable when fine-tuning?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m How do I ensure only LoRA parameters are trainable when fine-tuning?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: To ensure only LoRA (Low-Rank Adaptation) parameters are trainable when fine-tuning a model with \n", + "Torchtune, you can follow these steps:\n", + "\n", + "1. **Freeze the original model weights**: Before fine-tuning, you need to freeze the original model weights to \n", + "prevent them from being updated during the fine-tuning process. You can do this by setting the `requires_grad` \n", + "attribute of the model parameters to `False`. This will prevent the original model weights from being updated.\n", + "\n", + "2. **Create LoRA parameters**: Create LoRA parameters for the layers you want to fine-tune. LoRA parameters are \n", + "typically added to the original model weights to adapt the model to the new task.\n", + "\n", + "3. **Set LoRA parameters as trainable**: Set the LoRA parameters as trainable by setting their `requires_grad` \n", + "attribute to `True`. This will allow the LoRA parameters to be updated during the fine-tuning process.\n", + "\n", + "Here's a sample code snippet to illustrate this:\n", + "```python\n", + "import torch\n", + "import torch.nn as nn\n", + "\n", + "# Assume 'model' is your pre-trained model\n", + "model = ...\n", + "\n", + "# Freeze the original model weights\n", + "for param in model.parameters():\n", + " param.requires_grad = False\n", + "\n", + "# Create LoRA parameters\n", + "lora_params = []\n", + "for name, module in model.named_modules():\n", + " if isinstance(module, nn.Linear): # or any other module you want to fine-tune\n", + " lora_param = nn.Parameter(torch.randn(module.weight.shape))\n", + " lora_params.append(lora_param)\n", + " setattr(model, f\"{name}_lora\", lora_param)\n", + "\n", + "# Set LoRA parameters as trainable\n", + "for param in lora_params:\n", + " param.requires_grad = True\n", + "\n", + "# Fine-tune the model with LoRA parameters\n", + "optimizer = torch.optim.Adam(lora_params, lr=1e-4)\n", + "```\n", + "By following these steps, you can ensure that only the LoRA parameters are trainable during fine-tuning, while \n", + "keeping the original model weights frozen.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m To ensure only LoRA \u001b[1m(\u001b[0mLow-Rank Adaptation\u001b[1m)\u001b[0m parameters are trainable when fine-tuning a model with \n", + "Torchtune, you can follow these steps:\n", + "\n", + "\u001b[1;36m1\u001b[0m. **Freeze the original model weights**: Before fine-tuning, you need to freeze the original model weights to \n", + "prevent them from being updated during the fine-tuning process. You can do this by setting the `requires_grad` \n", + "attribute of the model parameters to `\u001b[3;91mFalse\u001b[0m`. This will prevent the original model weights from being updated.\n", + "\n", + "\u001b[1;36m2\u001b[0m. **Create LoRA parameters**: Create LoRA parameters for the layers you want to fine-tune. LoRA parameters are \n", + "typically added to the original model weights to adapt the model to the new task.\n", + "\n", + "\u001b[1;36m3\u001b[0m. **Set LoRA parameters as trainable**: Set the LoRA parameters as trainable by setting their `requires_grad` \n", + "attribute to `\u001b[3;92mTrue\u001b[0m`. This will allow the LoRA parameters to be updated during the fine-tuning process.\n", + "\n", + "Here's a sample code snippet to illustrate this:\n", + "```python\n", + "import torch\n", + "import torch.nn as nn\n", + "\n", + "# Assume \u001b[32m'model'\u001b[0m is your pre-trained model\n", + "model = \u001b[33m...\u001b[0m\n", + "\n", + "# Freeze the original model weights\n", + "for param in \u001b[1;35mmodel.parameters\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m:\n", + " param.requires_grad = \u001b[3;91mFalse\u001b[0m\n", + "\n", + "# Create LoRA parameters\n", + "lora_params = \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", + "for name, module in \u001b[1;35mmodel.named_modules\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m:\n", + " if \u001b[1;35misinstance\u001b[0m\u001b[1m(\u001b[0mmodule, nn.Linear\u001b[1m)\u001b[0m: # or any other module you want to fine-tune\n", + " lora_param = \u001b[1;35mnn.Parameter\u001b[0m\u001b[1m(\u001b[0m\u001b[1;35mtorch.randn\u001b[0m\u001b[1m(\u001b[0mmodule.weight.shape\u001b[1m)\u001b[0m\u001b[1m)\u001b[0m\n", + " \u001b[1;35mlora_params.append\u001b[0m\u001b[1m(\u001b[0mlora_param\u001b[1m)\u001b[0m\n", + " \u001b[1;35msetattr\u001b[0m\u001b[1m(\u001b[0mmodel, f\"\u001b[1m{\u001b[0mname\u001b[1m}\u001b[0m_lora\", lora_param\u001b[1m)\u001b[0m\n", + "\n", + "# Set LoRA parameters as trainable\n", + "for param in lora_params:\n", + " param.requires_grad = \u001b[3;92mTrue\u001b[0m\n", + "\n", + "# Fine-tune the model with LoRA parameters\n", + "optimizer = \u001b[1;35mtorch.optim.Adam\u001b[0m\u001b[1m(\u001b[0mlora_params, \u001b[33mlr\u001b[0m=\u001b[1;36m1e\u001b[0m\u001b[1;36m-4\u001b[0m\u001b[1m)\u001b[0m\n", + "```\n", + "By following these steps, you can ensure that only the LoRA parameters are trainable during fine-tuning, while \n", + "keeping the original model weights frozen.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "simple_agent = Agent(client,\n", + " model=MODEL_ID, \n", + " instructions=\"You are a helpful assistant that can answer questions about the Torchtune project.\")\n", + "for example in examples:\n", + " simple_session_id = simple_agent.create_session(session_name=f\"simple_session_{uuid.uuid4()}\")\n", + " response = simple_agent.create_turn(\n", + " messages=[\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": example[\"input_query\"]\n", + " }\n", + " ],\n", + " session_id=simple_session_id,\n", + " stream=False\n", + " )\n", + " rich.print(f\"[bold cyan]Question:[/bold cyan] {example['input_query']}\")\n", + " rich.print(f\"[bold yellow]Agent Answer:[/bold yellow] {response.output_message.content}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.1 Evaluate Agent Responses\n", + "Let's gather up the agent's logs and evaluate the agent's performance. We can see that our agent's response is quite bad and off from the expected answer." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
ScoringScoreResponse(\n", + "β results={\n", + "β β 'braintrust::factuality': ScoringResult(\n", + "β β β aggregated_results={'average': {'average': 0.3}},\n", + "β β β score_rows=[\n", + "β β β β {\n", + "β β β β β 'score': 0.0,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'D',\n", + "β β β β β β 'rationale': '1. **Expert Answer**: The expert states that Torchtune supports two precision formats: fp32 (full-precision) and bfloat16 (half-precision).\\n\\n2. **Submitted Answer**: The submission mentions that Torchtune supports full precision (FP32) and mixed precision (FP16). It also speculates about potential future support for other formats like INT8 and BF16, but emphasizes the current focus on FP32 and FP16.\\n\\n3. **Comparison**:\\n - Both answers agree on the support for FP32.\\n - The expert mentions bfloat16 (BF16), while the submission mentions FP16 and speculates about BF16 in the future. This is a key difference as the expert confirms BF16 support, whereas the submission does not.\\n - The submission introduces FP16, which is not mentioned by the expert.\\n - The submission also speculates about future support for INT8 and BF16, which is not addressed by the expert.\\n\\n4. **Conclusion**: There is a disagreement between the submitted answer and the expert answer regarding the precision formats supported by Torchtune. The expert confirms BF16 support, while the submission does not, and instead mentions FP16, which the expert does not confirm. Therefore, the correct choice is (D).'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.0,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'D',\n", + "β β β β β β 'rationale': '1. The expert answer states that DoRA stands for \"Weight-Decomposed Low-Rank Adaptation\".\\n2. The submitted answer states that DoRA stands for \"Decoupled Optimizer for Reparameterized Architectures\".\\n3. The two answers provide completely different expansions for the acronym DoRA.\\n4. Since the expansions are different, there is a clear disagreement between the submitted answer and the expert answer regarding what DoRA stands for in the context of torchtune.\\n5. Therefore, the correct choice is (D) There is a disagreement between the submitted answer and the expert answer.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': '1. The expert answer states that the CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on the CPU and performing optimizer steps on the CPU. It also mentions the optional offloading of gradients to the CPU.\\n2. The submitted answer describes a broader mechanism of offloading computations from the GPU to the CPU, including identifying offloadable operations, minimizing data transfer, optimizing CPU-GPU synchronization, and dynamic memory allocation.\\n3. The submitted answer does not explicitly mention keeping optimizer states on the CPU or performing optimizer steps on the CPU, which are key points in the expert answer.\\n4. The submitted answer provides additional details about the process of offloading operations and its benefits, which are not mentioned in the expert answer.\\n5. The submitted answer does not conflict with the expert answer but rather expands on the concept of offloading to the CPU with additional mechanisms and benefits.\\n\\nBased on this analysis, the submitted answer is a superset of the expert answer and is fully consistent with it, as it includes all the information from the expert answer and adds more details.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': \"1. **Expert Answer Summary**: The expert answer provides a concise method to ensure only LoRA parameters are trainable by using torchtune's utility functions. It mentions fetching LoRA parameters with `get_adapter_params(lora_model)` and setting them as trainable with `set_trainable_params(lora_model, lora_params)`. It also notes that the LoRA recipe handles this automatically.\\n\\n2. **Submitted Answer Summary**: The submitted answer provides a more detailed explanation, including steps to freeze the original model weights, create LoRA parameters, and set them as trainable. It includes a code snippet demonstrating these steps, using PyTorch to manually set `requires_grad` attributes.\\n\\n3. **Comparison**:\\n - Both answers aim to ensure only LoRA parameters are trainable.\\n - The expert answer uses torchtune's utility functions, while the submitted answer provides a manual method using PyTorch.\\n - The submitted answer includes additional steps and a code example, which are not present in the expert answer.\\n\\n4. **Conclusion**: The submitted answer is a superset of the expert answer. It includes all the information from the expert answer (ensuring only LoRA parameters are trainable) and adds more detail on how to achieve this manually. There is no conflict between the two answers, as they both achieve the same goal using different methods.\\n\\nTherefore, the correct choice is (B) The submitted answer is a superset of the expert answer and is fully consistent with it.\"\n", + "β β β β β }\n", + "β β β β }\n", + "β β β ]\n", + "β β )\n", + "β }\n", + ")\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mScoringScoreResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[32m'braintrust::factuality'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'average'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'average'\u001b[0m: \u001b[1;36m0.3\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'D'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. **Expert Answer**: The expert states that Torchtune supports two precision formats: fp32 \u001b[0m\u001b[32m(\u001b[0m\u001b[32mfull-precision\u001b[0m\u001b[32m)\u001b[0m\u001b[32m and bfloat16 \u001b[0m\u001b[32m(\u001b[0m\u001b[32mhalf-precision\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n\\n2. **Submitted Answer**: The submission mentions that Torchtune supports full precision \u001b[0m\u001b[32m(\u001b[0m\u001b[32mFP32\u001b[0m\u001b[32m)\u001b[0m\u001b[32m and mixed precision \u001b[0m\u001b[32m(\u001b[0m\u001b[32mFP16\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. It also speculates about potential future support for other formats like INT8 and BF16, but emphasizes the current focus on FP32 and FP16.\\n\\n3. **Comparison**:\\n - Both answers agree on the support for FP32.\\n - The expert mentions bfloat16 \u001b[0m\u001b[32m(\u001b[0m\u001b[32mBF16\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, while the submission mentions FP16 and speculates about BF16 in the future. This is a key difference as the expert confirms BF16 support, whereas the submission does not.\\n - The submission introduces FP16, which is not mentioned by the expert.\\n - The submission also speculates about future support for INT8 and BF16, which is not addressed by the expert.\\n\\n4. **Conclusion**: There is a disagreement between the submitted answer and the expert answer regarding the precision formats supported by Torchtune. The expert confirms BF16 support, while the submission does not, and instead mentions FP16, which the expert does not confirm. Therefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mD\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'D'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. The expert answer states that DoRA stands for \"Weight-Decomposed Low-Rank Adaptation\".\\n2. The submitted answer states that DoRA stands for \"Decoupled Optimizer for Reparameterized Architectures\".\\n3. The two answers provide completely different expansions for the acronym DoRA.\\n4. Since the expansions are different, there is a clear disagreement between the submitted answer and the expert answer regarding what DoRA stands for in the context of torchtune.\\n5. Therefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mD\u001b[0m\u001b[32m)\u001b[0m\u001b[32m There is a disagreement between the submitted answer and the expert answer.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. The expert answer states that the CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on the CPU and performing optimizer steps on the CPU. It also mentions the optional offloading of gradients to the CPU.\\n2. The submitted answer describes a broader mechanism of offloading computations from the GPU to the CPU, including identifying offloadable operations, minimizing data transfer, optimizing CPU-GPU synchronization, and dynamic memory allocation.\\n3. The submitted answer does not explicitly mention keeping optimizer states on the CPU or performing optimizer steps on the CPU, which are key points in the expert answer.\\n4. The submitted answer provides additional details about the process of offloading operations and its benefits, which are not mentioned in the expert answer.\\n5. The submitted answer does not conflict with the expert answer but rather expands on the concept of offloading to the CPU with additional mechanisms and benefits.\\n\\nBased on this analysis, the submitted answer is a superset of the expert answer and is fully consistent with it, as it includes all the information from the expert answer and adds more details.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m\"1. **Expert Answer Summary**: The expert answer provides a concise method to ensure only LoRA parameters are trainable by using torchtune's utility functions. It mentions fetching LoRA parameters with `get_adapter_params\u001b[0m\u001b[32m(\u001b[0m\u001b[32mlora_model\u001b[0m\u001b[32m)\u001b[0m\u001b[32m` and setting them as trainable with `set_trainable_params\u001b[0m\u001b[32m(\u001b[0m\u001b[32mlora_model, lora_params\u001b[0m\u001b[32m)\u001b[0m\u001b[32m`. It also notes that the LoRA recipe handles this automatically.\\n\\n2. **Submitted Answer Summary**: The submitted answer provides a more detailed explanation, including steps to freeze the original model weights, create LoRA parameters, and set them as trainable. It includes a code snippet demonstrating these steps, using PyTorch to manually set `requires_grad` attributes.\\n\\n3. **Comparison**:\\n - Both answers aim to ensure only LoRA parameters are trainable.\\n - The expert answer uses torchtune's utility functions, while the submitted answer provides a manual method using PyTorch.\\n - The submitted answer includes additional steps and a code example, which are not present in the expert answer.\\n\\n4. **Conclusion**: The submitted answer is a superset of the expert answer. It includes all the information from the expert answer \u001b[0m\u001b[32m(\u001b[0m\u001b[32mensuring only LoRA parameters are trainable\u001b[0m\u001b[32m)\u001b[0m\u001b[32m and adds more detail on how to achieve this manually. There is no conflict between the two answers, as they both achieve the same goal using different methods.\\n\\nTherefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mB\u001b[0m\u001b[32m)\u001b[0m\u001b[32m The submitted answer is a superset of the expert answer and is fully consistent with it.\"\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[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" + } + ], + "source": [ + "eval_rows = []\n", + "for i, session_id in enumerate(simple_agent.sessions):\n", + " session_response = client.agents.session.retrieve(agent_id=simple_agent.agent_id, session_id=session_id)\n", + " for turn in session_response.turns:\n", + " eval_rows.append({\n", + " \"input_query\": examples[i][\"input_query\"],\n", + " \"expected_answer\": examples[i][\"expected_answer\"],\n", + " \"generated_answer\": turn.output_message.content,\n", + " })\n", + "\n", + "scoring_params = {\n", + " \"braintrust::factuality\": None,\n", + "}\n", + "scoring_response = client.scoring.score(\n", + " input_rows=eval_rows,\n", + " scoring_functions=scoring_params,\n", + ")\n", + "pprint(scoring_response)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2. Search Agent\n", + "\n", + "Now, let's see how we can improve the agent's performance by adding a search tool." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Question: What precision formats does torchtune support?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m What precision formats does torchtune support?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: Torchtune supports the following precision formats:\n", + "\n", + "* bf16 (16-bit floating-point format)\n", + "* fp32 (32-bit floating-point format, also known as \"full-precision\")\n", + "\n", + "It's worth noting that torchtune also provides support for mixed-precision techniques, which allow for the use of \n", + "different precision formats for different parts of the model or during different stages of training.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m Torchtune supports the following precision formats:\n", + "\n", + "* bf16 \u001b[1m(\u001b[0m\u001b[1;36m16\u001b[0m-bit floating-point format\u001b[1m)\u001b[0m\n", + "* fp32 \u001b[1m(\u001b[0m\u001b[1;36m32\u001b[0m-bit floating-point format, also known as \u001b[32m\"full-precision\"\u001b[0m\u001b[1m)\u001b[0m\n", + "\n", + "It's worth noting that torchtune also provides support for mixed-precision techniques, which allow for the use of \n", + "different precision formats for different parts of the model or during different stages of training.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: What does DoRA stand for in torchtune?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m What does DoRA stand for in torchtune?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: DoRA stands for \"Decoupled Orthogonal Random Adaptation\" in torchtune.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m DoRA stands for \u001b[32m\"Decoupled Orthogonal Random Adaptation\"\u001b[0m in torchtune.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: How does the CPUOffloadOptimizer reduce GPU memory usage?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m How does the CPUOffloadOptimizer reduce GPU memory usage?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: The CPUOffloadOptimizer reduces GPU memory usage by offloading gradients and trainable parameters to \n", + "the CPU, allowing for more efficient use of GPU memory. This can be achieved by setting `offload_gradients=True` in\n", + "the CPUOffloadOptimizer, which frees gradients once device-to-host transfer finishes. Additionally, using paged \n", + "Adam with `optimizer_in_bwd=True` can also help reduce memory usage. However, it's important to note that the \n", + "actual memory usage may vary depending on the specific use case and model architecture.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m The CPUOffloadOptimizer reduces GPU memory usage by offloading gradients and trainable parameters to \n", + "the CPU, allowing for more efficient use of GPU memory. This can be achieved by setting `\u001b[33moffload_gradients\u001b[0m=\u001b[3;92mTrue\u001b[0m` in\n", + "the CPUOffloadOptimizer, which frees gradients once device-to-host transfer finishes. Additionally, using paged \n", + "Adam with `\u001b[33moptimizer_in_bwd\u001b[0m=\u001b[3;92mTrue\u001b[0m` can also help reduce memory usage. However, it's important to note that the \n", + "actual memory usage may vary depending on the specific use case and model architecture.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: How do I ensure only LoRA parameters are trainable when fine-tuning?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m How do I ensure only LoRA parameters are trainable when fine-tuning?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: To ensure only LoRA parameters are trainable when fine-tuning, you can use the `set_trainable_params`\n", + "function from the `torchtune.modules.peft.peft_utils` module. This function allows you to specify which parameters \n", + "to make trainable, and you can use it to set only the LoRA parameters as trainable.\n", + "\n", + "Here is an example of how to do this:\n", + "```\n", + "import torch\n", + "from torchtune.models.llama2 import llama2_7b, lora_llama2_7b\n", + "from torchtune.modules.peft.peft_utils import get_adapter_params, set_trainable_params\n", + "\n", + "# Load the model and adapter\n", + "model = llama2_7b()\n", + "adapter = lora_llama2_7b()\n", + "\n", + "# Get the adapter parameters\n", + "adapter_params = get_adapter_params(adapter)\n", + "\n", + "# Set only the adapter parameters as trainable\n", + "set_trainable_params(model, adapter_params)\n", + "```\n", + "This code loads the LLaMA-2 model and the LoRA adapter, gets the adapter parameters, and then sets only those \n", + "parameters as trainable using the `set_trainable_params` function. This ensures that only the LoRA parameters are \n", + "updated during fine-tuning, while the rest of the model remains frozen.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m To ensure only LoRA parameters are trainable when fine-tuning, you can use the `set_trainable_params`\n", + "function from the `torchtune.modules.peft.peft_utils` module. This function allows you to specify which parameters \n", + "to make trainable, and you can use it to set only the LoRA parameters as trainable.\n", + "\n", + "Here is an example of how to do this:\n", + "```\n", + "import torch\n", + "from torchtune.models.llama2 import llama2_7b, lora_llama2_7b\n", + "from torchtune.modules.peft.peft_utils import get_adapter_params, set_trainable_params\n", + "\n", + "# Load the model and adapter\n", + "model = \u001b[1;35mllama2_7b\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m\n", + "adapter = \u001b[1;35mlora_llama2_7b\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m\n", + "\n", + "# Get the adapter parameters\n", + "adapter_params = \u001b[1;35mget_adapter_params\u001b[0m\u001b[1m(\u001b[0madapter\u001b[1m)\u001b[0m\n", + "\n", + "# Set only the adapter parameters as trainable\n", + "\u001b[1;35mset_trainable_params\u001b[0m\u001b[1m(\u001b[0mmodel, adapter_params\u001b[1m)\u001b[0m\n", + "```\n", + "This code loads the LLaMA-\u001b[1;36m2\u001b[0m model and the LoRA adapter, gets the adapter parameters, and then sets only those \n", + "parameters as trainable using the `set_trainable_params` function. This ensures that only the LoRA parameters are \n", + "updated during fine-tuning, while the rest of the model remains frozen.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "search_agent = Agent(client, \n", + " model=MODEL_ID,\n", + " instructions=\"You are a helpful assistant that can answer questions about the Torchtune project. You should always use the search tool to answer questions.\",\n", + " tools=[\"builtin::websearch\"])\n", + "for example in examples:\n", + " search_session_id = search_agent.create_session(session_name=f\"search_session_{uuid.uuid4()}\")\n", + " response = search_agent.create_turn(\n", + " messages=[\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": example[\"input_query\"]\n", + " }\n", + " ],\n", + " session_id=search_session_id,\n", + " stream=False\n", + " )\n", + " rich.print(f\"[bold cyan]Question:[/bold cyan] {example['input_query']}\")\n", + " rich.print(f\"[bold yellow]Agent Answer:[/bold yellow] {response.output_message.content}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2.1 Evaluate Agent Responses\n", + "\n", + "We can see that with a search tool, the agent's performance is much better, and have less hallucinations. " + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
ScoringScoreResponse(\n", + "β results={\n", + "β β 'braintrust::factuality': ScoringResult(\n", + "β β β aggregated_results={'average': {'average': 0.44999999999999996}},\n", + "β β β score_rows=[\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': '1. **Expert Answer Details**: The expert answer states that Torchtune supports two precision formats: fp32 (full-precision) and bfloat16 (half-precision).\\n\\n2. **Submitted Answer Details**: The submitted answer mentions two precision formats: bf16 (16-bit floating-point format) and fp32 (32-bit floating-point format, also known as \"full-precision\"). It also adds that Torchtune supports mixed-precision techniques.\\n\\n3. **Comparison of Precision Formats**:\\n - The expert answer uses \"bfloat16\" while the submitted answer uses \"bf16\". These are equivalent terms, as \"bf16\" is a common abbreviation for \"bfloat16\".\\n - Both answers mention \"fp32\" as a supported precision format.\\n\\n4. **Additional Information in Submission**: The submitted answer includes additional information about mixed-precision techniques, which is not mentioned in the expert answer.\\n\\n5. **Consistency Check**: The submitted answer includes all the information from the expert answer and adds more details about mixed-precision techniques. There is no conflict between the two answers.\\n\\nBased on the above analysis, the submitted answer is a superset of the expert answer and is fully consistent with it.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.0,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'D',\n", + "β β β β β β 'rationale': '1. The expert answer states that DoRA stands for \"Weight-Decomposed Low-Rank Adaptation.\"\\n2. The submitted answer states that DoRA stands for \"Decoupled Orthogonal Random Adaptation.\"\\n3. The two answers provide completely different expansions for the acronym DoRA.\\n4. Since the expansions are different, there is a clear disagreement between the submitted answer and the expert answer regarding what DoRA stands for in torchtune.\\n5. Therefore, the correct choice is (D) There is a disagreement between the submitted answer and the expert answer.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': '1. **Expert Answer Analysis**: The expert answer states that the CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on the CPU and performing optimizer steps on the CPU. It also mentions the optional offloading of gradients to the CPU by setting `offload_gradients=True`.\\n\\n2. **Submitted Answer Analysis**: The submitted answer mentions offloading gradients and trainable parameters to the CPU, which allows for more efficient use of GPU memory. It specifies the use of `offload_gradients=True` to free gradients after device-to-host transfer. Additionally, it introduces the concept of using paged Adam with `optimizer_in_bwd=True` to help reduce memory usage. It also notes that actual memory usage may vary depending on the use case and model architecture.\\n\\n3. **Comparison**:\\n - Both answers mention offloading gradients to the CPU using `offload_gradients=True`.\\n - The expert answer focuses on keeping optimizer states and performing optimizer steps on the CPU, while the submitted answer expands on this by mentioning trainable parameters and the use of paged Adam.\\n - The submitted answer provides additional context about memory usage variability and the use of paged Adam, which is not mentioned in the expert answer.\\n\\n4. **Conclusion**: The submitted answer is a superset of the expert answer as it includes all the information from the expert answer and adds more details about trainable parameters, paged Adam, and memory usage variability. There is no conflict between the two answers, and the additional information in the submitted answer is consistent with the expert answer.\\n\\nTherefore, the correct choice is (B) The submitted answer is a superset of the expert answer and is fully consistent with it.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': \"1. **Expert Answer Analysis**: The expert answer provides a method to ensure only LoRA parameters are trainable by using torchtune's utility functions. It mentions fetching LoRA parameters with `get_adapter_params(lora_model)` and setting them as trainable with `set_trainable_params(lora_model, lora_params)`. It also notes that the LoRA recipe handles this automatically.\\n\\n2. **Submitted Answer Analysis**: The submitted answer provides a detailed example of how to ensure only LoRA parameters are trainable. It uses the `set_trainable_params` function from `torchtune.modules.peft.peft_utils` and provides a code example that includes loading a model and adapter, fetching adapter parameters, and setting them as trainable.\\n\\n3. **Comparison**:\\n - Both answers mention the use of `set_trainable_params` to set LoRA parameters as trainable.\\n - Both answers involve fetching LoRA parameters using a function (`get_adapter_params`).\\n - The submitted answer provides additional context by including a code example and specifying the module path for the functions used.\\n - The expert answer mentions that the LoRA recipe handles this automatically, which is not explicitly stated in the submitted answer.\\n\\n4. **Conclusion**: The submitted answer is a superset of the expert answer. It includes all the information from the expert answer and adds more detail, such as a code example and specific module paths. There is no conflict between the two answers, and the additional information in the submitted answer is consistent with the expert answer.\"\n", + "β β β β β }\n", + "β β β β }\n", + "β β β ]\n", + "β β )\n", + "β }\n", + ")\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mScoringScoreResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[32m'braintrust::factuality'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'average'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'average'\u001b[0m: \u001b[1;36m0.44999999999999996\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. **Expert Answer Details**: The expert answer states that Torchtune supports two precision formats: fp32 \u001b[0m\u001b[32m(\u001b[0m\u001b[32mfull-precision\u001b[0m\u001b[32m)\u001b[0m\u001b[32m and bfloat16 \u001b[0m\u001b[32m(\u001b[0m\u001b[32mhalf-precision\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n\\n2. **Submitted Answer Details**: The submitted answer mentions two precision formats: bf16 \u001b[0m\u001b[32m(\u001b[0m\u001b[32m16-bit floating-point format\u001b[0m\u001b[32m)\u001b[0m\u001b[32m and fp32 \u001b[0m\u001b[32m(\u001b[0m\u001b[32m32-bit floating-point format, also known as \"full-precision\"\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. It also adds that Torchtune supports mixed-precision techniques.\\n\\n3. **Comparison of Precision Formats**:\\n - The expert answer uses \"bfloat16\" while the submitted answer uses \"bf16\". These are equivalent terms, as \"bf16\" is a common abbreviation for \"bfloat16\".\\n - Both answers mention \"fp32\" as a supported precision format.\\n\\n4. **Additional Information in Submission**: The submitted answer includes additional information about mixed-precision techniques, which is not mentioned in the expert answer.\\n\\n5. **Consistency Check**: The submitted answer includes all the information from the expert answer and adds more details about mixed-precision techniques. There is no conflict between the two answers.\\n\\nBased on the above analysis, the submitted answer is a superset of the expert answer and is fully consistent with it.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'D'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. The expert answer states that DoRA stands for \"Weight-Decomposed Low-Rank Adaptation.\"\\n2. The submitted answer states that DoRA stands for \"Decoupled Orthogonal Random Adaptation.\"\\n3. The two answers provide completely different expansions for the acronym DoRA.\\n4. Since the expansions are different, there is a clear disagreement between the submitted answer and the expert answer regarding what DoRA stands for in torchtune.\\n5. Therefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mD\u001b[0m\u001b[32m)\u001b[0m\u001b[32m There is a disagreement between the submitted answer and the expert answer.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. **Expert Answer Analysis**: The expert answer states that the CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on the CPU and performing optimizer steps on the CPU. It also mentions the optional offloading of gradients to the CPU by setting `\u001b[0m\u001b[32moffload_gradients\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m`.\\n\\n2. **Submitted Answer Analysis**: The submitted answer mentions offloading gradients and trainable parameters to the CPU, which allows for more efficient use of GPU memory. It specifies the use of `\u001b[0m\u001b[32moffload_gradients\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m` to free gradients after device-to-host transfer. Additionally, it introduces the concept of using paged Adam with `\u001b[0m\u001b[32moptimizer_in_bwd\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m` to help reduce memory usage. It also notes that actual memory usage may vary depending on the use case and model architecture.\\n\\n3. **Comparison**:\\n - Both answers mention offloading gradients to the CPU using `\u001b[0m\u001b[32moffload_gradients\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m`.\\n - The expert answer focuses on keeping optimizer states and performing optimizer steps on the CPU, while the submitted answer expands on this by mentioning trainable parameters and the use of paged Adam.\\n - The submitted answer provides additional context about memory usage variability and the use of paged Adam, which is not mentioned in the expert answer.\\n\\n4. **Conclusion**: The submitted answer is a superset of the expert answer as it includes all the information from the expert answer and adds more details about trainable parameters, paged Adam, and memory usage variability. There is no conflict between the two answers, and the additional information in the submitted answer is consistent with the expert answer.\\n\\nTherefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mB\u001b[0m\u001b[32m)\u001b[0m\u001b[32m The submitted answer is a superset of the expert answer and is fully consistent with it.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m\"1. **Expert Answer Analysis**: The expert answer provides a method to ensure only LoRA parameters are trainable by using torchtune's utility functions. It mentions fetching LoRA parameters with `get_adapter_params\u001b[0m\u001b[32m(\u001b[0m\u001b[32mlora_model\u001b[0m\u001b[32m)\u001b[0m\u001b[32m` and setting them as trainable with `set_trainable_params\u001b[0m\u001b[32m(\u001b[0m\u001b[32mlora_model, lora_params\u001b[0m\u001b[32m)\u001b[0m\u001b[32m`. It also notes that the LoRA recipe handles this automatically.\\n\\n2. **Submitted Answer Analysis**: The submitted answer provides a detailed example of how to ensure only LoRA parameters are trainable. It uses the `set_trainable_params` function from `torchtune.modules.peft.peft_utils` and provides a code example that includes loading a model and adapter, fetching adapter parameters, and setting them as trainable.\\n\\n3. **Comparison**:\\n - Both answers mention the use of `set_trainable_params` to set LoRA parameters as trainable.\\n - Both answers involve fetching LoRA parameters using a function \u001b[0m\u001b[32m(\u001b[0m\u001b[32m`get_adapter_params`\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\n - The submitted answer provides additional context by including a code example and specifying the module path for the functions used.\\n - The expert answer mentions that the LoRA recipe handles this automatically, which is not explicitly stated in the submitted answer.\\n\\n4. **Conclusion**: The submitted answer is a superset of the expert answer. It includes all the information from the expert answer and adds more detail, such as a code example and specific module paths. There is no conflict between the two answers, and the additional information in the submitted answer is consistent with the expert answer.\"\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[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" + } + ], + "source": [ + "eval_rows = []\n", + "for i, session_id in enumerate(search_agent.sessions):\n", + " session_response = client.agents.session.retrieve(agent_id=search_agent.agent_id, session_id=session_id)\n", + " for turn in session_response.turns:\n", + " eval_rows.append({\n", + " \"input_query\": examples[i][\"input_query\"],\n", + " \"expected_answer\": examples[i][\"expected_answer\"],\n", + " \"generated_answer\": turn.output_message.content,\n", + " })\n", + "\n", + "scoring_params = {\n", + " \"braintrust::factuality\": None,\n", + "}\n", + "scoring_response = client.scoring.score(\n", + " input_rows=eval_rows,\n", + " scoring_functions=scoring_params,\n", + ")\n", + "pprint(scoring_response)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 3. RAG Agent\n", + "\n", + "Now, let's see how we can improve the agent's performance by adding a RAG tool that explicitly retrieves information from Torchtune's documentation. " + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [ + "from llama_stack_client.types import Document\n", + "urls = [\n", + " \"memory_optimizations.rst\",\n", + " \"chat.rst\",\n", + " \"llama3.rst\",\n", + " \"datasets.rst\",\n", + " \"qat_finetune.rst\",\n", + " \"lora_finetune.rst\",\n", + "]\n", + "documents = [\n", + " Document(\n", + " document_id=f\"num-{i}\",\n", + " content=f\"https://raw.githubusercontent.com/pytorch/torchtune/main/docs/source/tutorials/{url}\",\n", + " mime_type=\"text/plain\",\n", + " metadata={},\n", + " )\n", + " for i, url in enumerate(urls)\n", + "]\n", + "\n", + "vector_providers = [\n", + " provider for provider in client.providers.list() if provider.api == \"vector_io\"\n", + "]\n", + "selected_vector_provider = vector_providers[0]\n", + "vector_db_id = f\"test_vector_db_{uuid.uuid4()}\"\n", + "client.vector_dbs.register(\n", + " vector_db_id=vector_db_id,\n", + " embedding_model=\"all-MiniLM-L6-v2\",\n", + " embedding_dimension=384,\n", + " provider_id=selected_vector_provider.provider_id,\n", + ")\n", + "\n", + "client.tool_runtime.rag_tool.insert(\n", + " documents=documents,\n", + " vector_db_id=vector_db_id,\n", + " chunk_size_in_tokens=512,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Question: What precision formats does torchtune support?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m What precision formats does torchtune support?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: Torchtune supports the following precision formats:\n", + "\n", + "* bfloat16 (half-precision)\n", + "* fp32 (full-precision)\n", + "* int8 (integer 8-bit)\n", + "* int4 (integer 4-bit)\n", + "\n", + "Note that mixed-precision training is not currently supported in torchtune.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m Torchtune supports the following precision formats:\n", + "\n", + "* bfloat16 \u001b[1m(\u001b[0mhalf-precision\u001b[1m)\u001b[0m\n", + "* fp32 \u001b[1m(\u001b[0mfull-precision\u001b[1m)\u001b[0m\n", + "* int8 \u001b[1m(\u001b[0minteger \u001b[1;36m8\u001b[0m-bit\u001b[1m)\u001b[0m\n", + "* int4 \u001b[1m(\u001b[0minteger \u001b[1;36m4\u001b[0m-bit\u001b[1m)\u001b[0m\n", + "\n", + "Note that mixed-precision training is not currently supported in torchtune.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: What does DoRA stand for in torchtune?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m What does DoRA stand for in torchtune?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: DoRA stands for \"Decoupled Orthogonal Random Axes\" in the context of the Torchtune project.\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m DoRA stands for \u001b[32m\"Decoupled Orthogonal Random Axes\"\u001b[0m in the context of the Torchtune project.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Question: How does the CPUOffloadOptimizer reduce GPU memory usage?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m How does the CPUOffloadOptimizer reduce GPU memory usage?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: The CPUOffloadOptimizer reduces GPU memory usage by offloading optimizer states and gradients to CPU,\n",
+ "thus reducing the memory usage on the GPU. This is especially useful when training large models or when using \n",
+ "stateful optimizers, as it can significantly reduce the memory requirements. However, it may come at the cost of \n",
+ "increased CPU RAM usage and potentially slower training speeds.\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;33mAgent Answer:\u001b[0m The CPUOffloadOptimizer reduces GPU memory usage by offloading optimizer states and gradients to CPU,\n",
+ "thus reducing the memory usage on the GPU. This is especially useful when training large models or when using \n",
+ "stateful optimizers, as it can significantly reduce the memory requirements. However, it may come at the cost of \n",
+ "increased CPU RAM usage and potentially slower training speeds.\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Question: How do I ensure only LoRA parameters are trainable when fine-tuning?\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;36mQuestion:\u001b[0m How do I ensure only LoRA parameters are trainable when fine-tuning?\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Agent Answer: To ensure only LoRA parameters are trainable when fine-tuning, you can use the `get_adapter_params` \n", + "and `set_trainable_params` functions from `torchtune.modules.peft.peft_utils`. \n", + "\n", + "Here is how to do it:\n", + "\n", + "```python\n", + "from torchtune.modules.peft.peft_utils import get_adapter_params, set_trainable_params\n", + "\n", + "# Fetch all params from the model that are associated with LoRA.\n", + "lora_params = get_adapter_params(lora_model)\n", + "\n", + "# Set requires_grad=True on lora_params, and requires_grad=False on all others.\n", + "set_trainable_params(lora_model, lora_params)\n", + "```\n", + "\n" + ], + "text/plain": [ + "\u001b[1;33mAgent Answer:\u001b[0m To ensure only LoRA parameters are trainable when fine-tuning, you can use the `get_adapter_params` \n", + "and `set_trainable_params` functions from `torchtune.modules.peft.peft_utils`. \n", + "\n", + "Here is how to do it:\n", + "\n", + "```python\n", + "from torchtune.modules.peft.peft_utils import get_adapter_params, set_trainable_params\n", + "\n", + "# Fetch all params from the model that are associated with LoRA.\n", + "lora_params = \u001b[1;35mget_adapter_params\u001b[0m\u001b[1m(\u001b[0mlora_model\u001b[1m)\u001b[0m\n", + "\n", + "# Set \u001b[33mrequires_grad\u001b[0m=\u001b[3;92mTrue\u001b[0m on lora_params, and \u001b[33mrequires_grad\u001b[0m=\u001b[3;91mFalse\u001b[0m on all others.\n", + "\u001b[1;35mset_trainable_params\u001b[0m\u001b[1m(\u001b[0mlora_model, lora_params\u001b[1m)\u001b[0m\n", + "```\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "rag_agent = Agent(\n", + " client,\n", + " model=MODEL_ID,\n", + " instructions=\"You are a helpful assistant that can answer questions about the Torchtune project. You should always use the RAG tool to answer questions.\",\n", + " tools=[{\n", + " \"name\": \"builtin::rag\",\n", + " \"args\": {\"vector_db_ids\": [vector_db_id]},\n", + " }],\n", + ")\n", + "\n", + "for example in examples:\n", + " rag_session_id = rag_agent.create_session(session_name=f\"rag_session_{uuid.uuid4()}\")\n", + " response = rag_agent.create_turn(\n", + " messages=[\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": example[\"input_query\"]\n", + " }\n", + " ],\n", + " session_id=rag_session_id,\n", + " stream=False\n", + " )\n", + " rich.print(f\"[bold cyan]Question:[/bold cyan] {example['input_query']}\")\n", + " rich.print(f\"[bold yellow]Agent Answer:[/bold yellow] {response.output_message.content}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
ScoringScoreResponse(\n", + "β results={\n", + "β β 'braintrust::factuality': ScoringResult(\n", + "β β β aggregated_results={'average': {'average': 0.3}},\n", + "β β β score_rows=[\n", + "β β β β {\n", + "β β β β β 'score': 0.0,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'D',\n", + "β β β β β β 'rationale': '1. The expert answer states that Torchtune supports two precision formats: fp32 and bfloat16.\\n2. The submitted answer lists four precision formats: bfloat16, fp32, int8, and int4.\\n3. The submitted answer includes the two formats mentioned by the expert (bfloat16 and fp32), but also adds int8 and int4, which are not mentioned by the expert.\\n4. The submitted answer also states that mixed-precision training is not supported, which is not addressed in the expert answer.\\n5. Since the submitted answer includes additional precision formats (int8 and int4) that are not mentioned by the expert, there is a factual disagreement between the two answers regarding the supported precision formats.\\n6. Therefore, the correct choice is (D) There is a disagreement between the submitted answer and the expert answer.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.0,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'D',\n", + "β β β β β β 'rationale': '1. The expert answer states that DoRA stands for \"Weight-Decomposed Low-Rank Adaptation.\"\\n2. The submitted answer states that DoRA stands for \"Decoupled Orthogonal Random Axes.\"\\n3. The two answers provide completely different expansions for the acronym DoRA.\\n4. Since the expansions are different, there is a clear disagreement between the submitted answer and the expert answer.\\n5. Therefore, the correct choice is (D) There is a disagreement between the submitted answer and the expert answer.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': '1. The expert answer states that the CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on CPU and performing optimizer steps on CPU. It also mentions the optional offloading of gradients to CPU using offload_gradients=True.\\n2. The submitted answer states that the CPUOffloadOptimizer reduces GPU memory usage by offloading optimizer states and gradients to CPU. It also mentions that this is useful for large models or stateful optimizers and notes potential downsides like increased CPU RAM usage and slower training speeds.\\n3. The submitted answer includes all the points mentioned in the expert answer: offloading optimizer states and optionally gradients to CPU.\\n4. Additionally, the submitted answer provides extra context about the usefulness for large models and potential downsides, which are not mentioned in the expert answer.\\n5. There is no factual disagreement between the two answers; the submitted answer simply provides more information.\\n\\nBased on this analysis, the submitted answer is a superset of the expert answer and is fully consistent with it.'\n", + "β β β β β }\n", + "β β β β },\n", + "β β β β {\n", + "β β β β β 'score': 0.6,\n", + "β β β β β 'metadata': {\n", + "β β β β β β 'choice': 'B',\n", + "β β β β β β 'rationale': \"1. **Identify the core content of both answers:**\\n - The expert answer explains how to set only LoRA parameters as trainable using torchtune's utility functions by fetching all LoRA parameters with `get_adapter_params(lora_model)` and setting them as trainable with `set_trainable_params(lora_model, lora_params)`. It also mentions that the LoRA recipe handles this automatically.\\n - The submitted answer provides a similar explanation, detailing the use of `get_adapter_params` and `set_trainable_params` from `torchtune.modules.peft.peft_utils` to ensure only LoRA parameters are trainable. It includes a code snippet demonstrating the process.\\n\\n2. **Compare the factual content:**\\n - Both answers describe the same process of fetching LoRA parameters and setting them as trainable using the same functions.\\n - The submitted answer includes additional details such as the import statement and a code snippet, which are not present in the expert answer.\\n - The expert answer mentions that the LoRA recipe handles this automatically, which is not mentioned in the submission.\\n\\n3. **Determine the relationship between the answers:**\\n - The submitted answer is a superset of the expert answer because it includes all the information provided by the expert and adds more details, such as the import statement and code snippet.\\n - There is no conflict between the two answers; the submission expands on the expert's explanation.\\n\\nBased on this analysis, the submitted answer is a superset of the expert answer and is fully consistent with it.\"\n", + "β β β β β }\n", + "β β β β }\n", + "β β β ]\n", + "β β )\n", + "β }\n", + ")\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mScoringScoreResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β \u001b[0m\u001b[32m'braintrust::factuality'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'average'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'average'\u001b[0m: \u001b[1;36m0.3\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32mβ β β \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'D'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. The expert answer states that Torchtune supports two precision formats: fp32 and bfloat16.\\n2. The submitted answer lists four precision formats: bfloat16, fp32, int8, and int4.\\n3. The submitted answer includes the two formats mentioned by the expert \u001b[0m\u001b[32m(\u001b[0m\u001b[32mbfloat16 and fp32\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, but also adds int8 and int4, which are not mentioned by the expert.\\n4. The submitted answer also states that mixed-precision training is not supported, which is not addressed in the expert answer.\\n5. Since the submitted answer includes additional precision formats \u001b[0m\u001b[32m(\u001b[0m\u001b[32mint8 and int4\u001b[0m\u001b[32m)\u001b[0m\u001b[32m that are not mentioned by the expert, there is a factual disagreement between the two answers regarding the supported precision formats.\\n6. Therefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mD\u001b[0m\u001b[32m)\u001b[0m\u001b[32m There is a disagreement between the submitted answer and the expert answer.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'D'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. The expert answer states that DoRA stands for \"Weight-Decomposed Low-Rank Adaptation.\"\\n2. The submitted answer states that DoRA stands for \"Decoupled Orthogonal Random Axes.\"\\n3. The two answers provide completely different expansions for the acronym DoRA.\\n4. Since the expansions are different, there is a clear disagreement between the submitted answer and the expert answer.\\n5. Therefore, the correct choice is \u001b[0m\u001b[32m(\u001b[0m\u001b[32mD\u001b[0m\u001b[32m)\u001b[0m\u001b[32m There is a disagreement between the submitted answer and the expert answer.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m'1. The expert answer states that the CPUOffloadOptimizer reduces GPU memory usage by keeping optimizer states on CPU and performing optimizer steps on CPU. It also mentions the optional offloading of gradients to CPU using \u001b[0m\u001b[32moffload_gradients\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m.\\n2. The submitted answer states that the CPUOffloadOptimizer reduces GPU memory usage by offloading optimizer states and gradients to CPU. It also mentions that this is useful for large models or stateful optimizers and notes potential downsides like increased CPU RAM usage and slower training speeds.\\n3. The submitted answer includes all the points mentioned in the expert answer: offloading optimizer states and optionally gradients to CPU.\\n4. Additionally, the submitted answer provides extra context about the usefulness for large models and potential downsides, which are not mentioned in the expert answer.\\n5. There is no factual disagreement between the two answers; the submitted answer simply provides more information.\\n\\nBased on this analysis, the submitted answer is a superset of the expert answer and is fully consistent with it.'\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[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.6\u001b[0m,\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'choice'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[32m'rationale'\u001b[0m: \u001b[32m\"1. **Identify the core content of both answers:**\\n - The expert answer explains how to set only LoRA parameters as trainable using torchtune's utility functions by fetching all LoRA parameters with `get_adapter_params\u001b[0m\u001b[32m(\u001b[0m\u001b[32mlora_model\u001b[0m\u001b[32m)\u001b[0m\u001b[32m` and setting them as trainable with `set_trainable_params\u001b[0m\u001b[32m(\u001b[0m\u001b[32mlora_model, lora_params\u001b[0m\u001b[32m)\u001b[0m\u001b[32m`. It also mentions that the LoRA recipe handles this automatically.\\n - The submitted answer provides a similar explanation, detailing the use of `get_adapter_params` and `set_trainable_params` from `torchtune.modules.peft.peft_utils` to ensure only LoRA parameters are trainable. It includes a code snippet demonstrating the process.\\n\\n2. **Compare the factual content:**\\n - Both answers describe the same process of fetching LoRA parameters and setting them as trainable using the same functions.\\n - The submitted answer includes additional details such as the import statement and a code snippet, which are not present in the expert answer.\\n - The expert answer mentions that the LoRA recipe handles this automatically, which is not mentioned in the submission.\\n\\n3. **Determine the relationship between the answers:**\\n - The submitted answer is a superset of the expert answer because it includes all the information provided by the expert and adds more details, such as the import statement and code snippet.\\n - There is no conflict between the two answers; the submission expands on the expert's explanation.\\n\\nBased on this analysis, the submitted answer is a superset of the expert answer and is fully consistent with it.\"\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[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" + } + ], + "source": [ + "eval_rows = []\n", + "for i, session_id in enumerate(rag_agent.sessions):\n", + " session_response = client.agents.session.retrieve(agent_id=rag_agent.agent_id, session_id=session_id)\n", + " for turn in session_response.turns:\n", + " eval_rows.append({\n", + " \"input_query\": examples[i][\"input_query\"],\n", + " \"expected_answer\": examples[i][\"expected_answer\"],\n", + " \"generated_answer\": turn.output_message.content,\n", + " })\n", + "\n", + "scoring_params = {\n", + " \"braintrust::factuality\": None,\n", + "}\n", + "scoring_response = client.scoring.score(\n", + " input_rows=eval_rows,\n", + " scoring_functions=scoring_params,\n", + ")\n", + "pprint(scoring_response)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Deep dive into RAG Tool Performance\n", + "- Now, let's take a closer look at how the RAG tool is doing, specifically on the second example where the agent's answer is not correct on identifying what DoRA stands for. \n", + "- Notice that the issue lies with the retrieval step, where the retrieved document is not relevant to the question. " + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
[\n", + "β Turn(\n", + "β β input_messages=[UserMessage(content='What does DoRA stand for in torchtune?', role='user', context=None)],\n", + "β β output_message=CompletionMessage(\n", + "β β β content='DoRA stands for \"Decoupled Orthogonal Random Axes\" in the context of the Torchtune project.',\n", + "β β β role='assistant',\n", + "β β β stop_reason='end_of_turn',\n", + "β β β tool_calls=[]\n", + "β β ),\n", + "β β session_id='b5b5b9c5-1f14-404a-9677-cdb413b9f328',\n", + "β β started_at=datetime.datetime(2025, 3, 7, 10, 35, 24, 235903, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=57600))),\n", + "β β steps=[\n", + "β β β InferenceStep(\n", + "β β β β api_model_response=CompletionMessage(\n", + "β β β β β content='',\n", + "β β β β β role='assistant',\n", + "β β β β β stop_reason='end_of_turn',\n", + "β β β β β tool_calls=[\n", + "β β β β β β ToolCall(\n", + "β β β β β β β arguments={'query': 'DoRA meaning in Torchtune'},\n", + "β β β β β β β call_id='c2c088b9-cf2f-41b5-a050-dd5743112f48',\n", + "β β β β β β β tool_name='knowledge_search'\n", + "β β β β β β )\n", + "β β β β β ]\n", + "β β β β ),\n", + "β β β β step_id='27ba55cd-0252-4cff-8141-129b3b8dd021',\n", + "β β β β step_type='inference',\n", + "β β β β turn_id='bb111412-e2e9-40ca-9cd2-87df200807ab',\n", + "β β β β completed_at=datetime.datetime(2025, 3, 7, 10, 35, 26, 226185, tzinfo=TzInfo(-08:00)),\n", + "β β β β started_at=datetime.datetime(2025, 3, 7, 10, 35, 24, 236359, tzinfo=TzInfo(-08:00))\n", + "β β β ),\n", + "β β β ToolExecutionStep(\n", + "β β β β step_id='e7da6bb1-a704-4a2e-9954-5d54d8a1fc5d',\n", + "β β β β step_type='tool_execution',\n", + "β β β β tool_calls=[\n", + "β β β β β ToolCall(\n", + "β β β β β β arguments={'query': 'DoRA meaning in Torchtune'},\n", + "β β β β β β call_id='c2c088b9-cf2f-41b5-a050-dd5743112f48',\n", + "β β β β β β tool_name='knowledge_search'\n", + "β β β β β )\n", + "β β β β ],\n", + "β β β β tool_responses=[\n", + "β β β β β ToolResponse(\n", + "β β β β β β call_id='c2c088b9-cf2f-41b5-a050-dd5743112f48',\n", + "β β β β β β content=[\n", + "β β β β β β β TextContentItem(\n", + "β β β β β β β β text='knowledge_search tool found 5 chunks:\\nBEGIN of knowledge_search tool results.\\n',\n", + "β β β β β β β β type='text'\n", + "β β β β β β β ),\n", + "β β β β β β β TextContentItem(\n", + "β β β β β β β β text='Result 1:\\nDocument_id:num-0\\nContent: etune\\n:func:`torchtune.models.llama3.llama3_8b` with DoRA, you would use :func:`torchtune.models.llama3.lora_llama3_8b` with ``use_dora=True``:\\n\\n.. code-block:: bash\\n\\n tune run lora_finetune_single_device --config llama3/8B_lora_single_device \\\\\\n model.use_dora=True\\n\\n.. code-block:: yaml\\n\\n model:\\n _component_: torchtune.models.lora_llama3_8b\\n use_dora: True\\n\\nSince DoRA extends LoRA, the parameters for :ref:`customizing LoRA <glossary_lora>` are identical. You can also quantize the base model weights like in :ref:`glossary_qlora` by using ``quantize=True`` to reap\\neven more memory savings!\\n\\n.. code-block:: bash\\n\\n tune run lora_finetune_single_device --config llama3/8B_lora_single_device \\\\\\n model.apply_lora_to_mlp=True \\\\\\n model.lora_attn_modules=[\"q_proj\",\"k_proj\",\"v_proj\"] \\\\\\n model.lora_rank=16 \\\\\\n model.lora_alpha=32 \\\\\\n model.use_dora=True \\\\\\n model.quantize_base=True\\n\\n.. code-block:: yaml\\n\\n model:\\n _component_: torchtune.models.lora_llama3_8b\\n apply_lora_to_mlp: True\\n lora_attn_modules: [\"q_proj\", \"k_proj\", \"v_proj\"]\\n lora_rank: 16\\n lora_alpha: 32\\n use_dora: True\\n quantize_base: True\\n\\n\\n.. note::\\n\\n Under the hood, we\\'ve enabled DoRA by adding the :class:`~torchtune.modules.peft.DoRALinear` module, which we swap\\n out for :class:`~torchtune.modules.peft.LoRALinear` when ``use_dora=True``.\\n\\n.. _glossary_distrib:\\n\\n\\n.. TODO\\n\\n.. Distributed\\n.. -----------\\n\\n.. .. _glossary_fsdp:\\n\\n.. Fully Sharded Data Parallel (FSDP)\\n.. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n\\n.. All our ``_distributed`` recipes use `FSDP <https://pytorch.org/docs/stable/fsdp.html>`.\\n.. .. _glossary_fsdp2:\\n\\n',\n", + "β β β β β β β β type='text'\n", + "β β β β β β β ),\n", + "β β β β β β β TextContentItem(\n", + "β β β β β β β β text='Result 2:\\nDocument_id:num-1\\nContent: conversational data, :func:`~torchtune.datasets.chat_dataset` seems to be a good fit. For any\\ncustom local dataset we always need to specify ``source``, ``data_files``, and ``split`` for any dataset\\nbuilder in torchtune. For :func:`~torchtune.datasets.chat_dataset`, we additionally need to specify\\n``conversation_column`` and ``conversation_style``. Our data follows the ``\"sharegpt\"`` format, so\\nwe can specify that here. Altogether, our :func:`~torchtune.datasets.chat_dataset` call should\\nlook like so:\\n\\n.. code-block:: python\\n\\n from torchtune.datasets import chat_dataset\\n from torchtune.models.llama3 import llama3_tokenizer\\n\\n tokenizer = llama3_tokenizer(\"/tmp/Meta-Llama-3-8B-Instruct/original/tokenizer.model\")\\n ds = chat_dataset(\\n tokenizer=tokenizer,\\n source=\"json\",\\n data_files=\"data/my_data.json\",\\n split=\"train\",\\n conversation_column=\"dialogue\",\\n conversation_style=\"sharegpt\",\\n )\\n\\n.. code-block:: yaml\\n\\n # In config\\n tokenizer:\\n _component_: torchtune.models.llama3.llama3_tokenizer\\n path: /tmp/Meta-Llama-3-8B-Instruct/original/tokenizer.model\\n\\n dataset:\\n _component_: torchtune.datasets.chat_dataset\\n source: json\\n data_files: data/my_data.json\\n split: train\\n conversation_column: dialogue\\n conversation_style: sharegpt\\n\\n.. note::\\n You can pass in any keyword argument for `load_dataset <https://huggingface.co/docs/datasets/v2.20.0/en/package_reference/loading_methods#datasets.load_dataset>`_ into all our\\n Dataset classes and they will honor them. This is useful for common parameters\\n such as specifying the data split with :code:`split` or configuration with\\n :code:`name`\\n\\nIf you needed to add a prompt template, you would simply pass it into the tokenizer.\\nSince we\\'re fine-tuning Llama3, the tokenizer will handle all formatting for\\nus and prompt templates are optional. Other models such as Mistral\\'s :class:`~torchtune.models.mistral._tokenizer.MistralTokenizer`,\\nuse a chat template by default (:class:`~torchtune.models.mistral.MistralChatTemplate`) to format\\nall messages according to their `recommendations <https://\\n',\n", + "β β β β β β β β type='text'\n", + "β β β β β β β ),\n", + "β β β β β β β TextContentItem(\n", + "β β β β β β β β text=\"Result 3:\\nDocument_id:num-5\\nContent: .. _lora_finetune_label:\\n\\n============================\\nFine-Tuning Llama2 with LoRA\\n============================\\n\\nThis guide will teach you about `LoRA <https://arxiv.org/abs/2106.09685>`_, a parameter-efficient finetuning technique,\\nand show you how you can use torchtune to finetune a Llama2 model with LoRA.\\nIf you already know what LoRA is and want to get straight to running\\nyour own LoRA finetune in torchtune, you can jump to :ref:`LoRA finetuning recipe in torchtune<lora_recipe_label>`.\\n\\n.. grid:: 2\\n\\n .. grid-item-card:: :octicon:`mortar-board;1em;` What you will learn\\n\\n * What LoRA is and how it saves memory during finetuning\\n * An overview of LoRA components in torchtune\\n * How to run a LoRA finetune using torchtune\\n * How to experiment with different LoRA configurations\\n\\n .. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites\\n\\n * Be familiar with :ref:`torchtune<overview_label>`\\n * Make sure to :ref:`install torchtune<install_label>`\\n * Make sure you have downloaded the :ref:`Llama2-7B model weights<download_llama_label>`\\n\\nWhat is LoRA?\\n-------------\\n\\n`LoRA <https://arxiv.org/abs/2106.09685>`_ is an adapter-based method for\\nparameter-efficient finetuning that adds trainable low-rank decomposition matrices to different layers of a neural network,\\nthen freezes the network's remaining parameters. LoRA is most commonly applied to\\ntransformer models, in which case it is common to add the low-rank matrices\\nto some of the linear projections in each transformer layer's self-attention.\\n\\n.. note::\\n\\n If you're unfamiliar, check out these references for the `definition of rank <https://en.wikipedia.org/wiki/Rank_(linear_algebra)>`_\\n and discussion of `low-rank approximations <https://en.wikipedia.org/wiki/Low-rank_approximation>`_.\\n\\nBy finetuning with LoRA (as opposed to finetuning all model parameters),\\nyou can expect to see memory savings due to a substantial reduction in the\\nnumber of parameters with gradients. When using an optimizer with momentum,\\nlike `AdamW <https://py\\n\",\n", + "β β β β β β β β type='text'\n", + "β β β β β β β ),\n", + "β β β β β β β TextContentItem(\n", + "β β β β β β β β text='Result 4:\\nDocument_id:num-0\\nContent: use the :class:`torch.optim.AdamW` optimizer with ``fused=True`` as the base optimizer. For example, to use this optimizer to offload\\nboth optimizer states and gradients to CPU:\\n\\n.. code-block:: bash\\n\\n tune run <RECIPE> --config <CONFIG> \\\\\\n optimizer=optimizer=torchao.prototype.low_bit_optim.CPUOffloadOptimizer \\\\\\n optimizer.offload_gradients=True \\\\\\n lr=4e-5\\n\\n\\nor by directly :ref:`modifying a config file<config_tutorial_label>`:\\n\\n.. code-block:: yaml\\n\\n optimizer:\\n _component_: torchao.prototype.low_bit_optim.CPUOffloadOptimizer\\n offload_gradients: True\\n # additional key-word arguments can be passed to torch.optim.AdamW\\n lr: 4e-5\\n\\nor using it directly in your code, which allows you to change the base optimizer:\\n\\n.. code-block:: python\\n\\n from torchao.prototype.low_bit_optim import CPUOffloadOptimizer\\n from torch.optim import Adam\\n\\n optimizer = CPUOffloadOptimizer(\\n model.parameters(), # your model here\\n Adam,\\n lr=1e-5,\\n fused=True\\n )\\n\\nSome helpful hints from the ``torchao`` `CPUOffloadOptimizer page <https://github.com/pytorch/ao/tree/main/torchao/prototype/low_bit_optim#optimizer-cpu-offload>`_:\\n\\n* The CPU optimizer step is often the bottleneck when optimizer CPU offload is used. To minimize the slowdown, it is recommended to (1) use full ``bf16`` training so that parameters, gradients, and optimizer states are in ``bf16``; and (2) give GPU more work per optimizer step to amortize the offloading time (e.g. larger batch size with activation checkpointing, gradient accumulation).\\n* Gradient accumulation should always be set to 1 when ``offload_gradients=True``, as gradients are cleared on GPU every backward pass.\\n* This optimizer works by keeping a copy of parameters and pre-allocating gradient memory on CPU. Therefore, expect your RAM usage to increase by 4x model size.\\n* This optimizer is only supported for single-device recipes. To use CPU-offloading in distributed recipes, use ``fsdp_cpu_offload=True`` instead. See :class:`torch.distributed.fsdp.FullyShardedDataParallel` for more details and `FSDP1 vs FSDP2 <https://github.com/pytorch/torchtitan/blob/main/docs/fsdp\\n',\n", + "β β β β β β β β type='text'\n", + "β β β β β β β ),\n", + "β β β β β β β TextContentItem(\n", + "β β β β β β β β text='Result 5:\\nDocument_id:num-5\\nContent: from our Llama2\\nmodel without any wrappers or custom checkpoint conversion logic.\\n\\n.. code-block:: python\\n\\n # Assuming that base_model already has the pretrained Llama2 weights,\\n # this will directly load them into your LoRA model without any conversion necessary.\\n lora_model.load_state_dict(base_model.state_dict(), strict=False)\\n\\n.. note::\\n Whenever loading weights with :code:`strict=False`, you should verify that any missing or extra keys in\\n the loaded :code:`state_dict` are as expected. torchtune\\'s LoRA recipes do this by default via\\n :func:`validate_missing_and_unexpected_for_lora() <torchtune.modules.peft.validate_missing_and_unexpected_for_lora>`.\\n\\nOnce we\\'ve loaded the base model weights, we also want to set only LoRA parameters to trainable.\\n\\n.. _setting_trainable_params:\\n\\n.. code-block:: python\\n\\n from torchtune.modules.peft.peft_utils import get_adapter_params, set_trainable_params\\n\\n # Fetch all params from the model that are associated with LoRA.\\n lora_params = get_adapter_params(lora_model)\\n\\n # Set requires_grad=True on lora_params, and requires_grad=False on all others.\\n set_trainable_params(lora_model, lora_params)\\n\\n # Print the total number of parameters\\n total_params = sum([p.numel() for p in lora_model.parameters()])\\n trainable_params = sum([p.numel() for p in lora_model.parameters() if p.requires_grad])\\n print(\\n f\"\"\"\\n {total_params} total params,\\n {trainable_params}\" trainable params,\\n {(100.0 * trainable_params / total_params):.2f}% of all params are trainable.\\n \"\"\"\\n )\\n\\n 6742609920 total params,\\n 4194304 trainable params,\\n 0.06% of all params are trainable.\\n\\n.. note::\\n If you are directly using the LoRA recipe (as detailed :ref:`here<lora_recipe_label>`), you need only pass the\\n relevant checkpoint path. Loading model weights and setting trainable parameters will be taken care\\n of in the recipe.\\n\\n\\n.. _lora_recipe_label:\\n\\nLoRA finetuning recipe in torchtune\\n-----------------------------------\\n\\nFinally, we can put it all together and finetune a model using torchtune\\'s `LoRA recipe <https://github.com/pytorch/torchtune/blob/48626d19d2108f92\\n',\n", + "β β β β β β β β type='text'\n", + "β β β β β β β ),\n", + "β β β β β β β TextContentItem(text='END of knowledge_search tool results.\\n', type='text')\n", + "β β β β β β ],\n", + "β β β β β β tool_name='knowledge_search',\n", + "β β β β β β metadata={'document_ids': ['num-0', 'num-1', 'num-5', 'num-0', 'num-5']}\n", + "β β β β β )\n", + "β β β β ],\n", + "β β β β turn_id='bb111412-e2e9-40ca-9cd2-87df200807ab',\n", + "β β β β completed_at=datetime.datetime(2025, 3, 7, 10, 35, 26, 339563, tzinfo=TzInfo(-08:00)),\n", + "β β β β started_at=datetime.datetime(2025, 3, 7, 10, 35, 26, 264752, tzinfo=TzInfo(-08:00))\n", + "β β β ),\n", + "β β β InferenceStep(\n", + "β β β β api_model_response=CompletionMessage(\n", + "β β β β β content='DoRA stands for \"Decoupled Orthogonal Random Axes\" in the context of the Torchtune project.',\n", + "β β β β β role='assistant',\n", + "β β β β β stop_reason='end_of_turn',\n", + "β β β β β tool_calls=[]\n", + "β β β β ),\n", + "β β β β step_id='400e49e1-f33e-41da-b22a-f1d2338a27c8',\n", + "β β β β step_type='inference',\n", + "β β β β turn_id='bb111412-e2e9-40ca-9cd2-87df200807ab',\n", + "β β β β completed_at=datetime.datetime(2025, 3, 7, 10, 35, 27, 281430, tzinfo=TzInfo(-08:00)),\n", + "β β β β started_at=datetime.datetime(2025, 3, 7, 10, 35, 26, 351029, tzinfo=TzInfo(-08:00))\n", + "β β β )\n", + "β β ],\n", + "β β turn_id='bb111412-e2e9-40ca-9cd2-87df200807ab',\n", + "β β completed_at=datetime.datetime(2025, 3, 7, 10, 35, 27, 294253, tzinfo=TzInfo(-08:00)),\n", + "β β output_attachments=[]\n", + "β )\n", + "]\n", + "\n" + ], + "text/plain": [ + "\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\u001b[1;35mUserMessage\u001b[0m\u001b[1m(\u001b[0m\u001b[33mcontent\u001b[0m=\u001b[32m'What does DoRA stand for in torchtune?'\u001b[0m, \u001b[33mrole\u001b[0m=\u001b[32m'user'\u001b[0m, \u001b[33mcontext\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\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'DoRA stands for \"Decoupled Orthogonal Random Axes\" in the context of the Torchtune project.'\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'b5b5b9c5-1f14-404a-9677-cdb413b9f328'\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;36m3\u001b[0m, \u001b[1;36m7\u001b[0m, \u001b[1;36m10\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m24\u001b[0m, \u001b[1;36m235903\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''\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\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[1;35mToolCall\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β β β β β \u001b[0m\u001b[33marguments\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'query'\u001b[0m: \u001b[32m'DoRA meaning in Torchtune'\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32mβ β β β β β β \u001b[0m\u001b[33mcall_id\u001b[0m=\u001b[32m'c2c088b9-cf2f-41b5-a050-dd5743112f48'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β β \u001b[0m\u001b[33mtool_name\u001b[0m=\u001b[32m'knowledge_search'\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[1m)\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[33mstep_id\u001b[0m=\u001b[32m'27ba55cd-0252-4cff-8141-129b3b8dd021'\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'bb111412-e2e9-40ca-9cd2-87df200807ab'\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;36m3\u001b[0m, \u001b[1;36m7\u001b[0m, \u001b[1;36m10\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m26\u001b[0m, \u001b[1;36m226185\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;36m3\u001b[0m, \u001b[1;36m7\u001b[0m, \u001b[1;36m10\u001b[0m, \u001b[1;36m35\u001b[0m, \u001b[1;36m24\u001b[0m, \u001b[1;36m236359\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[1;35mToolExecutionStep\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[33mstep_id\u001b[0m=\u001b[32m'e7da6bb1-a704-4a2e-9954-5d54d8a1fc5d'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[33mstep_type\u001b[0m=\u001b[32m'tool_execution'\u001b[0m,\n", + "\u001b[2;32mβ β β β \u001b[0m\u001b[33mtool_calls\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[1;35mToolCall\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[33marguments\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'query'\u001b[0m: \u001b[32m'DoRA meaning in Torchtune'\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[33mcall_id\u001b[0m=\u001b[32m'c2c088b9-cf2f-41b5-a050-dd5743112f48'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[33mtool_name\u001b[0m=\u001b[32m'knowledge_search'\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[33mtool_responses\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β β \u001b[0m\u001b[1;35mToolResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[33mcall_id\u001b[0m=\u001b[32m'c2c088b9-cf2f-41b5-a050-dd5743112f48'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β \u001b[0m\u001b[33mcontent\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32mβ β β β β β β \u001b[0m\u001b[1;35mTextContentItem\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β β β β β β \u001b[0m\u001b[33mtext\u001b[0m=\u001b[32m'knowledge_search tool found 5 chunks:\\nBEGIN of knowledge_search tool results.\\n'\u001b[0m,\n", + "\u001b[2;32mβ β β β β β β β \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'text'\u001b[0m\n", + "\u001b[2;32mβ β β β β β β \u001b[0m\u001b[1m)\u001b[0m,\n", + "\u001b[2;32mβ β β β β β β \u001b[0m\u001b[1;35mTextContentItem\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32mβ β β β β β β β \u001b[0m\u001b[33mtext\u001b[0m=\u001b[32m'Result 1:\\nDocument_id:num-0\\nContent: etune\\n:func:`torchtune.models.llama3.llama3_8b` with DoRA, you would use :func:`torchtune.models.llama3.lora_llama3_8b` with ``\u001b[0m\u001b[32muse_dora\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m``:\\n\\n.. code-block:: bash\\n\\n tune run lora_finetune_single_device --config llama3/8B_lora_single_device \\\\\\n model.\u001b[0m\u001b[32muse_dora\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m\\n\\n.. code-block:: yaml\\n\\n model:\\n _component_: torchtune.models.lora_llama3_8b\\n use_dora: True\\n\\nSince DoRA extends LoRA, the parameters for :ref:`customizing LoRA \u001b[0m\u001b[32m<\u001b[0m\u001b[32mglossary_lora\u001b[0m\u001b[32m>` are identical. You can also quantize the base model weights like in :ref:`glossary_qlora` by using ``\u001b[0m\u001b[32mquantize\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m`` to reap\\neven more memory savings!\\n\\n.. code-block:: bash\\n\\n tune run lora_finetune_single_device --config llama3/8B_lora_single_device \\\\\\n model.\u001b[0m\u001b[32mapply_lora_to_mlp\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m \\\\\\n model.\u001b[0m\u001b[32mlora_attn_modules\u001b[0m\u001b[32m=\u001b[0m\u001b[32m[\u001b[0m\u001b[32m\"q_proj\",\"k_proj\",\"v_proj\"\u001b[0m\u001b[32m]\u001b[0m\u001b[32m \\\\\\n model.\u001b[0m\u001b[32mlora_rank\u001b[0m\u001b[32m=\u001b[0m\u001b[32m16\u001b[0m\u001b[32m \\\\\\n model.\u001b[0m\u001b[32mlora_alpha\u001b[0m\u001b[32m=\u001b[0m\u001b[32m32\u001b[0m\u001b[32m \\\\\\n model.\u001b[0m\u001b[32muse_dora\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m \\\\\\n model.\u001b[0m\u001b[32mquantize_base\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m\\n\\n.. code-block:: yaml\\n\\n model:\\n _component_: torchtune.models.lora_llama3_8b\\n apply_lora_to_mlp: True\\n lora_attn_modules: \u001b[0m\u001b[32m[\u001b[0m\u001b[32m\"q_proj\", \"k_proj\", \"v_proj\"\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n lora_rank: 16\\n lora_alpha: 32\\n use_dora: True\\n quantize_base: True\\n\\n\\n.. note::\\n\\n Under the hood, we\\'ve enabled DoRA by adding the :class:`~torchtune.modules.peft.DoRALinear` module, which we swap\\n out for :class:`~torchtune.modules.peft.LoRALinear` when ``\u001b[0m\u001b[32muse_dora\u001b[0m\u001b[32m=\u001b[0m\u001b[32mTrue\u001b[0m\u001b[32m``.\\n\\n.. _glossary_distrib:\\n\\n\\n.. TODO\\n\\n.. Distributed\\n.. -----------\\n\\n.. .. _glossary_fsdp:\\n\\n.. Fully Sharded Data Parallel \u001b[0m\u001b[32m(\u001b[0m\u001b[32mFSDP\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n.. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n\\n.. All our ``_distributed`` recipes use `FSDP