From 255bf22596f1202b6c73b7de534743c66a5fb5d0 Mon Sep 17 00:00:00 2001 From: Yiran Wu <32823396+kevin666aa@users.noreply.github.com> Date: Sat, 11 Nov 2023 14:57:14 -0500 Subject: [PATCH] Fix test error of compressible agent (#631) * fix bug in test * update workflow * update * deepcopy to copy --- .github/workflows/build.yml | 2 +- .github/workflows/openai.yml | 2 +- .../agentchat/contrib/compressible_agent.py | 2 +- notebook/agentchat_compression.ipynb | 2582 ++++++++--------- .../contrib/test_compressible_agent.py | 20 +- 5 files changed, 1304 insertions(+), 1304 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bc831913ae..3cdb6293b27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,7 @@ jobs: run: | pip install -e .[mathchat,test] pip uninstall -y openai - coverage run -a -m pytest test + coverage run -a -m pytest test --ignore=test/agentchat/contrib coverage xml - name: Upload coverage to Codecov if: matrix.python-version == '3.10' diff --git a/.github/workflows/openai.yml b/.github/workflows/openai.yml index 6f966337bed..b9184fd5268 100644 --- a/.github/workflows/openai.yml +++ b/.github/workflows/openai.yml @@ -54,7 +54,7 @@ jobs: AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }} OAI_CONFIG_LIST: ${{ secrets.OAI_CONFIG_LIST }} run: | - coverage run -a -m pytest test + coverage run -a -m pytest test --ignore=test/agentchat/contrib coverage xml - name: Coverage and check notebook outputs if: matrix.python-version != '3.9' diff --git a/autogen/agentchat/contrib/compressible_agent.py b/autogen/agentchat/contrib/compressible_agent.py index 15e641c0244..f1de41512e9 100644 --- a/autogen/agentchat/contrib/compressible_agent.py +++ b/autogen/agentchat/contrib/compressible_agent.py @@ -139,7 +139,7 @@ def _set_compress_config(self, compress_config: Optional[Dict] = False): if compress_config.get("mode", "TERMINATE") not in allowed_modes: raise ValueError(f"Invalid compression mode. Allowed values are: {', '.join(allowed_modes)}") - self.compress_config = self.DEFAULT_COMPRESS_CONFIG + self.compress_config = self.DEFAULT_COMPRESS_CONFIG.copy() self.compress_config.update(compress_config) if not isinstance(self.compress_config["leave_last_n"], int) or self.compress_config["leave_last_n"] < 0: diff --git a/notebook/agentchat_compression.ipynb b/notebook/agentchat_compression.ipynb index 40dc8a92497..295d1691856 100644 --- a/notebook/agentchat_compression.ipynb +++ b/notebook/agentchat_compression.ipynb @@ -1,1295 +1,1295 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Auto Generated Agent Chat: Conversations with Chat History Compression Enabled (Experimental)\n", - "\n", - "AutoGen offers conversable agents powered by LLM, tools, or humans, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n", - "\n", - "In this notebook, we demonstrate how to enable compression of history messages using the `CompressibleAgent`. While this agent retains all the default functionalities of the `AssistantAgent`, it also provides the added feature of compression when activated through the `compress_config` setting.\n", - "\n", - "Different compression modes are supported:\n", - "1. `compress_config=False` (Default): `CompressibleAgent` is equivalent to `AssistantAgent`.\n", - "2. `compress_config=True` or `compress_config={\"mode\": \"TERMINATE\"}`: no compression will be performed. However, we will count token usage before sending requests to the OpenAI model. The conversation will be terminated directly if the total token usage exceeds the maximum token usage allowed by the model (to avoid the token limit error from OpenAI API).\n", - "3. `compress_config={\"mode\": \"COMPRESS\", \"trigger_count\": }, \"leave_last_n\": `: compression is enabled.\n", - " ```python\n", - " # default compress_config\n", - " compress_config = {\n", - " \"mode\": \"COMPRESS\",\n", - " \"compress_function\": None,\n", - " \"trigger_count\": 0.7, # default to 0.7, or your pre-set number\n", - " \"broadcast\": True, # the compressed with be broadcast to sender. This will not be used in groupchat.\n", - "\n", - " # the following settings are for this mode only\n", - " \"leave_last_n\": 2, # leave the last n messages in the history to avoid compression\n", - " \"verbose\": False, # if True, print out the content to be compressed and the compressed content\n", - " }\n", - " ```\n", - " Currently, our compression logic is as follows:\n", - " 1. We will always leave the first user message (as well as system prompts) and compress the rest of the history messages.\n", - " 2. You can choose to not compress the last n messages in the history with \"leave_last_n\".\n", - " 2. The summary is performed on a per-message basis, with the role of the messages (See compressed content in the example below).\n", - "\n", - "4. `compress_config={\"mode\": \"CUSTOMIZED\", \"compress_function\": }`: the `compress_function` function will be called on trigger count. The function should accept a list of messages as input and return a tuple of (is_success: bool, compressed_messages: List[Dict]). The whole message history (except system prompt) will be passed.\n", - "\n", - "\n", - "By adjusting `trigger_count`, you can decide when to compress the history messages based on existing tokens. If this is a float number between 0 and 1, it is interpreted as a ratio of max tokens allowed by the model. For example, the AssistantAgent uses gpt-4 with max tokens 8192, the trigger_count = 0.7 * 8192 = 5734.4 -> 5734. Do not set `trigger_count` to the max tokens allowed by the model, since the same LLM is employed for compression and it needs tokens to generate the compressed content. \n", - "\n", - "\n", - "\n", - "## Limitations\n", - "- For now, the compression feature **is not well-supported for groupchat**. If you initialize a `CompressibleAgent` in a groupchat with compression, the compressed cannot be broadcast to all other agents in the groupchat. If you use this feature in groupchat, extra cost will be incurred since compression will be performed on at per-agent basis.\n", - "- We do not support async compression for now.\n", - "\n", - "## Requirements\n", - "\n", - "AutoGen requires `Python>=3.8`. To run this notebook example, please install:\n", - "```bash\n", - "pip install pyautogen\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# %pip install pyautogen~=0.1.0" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Set your API Endpoint\n", - "\n", - "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import autogen\n", - "config_list = autogen.config_list_from_json(\n", - " \"OAI_CONFIG_LIST\",\n", - " filter_dict={\n", - " \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n", - " },\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It first looks for environment variable \"OAI_CONFIG_LIST\" which needs to be a valid json string. If that variable is not found, it then looks for a json file named \"OAI_CONFIG_LIST\". It filters the configs by models (you can filter by other keys as well).\n", - "\n", - "The config list looks like the following:\n", - "```python\n", - "config_list = [\n", - " {\n", - " 'model': 'gpt-4',\n", - " 'api_key': '',\n", - " },\n", - " {\n", - " 'model': 'gpt-4',\n", - " 'api_key': '',\n", - " 'base_url': '',\n", - " 'api_type': 'azure',\n", - " 'api_version': '2023-06-01-preview',\n", - " },\n", - " {\n", - " 'model': 'gpt-4-32k',\n", - " 'api_key': '',\n", - " 'base_url': '',\n", - " 'api_type': 'azure',\n", - " 'api_version': '2023-06-01-preview',\n", - " },\n", - "]\n", - "```\n", - "\n", - "If you open this notebook in colab, you can upload your files by clicking the file icon on the left panel and then choose \"upload file\" icon.\n", - "\n", - "You can set the value of config_list in other ways you prefer, e.g., loading from a YAML file." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1\n", - "This example is from [agentchat_MathChat.ipynb](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_MathChat.ipynb). Compression with code execution.\n", - "\n", - "Note: we set `trigger_count=600`, and `leave_last_n=2`. In this example, we set a low trigger_count to demonstrate the compression feature. \n", - "The token count after compression is still bigger than trigger count, mainly because the trigger count is low an the first and last 2 messages are not compressed. Thus, the compression is performed at each turn. In practice, you want to adjust the trigger_count to a bigger number and properly set the `leave_last_n` to avoid compression at each turn. " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", - "\n", - "Let's use Python to solve a math problem.\n", - "\n", - "Query requirements:\n", - "You should always use the 'print' function for the output and use fractions/radical forms instead of decimals.\n", - "You can use packages like sympy to help you.\n", - "You must follow the formats below to write your code:\n", - "```python\n", - "# your code\n", - "```\n", - "\n", - "First state the key idea to solve the problem. You may choose from three ways to solve the problem:\n", - "Case 1: If the problem can be solved with Python code directly, please write a program to solve it. You can enumerate all possible arrangements if needed.\n", - "Case 2: If the problem is mostly reasoning, you can solve it by yourself directly.\n", - "Case 3: If the problem cannot be handled in the above two ways, please follow this process:\n", - "1. Solve the problem step by step (do not over-divide the steps).\n", - "2. Take out any queries that can be asked through Python (for example, any calculations or equations that can be calculated).\n", - "3. Wait for me to give the results.\n", - "4. Continue if you think the result is correct. If the result is invalid or unexpected, please correct your query or reasoning.\n", - "\n", - "After all the queries are run and you get the answer, put the answer in \\boxed{}.\n", - "\n", - "Problem:\n", - "Find all $x$ that satisfy the inequality $(2x+10)(x+3)<(3x+9)(x+8)$. Express your answer in interval notation.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", - "\n", - "First, we need to consider both sides of the inequality as two separate equations. Then subtract one from the other to set this result equal to zero. This would allow us to find the critical points, i.e., the places where the inequality changes its nature (from less to more or vice versa). Then we find the intervals.\n", - "\n", - "Here's how you can solve this problem in Python:\n", - "\n", - "```python\n", - "from sympy import *\n", - "from sympy.abc import x\n", - "\n", - "# define the equation\n", - "equation = (2*x+10)*(x+3) - (3*x+9)*(x+8)\n", - "\n", - "# set the equation equal to zero to find the critical points\n", - "critical_points = solve(equation, x)\n", - "\n", - "# Sort the critical_points\n", - "critical_points = sorted(critical_points)\n", - "\n", - "# define a function to test the intervals\n", - "def test_intervals(interval):\n", - " test_num = sum(interval)/2 # get the mid point of the interval\n", - " return equation.subs(x, test_num)\n", - "\n", - "# define the intervals based on the critical points\n", - "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", - "\n", - "solution = []\n", - "\n", - "# loop through the intervals, if the result is less than zero, it means it's a valid interval\n", - "for i in intervals:\n", - " if test_intervals(i) < 0:\n", - " solution.append(i)\n", - "\n", - "# print the solution in interval notation\n", - "for interval in solution:\n", - " print(interval)\n", - "```\n", - "\n", - "Replace oo with infinity when interpreting the result. Also, keep in mind that in interval notation, parentheses denote that the endpoint is not included in the set, and brackets denote that the end point is included in the set. Thus, (a, b) means \"greater than a and less than b\", [a, b] means \"greater than or equal to a and less than or equal to b\".\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", - "\n", - "Error: Traceback (most recent call last):\n", - " File \"\", line 25, in \n", - " if test_intervals(i) < 0:\n", - " return func(self, other)\n", - " return StrictLessThan(self, other)\n", - " raise TypeError(\"Invalid NaN comparison\")\n", - "TypeError: Invalid NaN comparison\n", - "\n", - "--------------------------------------------------------------------------------\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Warning: Compression skipped at trigger count threshold. The first msg and last 2 msgs will not be compressed. current msg count: 3. Consider raising trigger_count.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", - "\n", - "I apologize for the oversight. It seems like the function is returning NaN error. Because we are dealing with real numbers, NaN (Not a Number) error could arise from operations that don't return a defined real number. \n", - "\n", - "However, in this case, we it seems there's a problem with the comparison of symbolic terms with zero in the function test_intervals.\n", - "\n", - "Let's correct this approach. The error arises from trying to compare a symbolic expression to zero directly. Instead, we can create a numeric function from our symbolic expression, and use this function to test the intervals. \n", - "\n", - "Here is the revised code:\n", - "\n", - "```python\n", - "from sympy import *\n", - "from sympy.abc import x\n", - "\n", - "# define the equation\n", - "equation = expand((2*x+10)*(x+3) - (3*x+9)*(x+8))\n", - "\n", - "# set the equation equal to zero to find the critical points\n", - "critical_points = solve(equation, x)\n", - "\n", - "# Convert the points to standard python floats, so that they can be sorted numerically\n", - "critical_points = [N(i) for i in critical_points]\n", - "\n", - "# Sort the critical_points\n", - "critical_points = sorted(critical_points)\n", - "\n", - "# define a function to test the intervals\n", - "def test_intervals(interval):\n", - " test_num = N(sum(interval)/2) # get the mid point of the interval\n", - " return equation.subs(x, test_num)\n", - "\n", - "# define the intervals based on the critical points\n", - "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", - "\n", - "# Now, let's create a numeric function from this symbolic equation\n", - "numeric_equation = lambdify(x, equation)\n", - "\n", - "solution = []\n", - "\n", - "# loop through the intervals, first find the mid point of each interval, \n", - "# then if numeric result for this mid point is less than zero, it means it's a valid interval\n", - "for interval in intervals:\n", - " mid_point = sum(interval) / 2 \n", - " if numeric_equation(mid_point) < 0:\n", - " solution.append(interval)\n", - "\n", - "# print the solution in interval notation\n", - "for interval in solution:\n", - " print(interval)\n", - "```\n", - "\n", - "Remember to replace `oo` with infinity while interpreting the output.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", - "\n", - "Error: Traceback (most recent call last):\n", - " File \"\", line 36, in \n", - " if numeric_equation(mid_point) < 0:\n", - " return func(self, other)\n", - " return StrictLessThan(self, other)\n", - " raise TypeError(\"Invalid NaN comparison\")\n", - "TypeError: Invalid NaN comparison\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[35m******************************Start compressing the following content:******************************\u001b[0m\n", - "To be compressed:\n", - "##ASSISTANT## First, we need to consider both sides of the inequality as two separate equations. Then subtract one from the other to set this result equal to zero. This would allow us to find the critical points, i.e., the places where the inequality changes its nature (from less to more or vice versa). Then we find the intervals.\n", - "\n", - "Here's how you can solve this problem in Python:\n", - "\n", - "```python\n", - "from sympy import *\n", - "from sympy.abc import x\n", - "\n", - "# define the equation\n", - "equation = (2*x+10)*(x+3) - (3*x+9)*(x+8)\n", - "\n", - "# set the equation equal to zero to find the critical points\n", - "critical_points = solve(equation, x)\n", - "\n", - "# Sort the critical_points\n", - "critical_points = sorted(critical_points)\n", - "\n", - "# define a function to test the intervals\n", - "def test_intervals(interval):\n", - " test_num = sum(interval)/2 # get the mid point of the interval\n", - " return equation.subs(x, test_num)\n", - "\n", - "# define the intervals based on the critical points\n", - "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", - "\n", - "solution = []\n", - "\n", - "# loop through the intervals, if the result is less than zero, it means it's a valid interval\n", - "for i in intervals:\n", - " if test_intervals(i) < 0:\n", - " solution.append(i)\n", - "\n", - "# print the solution in interval notation\n", - "for interval in solution:\n", - " print(interval)\n", - "```\n", - "\n", - "Replace oo with infinity when interpreting the result. Also, keep in mind that in interval notation, parentheses denote that the endpoint is not included in the set, and brackets denote that the end point is included in the set. Thus, (a, b) means \"greater than a and less than b\", [a, b] means \"greater than or equal to a and less than or equal to b\".\n", - "##USER## Error: Traceback (most recent call last):\n", - " File \"\", line 25, in \n", - " if test_intervals(i) < 0:\n", - " return func(self, other)\n", - " return StrictLessThan(self, other)\n", - " raise TypeError(\"Invalid NaN comparison\")\n", - "TypeError: Invalid NaN comparison\n", - "\n", - "\u001b[35m******************************Content after compressing:******************************\u001b[0m\n", - "##ASSISTANT##\n", - "The assistant provides instructions to solve an inequality, which involves considering separate equations for the inequality components, finding the differing point (set to zero), identifying critical points (where nature of inequality changes), and determining the intervals. \n", - "\n", - "They also share Python code for the process, using sympy library. Steps include defining the equation, finding critical points by setting equation to zero, sorting these points, defining a function to test the intervals, determining intervals based on critical points, and looping through intervals to identify valid solutions. The assistant defines 'oo' as infinity and clarifies the use of parentheses and brackets to denote exclusion or inclusion of endpoints in interval notation.\n", - "\n", - "##CODE##\n", - "Python script to solve the given inequality and display the solution using interval notation.\n", - "\n", - "##USER##\n", - "User encounters 'TypeError: Invalid NaN comparison', indicating there's an error when comparing a test interval to zero in the Python script shared by the assistant.\n", - " \u001b[35m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[35mToken Count (including 13 tokens from system msg and function descriptions). Before compression : 1294 | After: 1045\u001b[0m\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", - "\n", - "I apologize for the confusion. There's an error with the calculation of mid_point when the interval is from negative infinity to a real number or a real number to infinity. In these circumstances, the calculation will return a NaN which cannot be used in comparison. We could handle these issues specifically.\n", - "\n", - "Let's refine the script:\n", - "\n", - "```python\n", - "from sympy import *\n", - "from sympy.abc import x\n", - "\n", - "# define the equation\n", - "equation = expand((2*x+10)*(x+3) - (3*x+9)*(x+8))\n", - "\n", - "# set the equation equal to zero to find the critical points\n", - "critical_points = solve(equation, x)\n", - "\n", - "# Convert the points to standard python floats, so that they can be sorted numerically\n", - "critical_points = [N(i) for i in critical_points]\n", - "\n", - "# Sort the critical_points\n", - "critical_points = sorted(critical_points)\n", - "\n", - "# Now, let's create a numeric function from this symbolic equation\n", - "numeric_equation = lambdify(x, equation)\n", - "\n", - "solution = []\n", - "\n", - "# Define the intervals based on the critical points\n", - "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", - "\n", - "# Loop through the intervals and compute the mid point of each interval\n", - "# If the mid point is NaN (occurs when dealing with infinity), then specific values are used for testing\n", - "for interval in intervals:\n", - " if interval[0] == -oo:\n", - " test_value = interval[1] - 1\n", - " elif interval[1] == oo:\n", - " test_value = interval[0] + 1\n", - " else:\n", - " test_value = sum(interval) / 2\n", - "\n", - " # If numeric result for test_value is less than zero, it's a valid interval\n", - " if numeric_equation(test_value) < 0:\n", - " solution.append(interval)\n", - "\n", - "# Print out the solution intervals\n", - "for interval in solution:\n", - " print(interval)\n", - "```\n", - "\n", - "The script now handles the special cases when dealing with infinity and should return the valid intervals.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", - "\n", - "(-oo, -14.0000000000000)\n", - "(-3.00000000000000, oo)\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[35m******************************Start compressing the following content:******************************\u001b[0m\n", - "To be compressed:\n", - "##ASSISTANT##\n", - "The assistant provides instructions to solve an inequality, which involves considering separate equations for the inequality components, finding the differing point (set to zero), identifying critical points (where nature of inequality changes), and determining the intervals. \n", - "\n", - "They also share Python code for the process, using sympy library. Steps include defining the equation, finding critical points by setting equation to zero, sorting these points, defining a function to test the intervals, determining intervals based on critical points, and looping through intervals to identify valid solutions. The assistant defines 'oo' as infinity and clarifies the use of parentheses and brackets to denote exclusion or inclusion of endpoints in interval notation.\n", - "\n", - "##CODE##\n", - "Python script to solve the given inequality and display the solution using interval notation.\n", - "\n", - "##USER##\n", - "User encounters 'TypeError: Invalid NaN comparison', indicating there's an error when comparing a test interval to zero in the Python script shared by the assistant.\n", - "\n", - "##ASSISTANT## I apologize for the oversight. It seems like the function is returning NaN error. Because we are dealing with real numbers, NaN (Not a Number) error could arise from operations that don't return a defined real number. \n", - "\n", - "However, in this case, we it seems there's a problem with the comparison of symbolic terms with zero in the function test_intervals.\n", - "\n", - "Let's correct this approach. The error arises from trying to compare a symbolic expression to zero directly. Instead, we can create a numeric function from our symbolic expression, and use this function to test the intervals. \n", - "\n", - "Here is the revised code:\n", - "\n", - "```python\n", - "from sympy import *\n", - "from sympy.abc import x\n", - "\n", - "# define the equation\n", - "equation = expand((2*x+10)*(x+3) - (3*x+9)*(x+8))\n", - "\n", - "# set the equation equal to zero to find the critical points\n", - "critical_points = solve(equation, x)\n", - "\n", - "# Convert the points to standard python floats, so that they can be sorted numerically\n", - "critical_points = [N(i) for i in critical_points]\n", - "\n", - "# Sort the critical_points\n", - "critical_points = sorted(critical_points)\n", - "\n", - "# define a function to test the intervals\n", - "def test_intervals(interval):\n", - " test_num = N(sum(interval)/2) # get the mid point of the interval\n", - " return equation.subs(x, test_num)\n", - "\n", - "# define the intervals based on the critical points\n", - "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", - "\n", - "# Now, let's create a numeric function from this symbolic equation\n", - "numeric_equation = lambdify(x, equation)\n", - "\n", - "solution = []\n", - "\n", - "# loop through the intervals, first find the mid point of each interval, \n", - "# then if numeric result for this mid point is less than zero, it means it's a valid interval\n", - "for interval in intervals:\n", - " mid_point = sum(interval) / 2 \n", - " if numeric_equation(mid_point) < 0:\n", - " solution.append(interval)\n", - "\n", - "# print the solution in interval notation\n", - "for interval in solution:\n", - " print(interval)\n", - "```\n", - "\n", - "Remember to replace `oo` with infinity while interpreting the output.\n", - "##USER## Error: Traceback (most recent call last):\n", - " File \"\", line 36, in \n", - " if numeric_equation(mid_point) < 0:\n", - " return func(self, other)\n", - " return StrictLessThan(self, other)\n", - " raise TypeError(\"Invalid NaN comparison\")\n", - "TypeError: Invalid NaN comparison\n", - "\n", - "\u001b[35m******************************Content after compressing:******************************\u001b[0m\n", - "##ASSISTANT##\n", - "The assistant provides steps to solve an inequality, including considering separate equations, finding the differing point (set to zero), identifying critical points, and determining intervals. They provide Python code using sympy for the process, defining 'oo' as infinity and explaining usage of parentheses and brackets in interval notation. \n", - "\n", - "##CODE##\n", - "The assistant provides Python code for solving an inequality and displaying the solution in interval notation.\n", - "\n", - "##USER##\n", - "The user reports encountering a 'TypeError: Invalid NaN comparison' when comparing a test interval to zero in the script provided by the assistant.\n", - "\n", - "##ASSISTANT##\n", - "The assistant apologizes for the oversight and suggests the issue might lie in the comparison of symbolic terms with zero. The assistant then provides revised code, explaining it creates a numeric function from the symbolic expression to test the intervals. It's highlighted to replace 'oo' with infinity when interpreting the output.\n", - "\n", - "##CODE##\n", - "Revised Python code is given by the assistant to solve a TypeError that occurred in the initial code.\n", - "\n", - "##USER##\n", - "The user reports another TypeError ('Invalid NaN comparison') when executing the revised code provided by the assistant. \u001b[35m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[35mToken Count (including 13 tokens from system msg and function descriptions). Before compression : 1494 | After: 1013\u001b[0m\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", - "\n", - "Great! You have got the correct answer.\n", - "\n", - "So, for $x$ in the interval $(-\\infty, -14]$ and $(-3, +\\infty)$, the inequality $(2x+10)(x+3)<(3x+9)(x+8)$ is satisfied. \n", - "\n", - "In interval notation, this result can be written as $(-\\infty, -14] \\cup (-3, +\\infty)$.\n", - "\n", - "The final answer is:\n", - "\n", - "\\boxed{(-\\infty, -14] \\cup (-3, +\\infty)}\n", - "\n", - "--------------------------------------------------------------------------------\n" - ] - } - ], - "source": [ - "from autogen.agentchat.contrib.math_user_proxy_agent import MathUserProxyAgent\n", - "from autogen.agentchat.contrib.compressible_agent import CompressibleAgent\n", - "\n", - "# 1. replace AssistantAgent with CompressibleAgent\n", - "assistant = CompressibleAgent(\n", - " name=\"assistant\", \n", - " system_message=\"You are a helpful assistant.\",\n", - " llm_config={\n", - " \"timeout\": 600,\n", - " \"seed\": 42,\n", - " \"config_list\": config_list,\n", - " },\n", - " compress_config={\n", - " \"mode\": \"COMPRESS\",\n", - " \"trigger_count\": 600, # set this to a large number for less frequent compression\n", - " \"verbose\": True, # to allow printing of compression information: contex before and after compression\n", - " \"leave_last_n\": 2,\n", - " }\n", - ")\n", - "\n", - "# 2. create the MathUserProxyAgent instance named \"mathproxyagent\"\n", - "mathproxyagent = MathUserProxyAgent(\n", - " name=\"mathproxyagent\", \n", - " human_input_mode=\"NEVER\",\n", - " code_execution_config={\"use_docker\": False},\n", - " max_consecutive_auto_reply=5,\n", - ")\n", - "math_problem = \"Find all $x$ that satisfy the inequality $(2x+10)(x+3)<(3x+9)(x+8)$. Express your answer in interval notation.\"\n", - "mathproxyagent.initiate_chat(assistant, problem=math_problem)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2\n", - "This example is from [agentchat_function_call.ipynb](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_function_call.ipynb). Compression with function calls. " - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to chatbot):\n", - "\n", - "Draw two agents chatting with each other with an example dialog. Don't add plt.show().\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mchatbot\u001b[0m (to user_proxy):\n", - "\n", - "\u001b[32m***** Suggested function Call: python *****\u001b[0m\n", - "Arguments: \n", - "{\n", - " \"cell\": \n", - " \"import matplotlib.pyplot as plt\n", - "\n", - " # Define agent texts\n", - " agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\n", - " agent2_texts = ['Hey!', 'Nice meeting you too.', 'Could you help me solve a problem?']\n", - "\n", - " # Define agent y positions\n", - " agent1_y = [3, 2, 1]\n", - " agent2_y = [3, 2, 1]\n", - "\n", - " # Create figure and axis\n", - " fig, ax = plt.subplots()\n", - "\n", - " # Plot Agent 1 texts\n", - " for i, text in enumerate(agent1_texts):\n", - " ax.text(0, agent1_y[i], text, fontsize=12, ha='right')\n", - "\n", - " # Plot Agent 2 texts\n", - " for i, text in enumerate(agent2_texts):\n", - " ax.text(1, agent2_y[i], text, fontsize=12, ha='left')\n", - "\n", - " # Set plot attributes\n", - " ax.set_xlim(-0.5, 1.5)\n", - " ax.set_ylim(0, 4)\n", - " ax.set_xticks([0, 1])\n", - " ax.set_xticklabels(['Agent 1', 'Agent 2'])\n", - " ax.set_yticks([])\n", - " ax.spines['top'].set_visible(False)\n", - " ax.spines['right'].set_visible(False)\n", - " ax.spines['bottom'].set_visible(False)\"\n", - "}\n", - "\u001b[32m*******************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION python...\u001b[0m\n" - ] - }, - { - "ename": "IndentationError", - "evalue": "unexpected indent (1440792568.py, line 4)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[3], line 4\u001b[0;36m\u001b[0m\n\u001b[0;31m agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to chatbot):\n", - "\n", - "\u001b[32m***** Response from calling function \"python\" *****\u001b[0m\n", - "None\n", - "unexpected indent (1440792568.py, line 4)\n", - "\u001b[32m***************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mchatbot\u001b[0m (to user_proxy):\n", - "\n", - "\u001b[32m***** Suggested function Call: python *****\u001b[0m\n", - "Arguments: \n", - "{\n", - " \"cell\": \n", - " \"import matplotlib.pyplot as plt\n", - "\n", - "# Define agent texts\n", - "agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\n", - "agent2_texts = ['Hey!', 'Nice meeting you too.', 'Could you help me solve a problem?']\n", - "\n", - "# Define agent y positions\n", - "agent1_y = [3, 2, 1]\n", - "agent2_y = [3, 2, 1]\n", - "\n", - "# Create figure and axis\n", - "fig, ax = plt.subplots()\n", - "\n", - "# Plot Agent 1 texts\n", - "for i, text in enumerate(agent1_texts):\n", - " ax.text(0, agent1_y[i], text, fontsize=12, ha='right')\n", - "\n", - "# Plot Agent 2 texts\n", - "for i, text in enumerate(agent2_texts):\n", - " ax.text(1, agent2_y[i], text, fontsize=12, ha='left')\n", - "\n", - "# Set plot attributes\n", - "ax.set_xlim(-0.5, 1.5)\n", - "ax.set_ylim(0, 4)\n", - "ax.set_xticks([0, 1])\n", - "ax.set_xticklabels(['Agent 1', 'Agent 2'])\n", - "ax.set_yticks([])\n", - "ax.spines['top'].set_visible(False)\n", - "ax.spines['right'].set_visible(False)\n", - "ax.spines['bottom'].set_visible(False)\"\n", - "}\n", - "\u001b[32m*******************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION python...\u001b[0m\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAu0AAAGdCAYAAACmdE07AAAAOXRFWHRTb2Z0d2Fy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otx5PT08NGzZM3bp1U926da0p++bMmZPpa9olqXLlyipXrpwWLVqk0qVL67777nNa/vDDD6tOnTp69dVXdfDgQVWsWFErVqzQxx9/rF69ellnFVO25Y033lCXLl1UpUoVrV271jqDfbO4ubnp7bffVsOGDVW2bFl16tRJhQoV0p9//qnVq1crZ86c+vTTT9NdR8mSJfXkk09q06ZNypcvn9555x0dOXJEc+bMuam1XitnzpyaPn262rdvr/vuu0+tW7dWSEiIfv/9d33++eeqUaOGS5i8WpkyZVS7dm1FRUUpKChImzdv1uLFi53C2ptvvqmGDRuqevXqevLJJ3X+/HlNnjxZgYGBmZorP2VO8xdffNEpB6SIiIjQsGHD1K9fPx08eFDNmjVTQECADhw4oKVLl6pr164u01xerUmTJpo3b54CAwNVpkwZbdy4UStXrlSePHky3oH/X/HixVWzZk0988wzunDhgiZMmKA8efLo5ZdfzvC+WXk9S1K5cuUUGxurnj17ysvLy/oQOnjw4DQf40af5+vRr18/vfvuu9d3tj0rU82kTJWzadOmVJfHxMQ4TflojDGXLl0ygwcPNkWLFjWenp4mNDTU9OvXz2laxRRTp041kswzzzzj1F6/fn0jyXz99deZrvWdd94xlStXNl5eXiZ37twmJibGfPXVV9by9evXm/vvv9/4+PgYSeb55583y5cvd5lWMLVtMubK1D9hYWEZ1pHZKR+vrqdgwYLm5Zdfdqln//79pnPnziYiIsJ4e3uboKAgU6dOHbNy5UprPV9//bVp2rSpKViwoMmRI4cpWLCgadOmjdmzZ4/V59rpvo4fP266d+9uSpUqZfz8/ExgYKCpVq2a+eCDD5xqPHz4sGncuLEJCAjI1DRlKZ599lkjKc1pF48cOWI6depkgoODTY4cOUz58uVTnYrs2LFjpnnz5sbX19fkzp3bdOvWzWzfvj3NqcvCwsIyXSOAu8+ePXvMU089ZcLDw02OHDlMQECAqVGjhpk8ebLTGJTZcSopKcm88sorJjg42Pj6+prY2Fjz22+/ZTjlY4pp06aZokWLGi8vL1OlShWzdu1aExMTk6Xj1OjRo12mnbva6dOnTe/evU3BggW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ZP//8s4oWLarFixdryZIlqlChgqZPn27NLuHl5SXpyrWsa9as0Z49exQdHa3KlStrwIABTl/LZ8TDw0OTJk3SzJkzVbBgQTVt2jTNvl26dFHlypU1c+ZM7dmzR5UrV1blypVtPwc1cLvcqe/vxYsX69ixY4qPj1eBAgWsv2uvuweA28FhzFXzbQF3oOHDh2vGjBn6448/srsUADcZ728AuIJr2nHHmTZtmv7zn/8oT548Wr9+vd58880sfTUOwL54fwNA6gjtuOPs3btXw4YN0z///KMiRYqoT58+6tevX3aXBeAm4P0NAKnj8hgAAADA5vghKgAAAGBzhHYAAADA5gjtAAAAgM0R2gEAAACbI7QDAAAANkdoBwAAAGyO0A4AAADYHKEdAAAAsDlCOwAAAGBz/w92zUeE6ZsUvAAAAABJRU5ErkJggg==", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to chatbot):\n", - "\n", - "\u001b[32m***** Response from calling function \"python\" *****\u001b[0m\n", - "None\n", - "\u001b[32m***************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[35m******************************Start compressing the following content:******************************\u001b[0m\n", - "To be compressed:\n", - "##FUNCTION_CALL## \n", - "Name: python\n", - "Args: {\n", - " \"cell\": \n", - " \"import matplotlib.pyplot as plt\n", - "\n", - " # Define agent texts\n", - " agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\n", - " agent2_texts = ['Hey!', 'Nice meeting you too.', 'Could you help me solve a problem?']\n", - "\n", - " # Define agent y positions\n", - " agent1_y = [3, 2, 1]\n", - " agent2_y = [3, 2, 1]\n", - "\n", - " # Create figure and axis\n", - " fig, ax = plt.subplots()\n", - "\n", - " # Plot Agent 1 texts\n", - " for i, text in enumerate(agent1_texts):\n", - " ax.text(0, agent1_y[i], text, fontsize=12, ha='right')\n", - "\n", - " # Plot Agent 2 texts\n", - " for i, text in enumerate(agent2_texts):\n", - " ax.text(1, agent2_y[i], text, fontsize=12, ha='left')\n", - "\n", - " # Set plot attributes\n", - " ax.set_xlim(-0.5, 1.5)\n", - " ax.set_ylim(0, 4)\n", - " ax.set_xticks([0, 1])\n", - " ax.set_xticklabels(['Agent 1', 'Agent 2'])\n", - " ax.set_yticks([])\n", - " ax.spines['top'].set_visible(False)\n", - " ax.spines['right'].set_visible(False)\n", - " ax.spines['bottom'].set_visible(False)\"\n", - "}\n", - "##FUNCTION_RETURN## (from function \"python\"): \n", - "None\n", - "unexpected indent (1440792568.py, line 4)\n", - "\n", - "\u001b[35m******************************Content after compressing:******************************\u001b[0m\n", - "##FUNCTION_CALL##\n", - "Name: python\n", - "Args: Executing a block of Python code that imports the matplotlib.pyplot library for graphing and plotting. It defines texts for two agents and sets y positions. It also creates a figure and plots the agent texts on a graph with specific attributes.\n", - " \n", - "##FUNCTION_RETURN## (from function \"python\"):\n", - "None. Execution failed due to an unexpected indentation error at line 4.\n", - " \u001b[35m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[35mToken Count (including 107 tokens from system msg and function descriptions). Before compression : 821 | After: 564\u001b[0m\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mchatbot\u001b[0m (to user_proxy):\n", - "\n", - "TERMINATE\n", - "\n", - "--------------------------------------------------------------------------------\n" - ] - } - ], - "source": [ - "llm_config = {\n", - " \"functions\": [\n", - " {\n", - " \"name\": \"python\",\n", - " \"description\": \"run cell in ipython and return the execution result.\",\n", - " \"parameters\": {\n", - " \"type\": \"object\",\n", - " \"properties\": {\n", - " \"cell\": {\n", - " \"type\": \"string\",\n", - " \"description\": \"Valid Python cell to execute.\",\n", - " }\n", - " },\n", - " \"required\": [\"cell\"],\n", - " },\n", - " },\n", - " {\n", - " \"name\": \"sh\",\n", - " \"description\": \"run a shell script and return the execution result.\",\n", - " \"parameters\": {\n", - " \"type\": \"object\",\n", - " \"properties\": {\n", - " \"script\": {\n", - " \"type\": \"string\",\n", - " \"description\": \"Valid shell script to execute.\",\n", - " }\n", - " },\n", - " \"required\": [\"script\"],\n", - " },\n", - " },\n", - " ],\n", - " \"config_list\": config_list,\n", - " \"timeout\": 120,\n", - "}\n", - "import autogen\n", - "from autogen.agentchat.contrib.compressible_agent import CompressibleAgent\n", - "\n", - "chatbot = CompressibleAgent(\n", - " name=\"chatbot\",\n", - " system_message=\"For coding tasks, only use the functions you have been provided with. Reply TERMINATE when the task is done.\",\n", - " llm_config=llm_config,\n", - " compress_config={\n", - " \"mode\": \"COMPRESS\",\n", - " \"trigger_count\": 600, # set this to a large number for less frequent compression\n", - " \"verbose\": True, # set this to False to suppress the compression log\n", - " \"leave_last_n\": 2,\n", - " }\n", - ")\n", - "\n", - "# create a UserProxyAgent instance named \"user_proxy\"\n", - "user_proxy = autogen.UserProxyAgent(\n", - " name=\"user_proxy\",\n", - " is_termination_msg=lambda x: x.get(\"content\", \"\") and x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\"),\n", - " human_input_mode=\"NEVER\",\n", - " max_consecutive_auto_reply=10,\n", - " code_execution_config={\"work_dir\": \"coding\"},\n", - ")\n", - "\n", - "# define functions according to the function desription\n", - "from IPython import get_ipython\n", - "\n", - "def exec_python(cell):\n", - " ipython = get_ipython()\n", - " result = ipython.run_cell(cell)\n", - " log = str(result.result)\n", - " if result.error_before_exec is not None:\n", - " log += f\"\\n{result.error_before_exec}\"\n", - " if result.error_in_exec is not None:\n", - " log += f\"\\n{result.error_in_exec}\"\n", - " return log\n", - "\n", - "def exec_sh(script):\n", - " return user_proxy.execute_code_blocks([(\"sh\", script)])\n", - "\n", - "# register the functions\n", - "user_proxy.register_function(\n", - " function_map={\n", - " \"python\": exec_python,\n", - " \"sh\": exec_sh,\n", - " }\n", - ")\n", - "\n", - "# start the conversation\n", - "user_proxy.initiate_chat(\n", - " chatbot,\n", - " message=\"Draw two agents chatting with each other with an example dialog. Don't add plt.show().\",\n", - ")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3\n", - "This example is from [agent_chat_web_info.ipynb](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_web_info.ipynb). \n", - "We use this example to demonstrate how to pass in a customized compression function. We pass in an compression function `constrain_num_messages`, which constrains the number of messages to be 3 or less. \n", - "The customized function should accept a list of messages as input and return a tuple of `(is_success: bool, compressed_messages: List[Dict])`." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to assistant):\n", - "\n", - "Show me the YTD gain of 10 largest technology companies as of today.\n", - "\n", - "--------------------------------------------------------------------------------\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33massistant\u001b[0m (to user_proxy):\n", - "\n", - "To fulfill your request, we first need a list of the 10 largest technology companies by market cap. Unfortunately, real-time financial data is gated behind paywalls, so it's difficult to get up-to-date reliable information through coding here. \n", - "\n", - "However, I can provide you a script to download YTD performance for a given list of companies if you already know the list. Below is an example using Yahoo Finance, for which Python has a usable API.\n", - "\n", - "Frequently mentioned largest technology companies include: Apple (AAPL), Microsoft (MSFT), Alphabet (GOOGL), Amazon (AMZN), Meta (FB), Tesla (TSLA), Alibaba group holding (BABA), Taiwan Semiconductor (TSM), Tencent (TCEHY), Oracle (ORCL). Adjust as necessary for your purpose.\n", - "\n", - "First, we need to install yfinance module:\n", - "\n", - "```sh\n", - "pip install yfinance\n", - "```\n", - "\n", - "Then, you can use this Python script to get the YTD performance. \n", - "\n", - "This Python script first gets the price at the beginning of the year, and then the most recent price. The difference between those two prices, divided by the starting price, gives the YTD performance.\n", - "\n", - "```python\n", - "# filename: ytd_gain.py\n", - "\n", - "import yfinance as yf\n", - "from datetime import datetime\n", - "\n", - "# Define the tickers\n", - "tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'FB', 'TSLA', 'BABA', 'TSM', 'TCEHY', 'ORCL']\n", - "now = datetime.now()\n", - "\n", - "# Define the current year\n", - "current_year = now.year\n", - "\n", - "# Iterate through each ticker\n", - "for ticker in tickers:\n", - " # Download the year-to-date data for this ticker\n", - " ticker_data = yf.download(ticker, start=f'{current_year}-01-01', end=f'{now.year}-{now.month}-{now.day}')\n", - "\n", - " # Get the close price at the beginning of the year\n", - " initial_price = ticker_data['Close'][0]\n", - "\n", - " # Get the most recent close price\n", - " most_recent_price = ticker_data['Close'][-1]\n", - "\n", - " # Calculate the year-to-date return\n", - " ytd_return = (most_recent_price - initial_price) / initial_price * 100\n", - "\n", - " # Print the result\n", - " print(f'The YTD return for {ticker} is {ytd_return:.2f}%')\n", - "```\n", - "\n", - "Run the file in shell:\n", - "\n", - "```sh\n", - "python ytd_gain.py\n", - "```\n", - "\n", - "The output will be the YTD gain (%) of each company to the console. Please note that actual results will depend on the input list of tickers and the current date.\n", - "\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[31m\n", - ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is sh)...\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[31m\n", - ">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is python)...\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to assistant):\n", - "\n", - "exitcode: 1 (execution failed)\n", - "Code output: \n", - "Requirement already satisfied: yfinance in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (0.2.31)\n", - "Requirement already satisfied: pandas>=1.3.0 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2.1.2)\n", - "Requirement already satisfied: numpy>=1.16.5 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (1.26.1)\n", - "Requirement already satisfied: requests>=2.31 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2.31.0)\n", - "Requirement already satisfied: multitasking>=0.0.7 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (0.0.11)\n", - "Requirement already satisfied: lxml>=4.9.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (4.9.3)\n", - "Requirement already satisfied: appdirs>=1.4.4 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (1.4.4)\n", - "Requirement already satisfied: pytz>=2022.5 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2023.3.post1)\n", - "Requirement already satisfied: frozendict>=2.3.4 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2.3.8)\n", - "Requirement already satisfied: peewee>=3.16.2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (3.17.0)\n", - "Requirement already satisfied: beautifulsoup4>=4.11.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (4.12.2)\n", - "Requirement already satisfied: html5lib>=1.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (1.1)\n", - "Requirement already satisfied: soupsieve>1.2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.5)\n", - "Requirement already satisfied: six>=1.9 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (1.16.0)\n", - "Requirement already satisfied: webencodings in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (0.5.1)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from pandas>=1.3.0->yfinance) (2.8.2)\n", - "Requirement already satisfied: tzdata>=2022.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from pandas>=1.3.0->yfinance) (2023.3)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.3.1)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.4)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2.0.7)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2023.7.22)\n", - "\n", - "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " initial_price = ticker_data['Close'][0]\n", - "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " most_recent_price = ticker_data['Close'][-1]\n", - "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " initial_price = ticker_data['Close'][0]\n", - "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " most_recent_price = ticker_data['Close'][-1]\n", - "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " initial_price = ticker_data['Close'][0]\n", - "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " most_recent_price = ticker_data['Close'][-1]\n", - "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " initial_price = ticker_data['Close'][0]\n", - "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", - " most_recent_price = ticker_data['Close'][-1]\n", - "\n", - "1 Failed download:\n", - "['FB']: Exception('%ticker%: No timezone found, symbol may be delisted')\n", - "Traceback (most recent call last):\n", - " File \"ytd_gain.py\", line 19, in \n", - " initial_price = ticker_data['Close'][0]\n", - " File \"/home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages/pandas/core/series.py\", line 1037, in __getitem__\n", - " return self._values[key]\n", - "IndexError: index 0 is out of bounds for axis 0 with size 0\n", - "\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33massistant\u001b[0m (to user_proxy):\n", - "\n", - "There seems to be an issue with the ticker symbol 'FB'. The error message shows 'FB': No timezone found, symbol may be delisted. This is because 'FB' has been recently changed to 'META' so the symbol 'FB' is causing the issue.\n", - "\n", - "We can replace 'FB' with 'META' and rerun the Python script. The error messages for series indexing are warnings rather than errors. It seems recent changes in pandas library caused these warnings. To resolve this, `iloc` function will be utilized to get the first and last items of the Series.\n", - "\n", - "Here is the updated Python script:\n", - "\n", - "```python\n", - "# filename: ytd_gain.py\n", - "\n", - "import yfinance as yf\n", - "from datetime import datetime\n", - "\n", - "# Define the tickers\n", - "tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'META', 'TSLA', 'BABA', 'TSM', 'TCEHY', 'ORCL']\n", - "now = datetime.now()\n", - "\n", - "# Define the current year\n", - "current_year = now.year\n", - "\n", - "# Iterate through each ticker\n", - "for ticker in tickers:\n", - " # Download the year-to-date data for this ticker\n", - " ticker_data = yf.download(ticker, start=f'{current_year}-01-01', end=f'{now.year}-{now.month}-{now.day}')\n", - "\n", - " # Get the close price at the beginning of the year\n", - " initial_price = ticker_data['Close'].iloc[0]\n", - "\n", - " # Get the most recent close price\n", - " most_recent_price = ticker_data['Close'].iloc[-1]\n", - "\n", - " # Calculate the year-to-date return\n", - " ytd_return = (most_recent_price - initial_price) / initial_price * 100\n", - "\n", - " # Print the result\n", - " print(f'The YTD return for {ticker} is {ytd_return:.2f}%')\n", - "```\n", - "\n", - "Run the file in shell:\n", - "\n", - "```sh\n", - "python ytd_gain.py\n", - "```\n", - "\n", - "This script will print the YTD gain (%) of each company to the console.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[31m\n", - ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[31m\n", - ">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is sh)...\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to assistant):\n", - "\n", - "exitcode: 0 (execution succeeded)\n", - "Code output: \n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for AAPL is 41.24%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for MSFT is 47.26%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for GOOGL is 44.86%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for AMZN is 61.50%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for META is 152.20%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for TSLA is 103.48%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for BABA is -7.25%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for TSM is 23.99%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for TCEHY is -12.16%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for ORCL is 29.06%\n", - "\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for AAPL is 41.24%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for MSFT is 47.26%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for GOOGL is 44.86%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for AMZN is 61.50%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for META is 152.20%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for TSLA is 103.48%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for BABA is -7.25%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for TSM is 23.99%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for TCEHY is -12.16%\n", - "\n", - "[*********************100%%**********************] 1 of 1 completed\n", - "The YTD return for ORCL is 29.06%\n", - "\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[35mToken Count (including 468 tokens from system msg and function descriptions). Before compression : 3684 | After: 1509\u001b[0m\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33massistant\u001b[0m (to user_proxy):\n", - "\n", - "It appears that you've run the script twice, as the results are duplicated. From the code output, here are the Year-to-Date (YTD) returns for the 10 largest technology companies:\n", - "\n", - "1. AAPL (Apple): 41.24% gain\n", - "2. MSFT (Microsoft): 47.26% gain\n", - "3. GOOGL (Alphabet Class A): 44.86% gain\n", - "4. AMZN (Amazon): 61.50% gain\n", - "5. META (Meta Platforms, previously Facebook): 152.20% gain\n", - "6. TSLA (Tesla): 103.48% gain\n", - "7. BABA (Alibaba): -7.25% loss\n", - "8. TSM (Taiwan Semiconductor Manufacturing): 23.99% gain\n", - "9. TCEHY (Tencent Holdings): -12.16% loss\n", - "10. ORCL (Oracle): 29.06% gain\n", - "\n", - "Please note, the percentage change could have slight differences due to market volatility and the exact times the prices were taken. \n", - "\n", - "If everything looks good, let's wrap up. If you need any more help with other tasks, just let me know! \n", - "\n", - "TERMINATE\n", - "\n", - "--------------------------------------------------------------------------------\n" - ] - } - ], - "source": [ - "import autogen\n", - "from autogen.agentchat.contrib.math_user_proxy_agent import MathUserProxyAgent\n", - "from autogen.agentchat.contrib.compressible_agent import CompressibleAgent\n", - "\n", - "def constrain_num_messages(messages):\n", - " \"\"\"Constrain the number of messages to 3.\n", - " \n", - " This is an example of a customized compression function.\n", - "\n", - " Returns:\n", - " bool: whether the compression is successful.\n", - " list: the compressed messages.\n", - " \"\"\"\n", - " if len(messages) <= 3:\n", - " # do nothing\n", - " return False, None\n", - " \n", - " # save the first and last two messages\n", - " return True, messages[:1] + messages[-2:]\n", - "\n", - "# create a CompressibleAgent instance named \"assistant\"\n", - "assistant = CompressibleAgent(\n", - " name=\"assistant\",\n", - " llm_config={\n", - " \"timeout\": 600,\n", - " \"seed\": 43,\n", - " \"config_list\": config_list,\n", - " },\n", - " compress_config={\n", - " \"mode\": \"CUSTOMIZED\",\n", - " \"compress_function\": constrain_num_messages, # this is required for customized compression\n", - " \"trigger_count\": 1600, \n", - " },\n", - ")\n", - "\n", - "# create a UserProxyAgent instance named \"user_proxy\"\n", - "user_proxy = autogen.UserProxyAgent(\n", - " name=\"user_proxy\",\n", - " human_input_mode=\"TERMINATE\",\n", - " max_consecutive_auto_reply=10,\n", - " is_termination_msg=lambda x: x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\") or x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE.\"),\n", - " code_execution_config={\"work_dir\": \"web\"},\n", - " system_message=\"\"\"Reply TERMINATE if the task has been solved at full satisfaction.\n", - "Otherwise, reply CONTINUE, or the reason why the task is not solved yet.\"\"\"\n", - ")\n", - "\n", - "user_proxy.initiate_chat(\n", - " assistant,\n", - " message=\"\"\"Show me the YTD gain of 10 largest technology companies as of today.\"\"\",\n", - ")\n" + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Auto Generated Agent Chat: Conversations with Chat History Compression Enabled (Experimental)\n", + "\n", + "AutoGen offers conversable agents powered by LLM, tools, or humans, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n", + "\n", + "In this notebook, we demonstrate how to enable compression of history messages using the `CompressibleAgent`. While this agent retains all the default functionalities of the `AssistantAgent`, it also provides the added feature of compression when activated through the `compress_config` setting.\n", + "\n", + "Different compression modes are supported:\n", + "1. `compress_config=False` (Default): `CompressibleAgent` is equivalent to `AssistantAgent`.\n", + "2. `compress_config=True` or `compress_config={\"mode\": \"TERMINATE\"}`: no compression will be performed. However, we will count token usage before sending requests to the OpenAI model. The conversation will be terminated directly if the total token usage exceeds the maximum token usage allowed by the model (to avoid the token limit error from OpenAI API).\n", + "3. `compress_config={\"mode\": \"COMPRESS\", \"trigger_count\": }, \"leave_last_n\": `: compression is enabled.\n", + " ```python\n", + " # default compress_config\n", + " compress_config = {\n", + " \"mode\": \"COMPRESS\",\n", + " \"compress_function\": None,\n", + " \"trigger_count\": 0.7, # default to 0.7, or your pre-set number\n", + " \"broadcast\": True, # the compressed with be broadcast to sender. This will not be used in groupchat.\n", + "\n", + " # the following settings are for this mode only\n", + " \"leave_last_n\": 2, # leave the last n messages in the history to avoid compression\n", + " \"verbose\": False, # if True, print out the content to be compressed and the compressed content\n", + " }\n", + " ```\n", + " Currently, our compression logic is as follows:\n", + " 1. We will always leave the first user message (as well as system prompts) and compress the rest of the history messages.\n", + " 2. You can choose to not compress the last n messages in the history with \"leave_last_n\".\n", + " 2. The summary is performed on a per-message basis, with the role of the messages (See compressed content in the example below).\n", + "\n", + "4. `compress_config={\"mode\": \"CUSTOMIZED\", \"compress_function\": }`: the `compress_function` function will be called on trigger count. The function should accept a list of messages as input and return a tuple of (is_success: bool, compressed_messages: List[Dict]). The whole message history (except system prompt) will be passed.\n", + "\n", + "\n", + "By adjusting `trigger_count`, you can decide when to compress the history messages based on existing tokens. If this is a float number between 0 and 1, it is interpreted as a ratio of max tokens allowed by the model. For example, the AssistantAgent uses gpt-4 with max tokens 8192, the trigger_count = 0.7 * 8192 = 5734.4 -> 5734. Do not set `trigger_count` to the max tokens allowed by the model, since the same LLM is employed for compression and it needs tokens to generate the compressed content. \n", + "\n", + "\n", + "\n", + "## Limitations\n", + "- For now, the compression feature **is not well-supported for groupchat**. If you initialize a `CompressibleAgent` in a groupchat with compression, the compressed cannot be broadcast to all other agents in the groupchat. If you use this feature in groupchat, extra cost will be incurred since compression will be performed on at per-agent basis.\n", + "- We do not support async compression for now.\n", + "\n", + "## Requirements\n", + "\n", + "AutoGen requires `Python>=3.8`. To run this notebook example, please install:\n", + "```bash\n", + "pip install pyautogen\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# %pip install pyautogen~=0.1.0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set your API Endpoint\n", + "\n", + "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import autogen\n", + "config_list = autogen.config_list_from_json(\n", + " \"OAI_CONFIG_LIST\",\n", + " filter_dict={\n", + " \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n", + " },\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It first looks for environment variable \"OAI_CONFIG_LIST\" which needs to be a valid json string. If that variable is not found, it then looks for a json file named \"OAI_CONFIG_LIST\". It filters the configs by models (you can filter by other keys as well).\n", + "\n", + "The config list looks like the following:\n", + "```python\n", + "config_list = [\n", + " {\n", + " 'model': 'gpt-4',\n", + " 'api_key': '',\n", + " },\n", + " {\n", + " 'model': 'gpt-4',\n", + " 'api_key': '',\n", + " 'base_url': '',\n", + " 'api_type': 'azure',\n", + " 'api_version': '2023-06-01-preview',\n", + " },\n", + " {\n", + " 'model': 'gpt-4-32k',\n", + " 'api_key': '',\n", + " 'base_url': '',\n", + " 'api_type': 'azure',\n", + " 'api_version': '2023-06-01-preview',\n", + " },\n", + "]\n", + "```\n", + "\n", + "If you open this notebook in colab, you can upload your files by clicking the file icon on the left panel and then choose \"upload file\" icon.\n", + "\n", + "You can set the value of config_list in other ways you prefer, e.g., loading from a YAML file." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1\n", + "This example is from [agentchat_MathChat.ipynb](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_MathChat.ipynb). Compression with code execution.\n", + "\n", + "Note: we set `trigger_count=600`, and `leave_last_n=2`. In this example, we set a low trigger_count to demonstrate the compression feature. \n", + "The token count after compression is still bigger than trigger count, mainly because the trigger count is low an the first and last 2 messages are not compressed. Thus, the compression is performed at each turn. In practice, you want to adjust the trigger_count to a bigger number and properly set the `leave_last_n` to avoid compression at each turn. " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", + "\n", + "Let's use Python to solve a math problem.\n", + "\n", + "Query requirements:\n", + "You should always use the 'print' function for the output and use fractions/radical forms instead of decimals.\n", + "You can use packages like sympy to help you.\n", + "You must follow the formats below to write your code:\n", + "```python\n", + "# your code\n", + "```\n", + "\n", + "First state the key idea to solve the problem. You may choose from three ways to solve the problem:\n", + "Case 1: If the problem can be solved with Python code directly, please write a program to solve it. You can enumerate all possible arrangements if needed.\n", + "Case 2: If the problem is mostly reasoning, you can solve it by yourself directly.\n", + "Case 3: If the problem cannot be handled in the above two ways, please follow this process:\n", + "1. Solve the problem step by step (do not over-divide the steps).\n", + "2. Take out any queries that can be asked through Python (for example, any calculations or equations that can be calculated).\n", + "3. Wait for me to give the results.\n", + "4. Continue if you think the result is correct. If the result is invalid or unexpected, please correct your query or reasoning.\n", + "\n", + "After all the queries are run and you get the answer, put the answer in \\boxed{}.\n", + "\n", + "Problem:\n", + "Find all $x$ that satisfy the inequality $(2x+10)(x+3)<(3x+9)(x+8)$. Express your answer in interval notation.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", + "\n", + "First, we need to consider both sides of the inequality as two separate equations. Then subtract one from the other to set this result equal to zero. This would allow us to find the critical points, i.e., the places where the inequality changes its nature (from less to more or vice versa). Then we find the intervals.\n", + "\n", + "Here's how you can solve this problem in Python:\n", + "\n", + "```python\n", + "from sympy import *\n", + "from sympy.abc import x\n", + "\n", + "# define the equation\n", + "equation = (2*x+10)*(x+3) - (3*x+9)*(x+8)\n", + "\n", + "# set the equation equal to zero to find the critical points\n", + "critical_points = solve(equation, x)\n", + "\n", + "# Sort the critical_points\n", + "critical_points = sorted(critical_points)\n", + "\n", + "# define a function to test the intervals\n", + "def test_intervals(interval):\n", + " test_num = sum(interval)/2 # get the mid point of the interval\n", + " return equation.subs(x, test_num)\n", + "\n", + "# define the intervals based on the critical points\n", + "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", + "\n", + "solution = []\n", + "\n", + "# loop through the intervals, if the result is less than zero, it means it's a valid interval\n", + "for i in intervals:\n", + " if test_intervals(i) < 0:\n", + " solution.append(i)\n", + "\n", + "# print the solution in interval notation\n", + "for interval in solution:\n", + " print(interval)\n", + "```\n", + "\n", + "Replace oo with infinity when interpreting the result. Also, keep in mind that in interval notation, parentheses denote that the endpoint is not included in the set, and brackets denote that the end point is included in the set. Thus, (a, b) means \"greater than a and less than b\", [a, b] means \"greater than or equal to a and less than or equal to b\".\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", + "\n", + "Error: Traceback (most recent call last):\n", + " File \"\", line 25, in \n", + " if test_intervals(i) < 0:\n", + " return func(self, other)\n", + " return StrictLessThan(self, other)\n", + " raise TypeError(\"Invalid NaN comparison\")\n", + "TypeError: Invalid NaN comparison\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Warning: Compression skipped at trigger count threshold. The first msg and last 2 msgs will not be compressed. current msg count: 3. Consider raising trigger_count.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", + "\n", + "I apologize for the oversight. It seems like the function is returning NaN error. Because we are dealing with real numbers, NaN (Not a Number) error could arise from operations that don't return a defined real number. \n", + "\n", + "However, in this case, we it seems there's a problem with the comparison of symbolic terms with zero in the function test_intervals.\n", + "\n", + "Let's correct this approach. The error arises from trying to compare a symbolic expression to zero directly. Instead, we can create a numeric function from our symbolic expression, and use this function to test the intervals. \n", + "\n", + "Here is the revised code:\n", + "\n", + "```python\n", + "from sympy import *\n", + "from sympy.abc import x\n", + "\n", + "# define the equation\n", + "equation = expand((2*x+10)*(x+3) - (3*x+9)*(x+8))\n", + "\n", + "# set the equation equal to zero to find the critical points\n", + "critical_points = solve(equation, x)\n", + "\n", + "# Convert the points to standard python floats, so that they can be sorted numerically\n", + "critical_points = [N(i) for i in critical_points]\n", + "\n", + "# Sort the critical_points\n", + "critical_points = sorted(critical_points)\n", + "\n", + "# define a function to test the intervals\n", + "def test_intervals(interval):\n", + " test_num = N(sum(interval)/2) # get the mid point of the interval\n", + " return equation.subs(x, test_num)\n", + "\n", + "# define the intervals based on the critical points\n", + "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", + "\n", + "# Now, let's create a numeric function from this symbolic equation\n", + "numeric_equation = lambdify(x, equation)\n", + "\n", + "solution = []\n", + "\n", + "# loop through the intervals, first find the mid point of each interval, \n", + "# then if numeric result for this mid point is less than zero, it means it's a valid interval\n", + "for interval in intervals:\n", + " mid_point = sum(interval) / 2 \n", + " if numeric_equation(mid_point) < 0:\n", + " solution.append(interval)\n", + "\n", + "# print the solution in interval notation\n", + "for interval in solution:\n", + " print(interval)\n", + "```\n", + "\n", + "Remember to replace `oo` with infinity while interpreting the output.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", + "\n", + "Error: Traceback (most recent call last):\n", + " File \"\", line 36, in \n", + " if numeric_equation(mid_point) < 0:\n", + " return func(self, other)\n", + " return StrictLessThan(self, other)\n", + " raise TypeError(\"Invalid NaN comparison\")\n", + "TypeError: Invalid NaN comparison\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35m******************************Start compressing the following content:******************************\u001b[0m\n", + "To be compressed:\n", + "##ASSISTANT## First, we need to consider both sides of the inequality as two separate equations. Then subtract one from the other to set this result equal to zero. This would allow us to find the critical points, i.e., the places where the inequality changes its nature (from less to more or vice versa). Then we find the intervals.\n", + "\n", + "Here's how you can solve this problem in Python:\n", + "\n", + "```python\n", + "from sympy import *\n", + "from sympy.abc import x\n", + "\n", + "# define the equation\n", + "equation = (2*x+10)*(x+3) - (3*x+9)*(x+8)\n", + "\n", + "# set the equation equal to zero to find the critical points\n", + "critical_points = solve(equation, x)\n", + "\n", + "# Sort the critical_points\n", + "critical_points = sorted(critical_points)\n", + "\n", + "# define a function to test the intervals\n", + "def test_intervals(interval):\n", + " test_num = sum(interval)/2 # get the mid point of the interval\n", + " return equation.subs(x, test_num)\n", + "\n", + "# define the intervals based on the critical points\n", + "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", + "\n", + "solution = []\n", + "\n", + "# loop through the intervals, if the result is less than zero, it means it's a valid interval\n", + "for i in intervals:\n", + " if test_intervals(i) < 0:\n", + " solution.append(i)\n", + "\n", + "# print the solution in interval notation\n", + "for interval in solution:\n", + " print(interval)\n", + "```\n", + "\n", + "Replace oo with infinity when interpreting the result. Also, keep in mind that in interval notation, parentheses denote that the endpoint is not included in the set, and brackets denote that the end point is included in the set. Thus, (a, b) means \"greater than a and less than b\", [a, b] means \"greater than or equal to a and less than or equal to b\".\n", + "##USER## Error: Traceback (most recent call last):\n", + " File \"\", line 25, in \n", + " if test_intervals(i) < 0:\n", + " return func(self, other)\n", + " return StrictLessThan(self, other)\n", + " raise TypeError(\"Invalid NaN comparison\")\n", + "TypeError: Invalid NaN comparison\n", + "\n", + "\u001b[35m******************************Content after compressing:******************************\u001b[0m\n", + "##ASSISTANT##\n", + "The assistant provides instructions to solve an inequality, which involves considering separate equations for the inequality components, finding the differing point (set to zero), identifying critical points (where nature of inequality changes), and determining the intervals. \n", + "\n", + "They also share Python code for the process, using sympy library. Steps include defining the equation, finding critical points by setting equation to zero, sorting these points, defining a function to test the intervals, determining intervals based on critical points, and looping through intervals to identify valid solutions. The assistant defines 'oo' as infinity and clarifies the use of parentheses and brackets to denote exclusion or inclusion of endpoints in interval notation.\n", + "\n", + "##CODE##\n", + "Python script to solve the given inequality and display the solution using interval notation.\n", + "\n", + "##USER##\n", + "User encounters 'TypeError: Invalid NaN comparison', indicating there's an error when comparing a test interval to zero in the Python script shared by the assistant.\n", + " \u001b[35m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[35mToken Count (including 13 tokens from system msg and function descriptions). Before compression : 1294 | After: 1045\u001b[0m\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", + "\n", + "I apologize for the confusion. There's an error with the calculation of mid_point when the interval is from negative infinity to a real number or a real number to infinity. In these circumstances, the calculation will return a NaN which cannot be used in comparison. We could handle these issues specifically.\n", + "\n", + "Let's refine the script:\n", + "\n", + "```python\n", + "from sympy import *\n", + "from sympy.abc import x\n", + "\n", + "# define the equation\n", + "equation = expand((2*x+10)*(x+3) - (3*x+9)*(x+8))\n", + "\n", + "# set the equation equal to zero to find the critical points\n", + "critical_points = solve(equation, x)\n", + "\n", + "# Convert the points to standard python floats, so that they can be sorted numerically\n", + "critical_points = [N(i) for i in critical_points]\n", + "\n", + "# Sort the critical_points\n", + "critical_points = sorted(critical_points)\n", + "\n", + "# Now, let's create a numeric function from this symbolic equation\n", + "numeric_equation = lambdify(x, equation)\n", + "\n", + "solution = []\n", + "\n", + "# Define the intervals based on the critical points\n", + "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", + "\n", + "# Loop through the intervals and compute the mid point of each interval\n", + "# If the mid point is NaN (occurs when dealing with infinity), then specific values are used for testing\n", + "for interval in intervals:\n", + " if interval[0] == -oo:\n", + " test_value = interval[1] - 1\n", + " elif interval[1] == oo:\n", + " test_value = interval[0] + 1\n", + " else:\n", + " test_value = sum(interval) / 2\n", + "\n", + " # If numeric result for test_value is less than zero, it's a valid interval\n", + " if numeric_equation(test_value) < 0:\n", + " solution.append(interval)\n", + "\n", + "# Print out the solution intervals\n", + "for interval in solution:\n", + " print(interval)\n", + "```\n", + "\n", + "The script now handles the special cases when dealing with infinity and should return the valid intervals.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mmathproxyagent\u001b[0m (to assistant):\n", + "\n", + "(-oo, -14.0000000000000)\n", + "(-3.00000000000000, oo)\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35m******************************Start compressing the following content:******************************\u001b[0m\n", + "To be compressed:\n", + "##ASSISTANT##\n", + "The assistant provides instructions to solve an inequality, which involves considering separate equations for the inequality components, finding the differing point (set to zero), identifying critical points (where nature of inequality changes), and determining the intervals. \n", + "\n", + "They also share Python code for the process, using sympy library. Steps include defining the equation, finding critical points by setting equation to zero, sorting these points, defining a function to test the intervals, determining intervals based on critical points, and looping through intervals to identify valid solutions. The assistant defines 'oo' as infinity and clarifies the use of parentheses and brackets to denote exclusion or inclusion of endpoints in interval notation.\n", + "\n", + "##CODE##\n", + "Python script to solve the given inequality and display the solution using interval notation.\n", + "\n", + "##USER##\n", + "User encounters 'TypeError: Invalid NaN comparison', indicating there's an error when comparing a test interval to zero in the Python script shared by the assistant.\n", + "\n", + "##ASSISTANT## I apologize for the oversight. It seems like the function is returning NaN error. Because we are dealing with real numbers, NaN (Not a Number) error could arise from operations that don't return a defined real number. \n", + "\n", + "However, in this case, we it seems there's a problem with the comparison of symbolic terms with zero in the function test_intervals.\n", + "\n", + "Let's correct this approach. The error arises from trying to compare a symbolic expression to zero directly. Instead, we can create a numeric function from our symbolic expression, and use this function to test the intervals. \n", + "\n", + "Here is the revised code:\n", + "\n", + "```python\n", + "from sympy import *\n", + "from sympy.abc import x\n", + "\n", + "# define the equation\n", + "equation = expand((2*x+10)*(x+3) - (3*x+9)*(x+8))\n", + "\n", + "# set the equation equal to zero to find the critical points\n", + "critical_points = solve(equation, x)\n", + "\n", + "# Convert the points to standard python floats, so that they can be sorted numerically\n", + "critical_points = [N(i) for i in critical_points]\n", + "\n", + "# Sort the critical_points\n", + "critical_points = sorted(critical_points)\n", + "\n", + "# define a function to test the intervals\n", + "def test_intervals(interval):\n", + " test_num = N(sum(interval)/2) # get the mid point of the interval\n", + " return equation.subs(x, test_num)\n", + "\n", + "# define the intervals based on the critical points\n", + "intervals = [(-oo, critical_points[0]), (critical_points[0], critical_points[1]), (critical_points[1], oo)]\n", + "\n", + "# Now, let's create a numeric function from this symbolic equation\n", + "numeric_equation = lambdify(x, equation)\n", + "\n", + "solution = []\n", + "\n", + "# loop through the intervals, first find the mid point of each interval, \n", + "# then if numeric result for this mid point is less than zero, it means it's a valid interval\n", + "for interval in intervals:\n", + " mid_point = sum(interval) / 2 \n", + " if numeric_equation(mid_point) < 0:\n", + " solution.append(interval)\n", + "\n", + "# print the solution in interval notation\n", + "for interval in solution:\n", + " print(interval)\n", + "```\n", + "\n", + "Remember to replace `oo` with infinity while interpreting the output.\n", + "##USER## Error: Traceback (most recent call last):\n", + " File \"\", line 36, in \n", + " if numeric_equation(mid_point) < 0:\n", + " return func(self, other)\n", + " return StrictLessThan(self, other)\n", + " raise TypeError(\"Invalid NaN comparison\")\n", + "TypeError: Invalid NaN comparison\n", + "\n", + "\u001b[35m******************************Content after compressing:******************************\u001b[0m\n", + "##ASSISTANT##\n", + "The assistant provides steps to solve an inequality, including considering separate equations, finding the differing point (set to zero), identifying critical points, and determining intervals. They provide Python code using sympy for the process, defining 'oo' as infinity and explaining usage of parentheses and brackets in interval notation. \n", + "\n", + "##CODE##\n", + "The assistant provides Python code for solving an inequality and displaying the solution in interval notation.\n", + "\n", + "##USER##\n", + "The user reports encountering a 'TypeError: Invalid NaN comparison' when comparing a test interval to zero in the script provided by the assistant.\n", + "\n", + "##ASSISTANT##\n", + "The assistant apologizes for the oversight and suggests the issue might lie in the comparison of symbolic terms with zero. The assistant then provides revised code, explaining it creates a numeric function from the symbolic expression to test the intervals. It's highlighted to replace 'oo' with infinity when interpreting the output.\n", + "\n", + "##CODE##\n", + "Revised Python code is given by the assistant to solve a TypeError that occurred in the initial code.\n", + "\n", + "##USER##\n", + "The user reports another TypeError ('Invalid NaN comparison') when executing the revised code provided by the assistant. \u001b[35m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[35mToken Count (including 13 tokens from system msg and function descriptions). Before compression : 1494 | After: 1013\u001b[0m\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33massistant\u001b[0m (to mathproxyagent):\n", + "\n", + "Great! You have got the correct answer.\n", + "\n", + "So, for $x$ in the interval $(-\\infty, -14]$ and $(-3, +\\infty)$, the inequality $(2x+10)(x+3)<(3x+9)(x+8)$ is satisfied. \n", + "\n", + "In interval notation, this result can be written as $(-\\infty, -14] \\cup (-3, +\\infty)$.\n", + "\n", + "The final answer is:\n", + "\n", + "\\boxed{(-\\infty, -14] \\cup (-3, +\\infty)}\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], + "source": [ + "from autogen.agentchat.contrib.math_user_proxy_agent import MathUserProxyAgent\n", + "from autogen.agentchat.contrib.compressible_agent import CompressibleAgent\n", + "\n", + "# 1. replace AssistantAgent with CompressibleAgent\n", + "assistant = CompressibleAgent(\n", + " name=\"assistant\", \n", + " system_message=\"You are a helpful assistant.\",\n", + " llm_config={\n", + " \"timeout\": 600,\n", + " \"cache_seed\": 42,\n", + " \"config_list\": config_list,\n", + " },\n", + " compress_config={\n", + " \"mode\": \"COMPRESS\",\n", + " \"trigger_count\": 600, # set this to a large number for less frequent compression\n", + " \"verbose\": True, # to allow printing of compression information: contex before and after compression\n", + " \"leave_last_n\": 2,\n", + " }\n", + ")\n", + "\n", + "# 2. create the MathUserProxyAgent instance named \"mathproxyagent\"\n", + "mathproxyagent = MathUserProxyAgent(\n", + " name=\"mathproxyagent\", \n", + " human_input_mode=\"NEVER\",\n", + " code_execution_config={\"use_docker\": False},\n", + " max_consecutive_auto_reply=5,\n", + ")\n", + "math_problem = \"Find all $x$ that satisfy the inequality $(2x+10)(x+3)<(3x+9)(x+8)$. Express your answer in interval notation.\"\n", + "mathproxyagent.initiate_chat(assistant, problem=math_problem)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2\n", + "This example is from [agentchat_function_call.ipynb](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_function_call.ipynb). Compression with function calls. " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33muser_proxy\u001b[0m (to chatbot):\n", + "\n", + "Draw two agents chatting with each other with an example dialog. Don't add plt.show().\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mchatbot\u001b[0m (to user_proxy):\n", + "\n", + "\u001b[32m***** Suggested function Call: python *****\u001b[0m\n", + "Arguments: \n", + "{\n", + " \"cell\": \n", + " \"import matplotlib.pyplot as plt\n", + "\n", + " # Define agent texts\n", + " agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\n", + " agent2_texts = ['Hey!', 'Nice meeting you too.', 'Could you help me solve a problem?']\n", + "\n", + " # Define agent y positions\n", + " agent1_y = [3, 2, 1]\n", + " agent2_y = [3, 2, 1]\n", + "\n", + " # Create figure and axis\n", + " fig, ax = plt.subplots()\n", + "\n", + " # Plot Agent 1 texts\n", + " for i, text in enumerate(agent1_texts):\n", + " ax.text(0, agent1_y[i], text, fontsize=12, ha='right')\n", + "\n", + " # Plot Agent 2 texts\n", + " for i, text in enumerate(agent2_texts):\n", + " ax.text(1, agent2_y[i], text, fontsize=12, ha='left')\n", + "\n", + " # Set plot attributes\n", + " ax.set_xlim(-0.5, 1.5)\n", + " ax.set_ylim(0, 4)\n", + " ax.set_xticks([0, 1])\n", + " ax.set_xticklabels(['Agent 1', 'Agent 2'])\n", + " ax.set_yticks([])\n", + " ax.spines['top'].set_visible(False)\n", + " ax.spines['right'].set_visible(False)\n", + " ax.spines['bottom'].set_visible(False)\"\n", + "}\n", + "\u001b[32m*******************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION python...\u001b[0m\n" + ] + }, + { + "ename": "IndentationError", + "evalue": "unexpected indent (1440792568.py, line 4)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m Cell \u001b[0;32mIn[3], line 4\u001b[0;36m\u001b[0m\n\u001b[0;31m agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33muser_proxy\u001b[0m (to chatbot):\n", + "\n", + "\u001b[32m***** Response from calling function \"python\" *****\u001b[0m\n", + "None\n", + "unexpected indent (1440792568.py, line 4)\n", + "\u001b[32m***************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mchatbot\u001b[0m (to user_proxy):\n", + "\n", + "\u001b[32m***** Suggested function Call: python *****\u001b[0m\n", + "Arguments: \n", + "{\n", + " \"cell\": \n", + " \"import matplotlib.pyplot as plt\n", + "\n", + "# Define agent texts\n", + "agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\n", + "agent2_texts = ['Hey!', 'Nice meeting you too.', 'Could you help me solve a problem?']\n", + "\n", + "# Define agent y positions\n", + "agent1_y = [3, 2, 1]\n", + "agent2_y = [3, 2, 1]\n", + "\n", + "# Create figure and axis\n", + "fig, ax = plt.subplots()\n", + "\n", + "# Plot Agent 1 texts\n", + "for i, text in enumerate(agent1_texts):\n", + " ax.text(0, agent1_y[i], text, fontsize=12, ha='right')\n", + "\n", + "# Plot Agent 2 texts\n", + "for i, text in enumerate(agent2_texts):\n", + " ax.text(1, agent2_y[i], text, fontsize=12, ha='left')\n", + "\n", + "# Set plot attributes\n", + "ax.set_xlim(-0.5, 1.5)\n", + "ax.set_ylim(0, 4)\n", + "ax.set_xticks([0, 1])\n", + "ax.set_xticklabels(['Agent 1', 'Agent 2'])\n", + "ax.set_yticks([])\n", + "ax.spines['top'].set_visible(False)\n", + "ax.spines['right'].set_visible(False)\n", + "ax.spines['bottom'].set_visible(False)\"\n", + "}\n", + "\u001b[32m*******************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION python...\u001b[0m\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAu0AAAGdCAYAAACmdE07AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAABIHElEQVR4nO3deZyN9f//8eeZxeyGMWMfMwzGvjQ+JMbYMlmKki2MJVGRSAsq+xLZd0qUoY+IdpEIoaJQyJKtPpU1M9YsM+/fH35zfR1nVttceNxvt7nVeV/vc53XdZ1zrvfzXOc6bw5jjBEAAAAA23LL7gIAAAAApI/QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAMDmCO0AAACAzRHaAQAAAJsjtAMAAAA2d8+HdmOMTp06Jf6NKQAAANjVPR/aT58+rcDAQJ0+fTq7SwEAAABSdc+HdgAAAMDuCO0AAACAzRHaAQAAAJsjtAMAAAA2R2gHAAAAbI7QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAMDmCO0AAACAzRHaAQAAAJsjtAMAAAA2R2gHAAAAbI7QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAMDmCO0AAACAzRHaAQAAAJsjtAMAAAA2R2gHAAAAbI7QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAMDmCO0AAACAzRHaAQAAAJsjtAMAAAA2R2gHAAAAbI7QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAMDmCO0AAACAzRHaAQAAAJsjtAMAAAA2R2gHAAAAbI7QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAMDmCO0AAACAzRHaAQAAAJsjtAMAAAA2R2gHAAAAbI7QDgAAANgcoR0AAACwOUI7AAAAYHOEdgAAAM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E3L/PnzNW3aND333HPq06eP1qxZo5YtW+q1117Tl19+qVdeeUVdu3bVp59+qhdffNHpvvPmzVPjxo3l7++vUaNG6fXXX9fOnTtVs2bNDIProEGDNHjwYNWpU0dTpkzRq6++qiJFiuinn36y+qxcuVKxsbE6evSoBg0apBdeeEEbNmxQjRo10l1/q1atdODAAW3atMmp/dChQ/ruu++cXrfDhw9XXFycSpQooXHjxqlXr176+uuvVatWLSs3pGXTpk3asGGDWrdurUmTJunpp5/W119/rdq1a+vcuXPp3jfFe++9p0mTJql79+7q16+ftm/frrp16+rIkSNO/S5fvqzY2FjlzZtXY8aMUfPmzbP8el6zZo169eqldu3aaciQITpx4oQeeughl/fNtbLyPCclJalhw4YKDQ3V6NGjFR4erh49emju3Ll66KGHVKVKFY0aNUoBAQGKi4vTgQMH0nzcyZMna//+/ercuXOm9qUkyWTBnDlzjKR0/8qWLWv137p1q5FkunTp4rSeF1980Ugyq1atMsYYc/ToUSPJTJs2zRhjTEJCgnFzczMtWrQw+fLls+7Xs2dPExQUZJKTk9Osce/evcbNzc08+uijJikpyWnZ1fc7d+6cMcaYxMREI8kkJiaabt26GV9fX/Pvv/9a/WJiYowk895771ltFy5cMPnz5zfNmzfPcJ+FhYWZxo0bZ9gvpZ6rXVvPli1bjCSzaNGiNNczfvx4I8kcO3YszT4HDhwwksycOXOMMcacPHnSSDJvvvlmujWWLVvWxMTEZLgtxhize/duI8lMnz7dqf2RRx4x4eHh1nMxYcIEI8nEx8dbfS5evGiqV69u/P39zalTp4wxxqxevdpIMqtXr053W67VtWtX43A4zIIFCzJVN4A7W8oxvWnTppnqn9lxyhhjJJmBAwe6rCMsLMx06NDBun3t8erixYsmb968plKlSubChQtWv1mzZhlJGR5XExISjLe3t3nllVec2nv27Gn8/PzMmTNnjDHGfPTRR0aSGTZsmFO/xx9/3DgcDvPbb78ZY9I/bqa1jVdL2b7SpUs7bc/EiRONJPPLL78YY66MuSVKlDCxsbEu42/RokXNgw8+aLWl5IsDBw5YbWF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Uh05csQpZEdFRWn69OkaNmyYihcvrrx58zqdNUpN48aNlSdPHi1atEgNGzZU3rx5nZZ37dpVM2fOVMeOHfXjjz8qPDxcixcvts7Kp3y6DgwMVIsWLTR58mQ5HA5FRETos88+S/fbkXr16ik8PNxlbncAd7eIiAgtWLBArVq1UunSpZ3+RdQNGzZo0aJF1rzqWRmnunTpoqefflrNmzfXgw8+qG3btmn58uUKDg5Otx5PT08NGzZM3bp1U926da0p++bMmZPpa9olqXLlyipXrpwWLVqk0qVL67777nNa/vDDD6tOnTp69dVXdfDgQVWsWFErVqzQxx9/rF69ellnFVO25Y033lCXLl1UpUoVrV271jqDfbO4ubnp7bffVsOGDVW2bFl16tRJhQoV0p9//qnVq1crZ86c+vTTT9NdR8mSJfXkk09q06ZNypcvn9555x0dOXJEc+bMuam1XitnzpyaPn262rdvr/vuu0+tW7dWSEiIfv/9d33++eeqUaOGS5i8WpkyZVS7dm1FRUUpKChImzdv1uLFi53C2ptvvqmGDRuqevXqevLJJ3X+/HlNnjxZgYGBmZorP2VO8xdffNEpB6SIiIjQsGHD1K9fPx08eFDNmjVTQECADhw4oKVLl6pr164u01xerUmTJpo3b54CAwNVpkwZbdy4UStXrlSePHky3oH/X/HixVWzZk0988wzunDhgiZMmKA8efLo5ZdfzvC+WXk9S1K5cuUUGxurnj17ysvLy/oQOnjw4DQf40af5+vRr18/vfvuu9d3tj0rU82kTJWzadOmVJfHxMQ4TflojDGXLl0ygwcPNkWLFjWenp4mNDTU9OvXz2laxRRTp041kswzzzzj1F6/fn0jyXz99deZrvWdd94xlStXNl5eXiZ37twmJibGfPXVV9by9evXm/vvv9/4+PgYSeb55583y5cvd5lWMLVtMubK1D9hYWEZ1pHZKR+vrqdgwYLm5Zdfdqln//79pnPnziYiIsJ4e3uboKAgU6dOHbNy5UprPV9//bVp2rSpKViwoMmRI4cpWLCgadOmjdmzZ4/V59rpvo4fP266d+9uSpUqZfz8/ExgYKCpVq2a+eCDD5xqPHz4sGncuLEJCAjI1D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Zs3t75C79atm3bt2qVXXnlFe/bs0QcffGDNQOFwOCRJr7zyijZs2KAePXpo69at2rt3rz7++GOXH6qlJ2/evPLx8dGXX36pI0eOKDExMc2+v/32m7Zu3arDhw/r/Pnz2rp1q7Zu3aqLFy9e/w4B7iJ36vt7+/btqlOnjho0aKAXXnhBhw8f1uHDh3Xs2LEb2yEAcB0I7bCF2bNnq379+ql+Rd68eXNt3rxZP//8s4oWLarFixdryZIlqlChgqZPn27NLuHl5SXpyrWsa9as0Z49exQdHa3KlStrwIABTl/LZ8TDw0OTJk3SzJkzVbBgQTVt2jTNvl26dFHlypU1c+ZM7dmzR5UrV1blypVtPwc1cLvcqe/vxYsX69ixY4qPj1eBAgWsv2uvuweA28FhzFXzbQF3oOHDh2vGjBn6448/srsUADcZ728AuIJr2nHHmTZtmv7zn/8oT548Wr9+vd58880sfTUOwL54fwNA6gjtuOPs3btXw4YN0z///KMiRYqoT58+6tevX3aXBeAm4P0NAKnj8hgAAADA5vghKgAAAGBzhHYAAADA5gjtAAAAgM0R2gEAAACbI7QDAAAANkdoBwAAAGyO0A4AAADYHKEdAAAAsDlCOwAAAGBz/w92zUeE6ZsUvAAAAABJRU5ErkJggg==", + "text/plain": [ + "
" ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "msft", - "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.9.18" }, - "orig_nbformat": 4 + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33muser_proxy\u001b[0m (to chatbot):\n", + "\n", + "\u001b[32m***** Response from calling function \"python\" *****\u001b[0m\n", + "None\n", + "\u001b[32m***************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35m******************************Start compressing the following content:******************************\u001b[0m\n", + "To be compressed:\n", + "##FUNCTION_CALL## \n", + "Name: python\n", + "Args: {\n", + " \"cell\": \n", + " \"import matplotlib.pyplot as plt\n", + "\n", + " # Define agent texts\n", + " agent1_texts = ['Hello there!', 'Nice to meet you.', 'How can I assist you?']\n", + " agent2_texts = ['Hey!', 'Nice meeting you too.', 'Could you help me solve a problem?']\n", + "\n", + " # Define agent y positions\n", + " agent1_y = [3, 2, 1]\n", + " agent2_y = [3, 2, 1]\n", + "\n", + " # Create figure and axis\n", + " fig, ax = plt.subplots()\n", + "\n", + " # Plot Agent 1 texts\n", + " for i, text in enumerate(agent1_texts):\n", + " ax.text(0, agent1_y[i], text, fontsize=12, ha='right')\n", + "\n", + " # Plot Agent 2 texts\n", + " for i, text in enumerate(agent2_texts):\n", + " ax.text(1, agent2_y[i], text, fontsize=12, ha='left')\n", + "\n", + " # Set plot attributes\n", + " ax.set_xlim(-0.5, 1.5)\n", + " ax.set_ylim(0, 4)\n", + " ax.set_xticks([0, 1])\n", + " ax.set_xticklabels(['Agent 1', 'Agent 2'])\n", + " ax.set_yticks([])\n", + " ax.spines['top'].set_visible(False)\n", + " ax.spines['right'].set_visible(False)\n", + " ax.spines['bottom'].set_visible(False)\"\n", + "}\n", + "##FUNCTION_RETURN## (from function \"python\"): \n", + "None\n", + "unexpected indent (1440792568.py, line 4)\n", + "\n", + "\u001b[35m******************************Content after compressing:******************************\u001b[0m\n", + "##FUNCTION_CALL##\n", + "Name: python\n", + "Args: Executing a block of Python code that imports the matplotlib.pyplot library for graphing and plotting. It defines texts for two agents and sets y positions. It also creates a figure and plots the agent texts on a graph with specific attributes.\n", + " \n", + "##FUNCTION_RETURN## (from function \"python\"):\n", + "None. Execution failed due to an unexpected indentation error at line 4.\n", + " \u001b[35m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[35mToken Count (including 107 tokens from system msg and function descriptions). Before compression : 821 | After: 564\u001b[0m\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mchatbot\u001b[0m (to user_proxy):\n", + "\n", + "TERMINATE\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], + "source": [ + "llm_config = {\n", + " \"functions\": [\n", + " {\n", + " \"name\": \"python\",\n", + " \"description\": \"run cell in ipython and return the execution result.\",\n", + " \"parameters\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"cell\": {\n", + " \"type\": \"string\",\n", + " \"description\": \"Valid Python cell to execute.\",\n", + " }\n", + " },\n", + " \"required\": [\"cell\"],\n", + " },\n", + " },\n", + " {\n", + " \"name\": \"sh\",\n", + " \"description\": \"run a shell script and return the execution result.\",\n", + " \"parameters\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"script\": {\n", + " \"type\": \"string\",\n", + " \"description\": \"Valid shell script to execute.\",\n", + " }\n", + " },\n", + " \"required\": [\"script\"],\n", + " },\n", + " },\n", + " ],\n", + " \"config_list\": config_list,\n", + " \"timeout\": 120,\n", + "}\n", + "import autogen\n", + "from autogen.agentchat.contrib.compressible_agent import CompressibleAgent\n", + "\n", + "chatbot = CompressibleAgent(\n", + " name=\"chatbot\",\n", + " system_message=\"For coding tasks, only use the functions you have been provided with. Reply TERMINATE when the task is done.\",\n", + " llm_config=llm_config,\n", + " compress_config={\n", + " \"mode\": \"COMPRESS\",\n", + " \"trigger_count\": 600, # set this to a large number for less frequent compression\n", + " \"verbose\": True, # set this to False to suppress the compression log\n", + " \"leave_last_n\": 2,\n", + " }\n", + ")\n", + "\n", + "# create a UserProxyAgent instance named \"user_proxy\"\n", + "user_proxy = autogen.UserProxyAgent(\n", + " name=\"user_proxy\",\n", + " is_termination_msg=lambda x: x.get(\"content\", \"\") and x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\"),\n", + " human_input_mode=\"NEVER\",\n", + " max_consecutive_auto_reply=10,\n", + " code_execution_config={\"work_dir\": \"coding\"},\n", + ")\n", + "\n", + "# define functions according to the function desription\n", + "from IPython import get_ipython\n", + "\n", + "def exec_python(cell):\n", + " ipython = get_ipython()\n", + " result = ipython.run_cell(cell)\n", + " log = str(result.result)\n", + " if result.error_before_exec is not None:\n", + " log += f\"\\n{result.error_before_exec}\"\n", + " if result.error_in_exec is not None:\n", + " log += f\"\\n{result.error_in_exec}\"\n", + " return log\n", + "\n", + "def exec_sh(script):\n", + " return user_proxy.execute_code_blocks([(\"sh\", script)])\n", + "\n", + "# register the functions\n", + "user_proxy.register_function(\n", + " function_map={\n", + " \"python\": exec_python,\n", + " \"sh\": exec_sh,\n", + " }\n", + ")\n", + "\n", + "# start the conversation\n", + "user_proxy.initiate_chat(\n", + " chatbot,\n", + " message=\"Draw two agents chatting with each other with an example dialog. Don't add plt.show().\",\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3\n", + "This example is from [agent_chat_web_info.ipynb](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_web_info.ipynb). \n", + "We use this example to demonstrate how to pass in a customized compression function. We pass in an compression function `constrain_num_messages`, which constrains the number of messages to be 3 or less. \n", + "The customized function should accept a list of messages as input and return a tuple of `(is_success: bool, compressed_messages: List[Dict])`." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33muser_proxy\u001b[0m (to assistant):\n", + "\n", + "Show me the YTD gain of 10 largest technology companies as of today.\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33massistant\u001b[0m (to user_proxy):\n", + "\n", + "To fulfill your request, we first need a list of the 10 largest technology companies by market cap. Unfortunately, real-time financial data is gated behind paywalls, so it's difficult to get up-to-date reliable information through coding here. \n", + "\n", + "However, I can provide you a script to download YTD performance for a given list of companies if you already know the list. Below is an example using Yahoo Finance, for which Python has a usable API.\n", + "\n", + "Frequently mentioned largest technology companies include: Apple (AAPL), Microsoft (MSFT), Alphabet (GOOGL), Amazon (AMZN), Meta (FB), Tesla (TSLA), Alibaba group holding (BABA), Taiwan Semiconductor (TSM), Tencent (TCEHY), Oracle (ORCL). Adjust as necessary for your purpose.\n", + "\n", + "First, we need to install yfinance module:\n", + "\n", + "```sh\n", + "pip install yfinance\n", + "```\n", + "\n", + "Then, you can use this Python script to get the YTD performance. \n", + "\n", + "This Python script first gets the price at the beginning of the year, and then the most recent price. The difference between those two prices, divided by the starting price, gives the YTD performance.\n", + "\n", + "```python\n", + "# filename: ytd_gain.py\n", + "\n", + "import yfinance as yf\n", + "from datetime import datetime\n", + "\n", + "# Define the tickers\n", + "tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'FB', 'TSLA', 'BABA', 'TSM', 'TCEHY', 'ORCL']\n", + "now = datetime.now()\n", + "\n", + "# Define the current year\n", + "current_year = now.year\n", + "\n", + "# Iterate through each ticker\n", + "for ticker in tickers:\n", + " # Download the year-to-date data for this ticker\n", + " ticker_data = yf.download(ticker, start=f'{current_year}-01-01', end=f'{now.year}-{now.month}-{now.day}')\n", + "\n", + " # Get the close price at the beginning of the year\n", + " initial_price = ticker_data['Close'][0]\n", + "\n", + " # Get the most recent close price\n", + " most_recent_price = ticker_data['Close'][-1]\n", + "\n", + " # Calculate the year-to-date return\n", + " ytd_return = (most_recent_price - initial_price) / initial_price * 100\n", + "\n", + " # Print the result\n", + " print(f'The YTD return for {ticker} is {ytd_return:.2f}%')\n", + "```\n", + "\n", + "Run the file in shell:\n", + "\n", + "```sh\n", + "python ytd_gain.py\n", + "```\n", + "\n", + "The output will be the YTD gain (%) of each company to the console. Please note that actual results will depend on the input list of tickers and the current date.\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[31m\n", + ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is sh)...\u001b[0m\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[31m\n", + ">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is python)...\u001b[0m\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33muser_proxy\u001b[0m (to assistant):\n", + "\n", + "exitcode: 1 (execution failed)\n", + "Code output: \n", + "Requirement already satisfied: yfinance in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (0.2.31)\n", + "Requirement already satisfied: pandas>=1.3.0 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2.1.2)\n", + "Requirement already satisfied: numpy>=1.16.5 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (1.26.1)\n", + "Requirement already satisfied: requests>=2.31 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2.31.0)\n", + "Requirement already satisfied: multitasking>=0.0.7 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (0.0.11)\n", + "Requirement already satisfied: lxml>=4.9.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (4.9.3)\n", + "Requirement already satisfied: appdirs>=1.4.4 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (1.4.4)\n", + "Requirement already satisfied: pytz>=2022.5 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2023.3.post1)\n", + "Requirement already satisfied: frozendict>=2.3.4 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (2.3.8)\n", + "Requirement already satisfied: peewee>=3.16.2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (3.17.0)\n", + "Requirement already satisfied: beautifulsoup4>=4.11.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (4.12.2)\n", + "Requirement already satisfied: html5lib>=1.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from yfinance) (1.1)\n", + "Requirement already satisfied: soupsieve>1.2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.5)\n", + "Requirement already satisfied: six>=1.9 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (1.16.0)\n", + "Requirement already satisfied: webencodings in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (0.5.1)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from pandas>=1.3.0->yfinance) (2.8.2)\n", + "Requirement already satisfied: tzdata>=2022.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from pandas>=1.3.0->yfinance) (2023.3)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.3.1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2023.7.22)\n", + "\n", + "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " initial_price = ticker_data['Close'][0]\n", + "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " most_recent_price = ticker_data['Close'][-1]\n", + "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " initial_price = ticker_data['Close'][0]\n", + "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " most_recent_price = ticker_data['Close'][-1]\n", + "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " initial_price = ticker_data['Close'][0]\n", + "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " most_recent_price = ticker_data['Close'][-1]\n", + "ytd_gain.py:19: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " initial_price = ticker_data['Close'][0]\n", + "ytd_gain.py:22: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n", + " most_recent_price = ticker_data['Close'][-1]\n", + "\n", + "1 Failed download:\n", + "['FB']: Exception('%ticker%: No timezone found, symbol may be delisted')\n", + "Traceback (most recent call last):\n", + " File \"ytd_gain.py\", line 19, in \n", + " initial_price = ticker_data['Close'][0]\n", + " File \"/home/ykw5399/.conda/envs/dev2/lib/python3.9/site-packages/pandas/core/series.py\", line 1037, in __getitem__\n", + " return self._values[key]\n", + "IndexError: index 0 is out of bounds for axis 0 with size 0\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33massistant\u001b[0m (to user_proxy):\n", + "\n", + "There seems to be an issue with the ticker symbol 'FB'. The error message shows 'FB': No timezone found, symbol may be delisted. This is because 'FB' has been recently changed to 'META' so the symbol 'FB' is causing the issue.\n", + "\n", + "We can replace 'FB' with 'META' and rerun the Python script. The error messages for series indexing are warnings rather than errors. It seems recent changes in pandas library caused these warnings. To resolve this, `iloc` function will be utilized to get the first and last items of the Series.\n", + "\n", + "Here is the updated Python script:\n", + "\n", + "```python\n", + "# filename: ytd_gain.py\n", + "\n", + "import yfinance as yf\n", + "from datetime import datetime\n", + "\n", + "# Define the tickers\n", + "tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'META', 'TSLA', 'BABA', 'TSM', 'TCEHY', 'ORCL']\n", + "now = datetime.now()\n", + "\n", + "# Define the current year\n", + "current_year = now.year\n", + "\n", + "# Iterate through each ticker\n", + "for ticker in tickers:\n", + " # Download the year-to-date data for this ticker\n", + " ticker_data = yf.download(ticker, start=f'{current_year}-01-01', end=f'{now.year}-{now.month}-{now.day}')\n", + "\n", + " # Get the close price at the beginning of the year\n", + " initial_price = ticker_data['Close'].iloc[0]\n", + "\n", + " # Get the most recent close price\n", + " most_recent_price = ticker_data['Close'].iloc[-1]\n", + "\n", + " # Calculate the year-to-date return\n", + " ytd_return = (most_recent_price - initial_price) / initial_price * 100\n", + "\n", + " # Print the result\n", + " print(f'The YTD return for {ticker} is {ytd_return:.2f}%')\n", + "```\n", + "\n", + "Run the file in shell:\n", + "\n", + "```sh\n", + "python ytd_gain.py\n", + "```\n", + "\n", + "This script will print the YTD gain (%) of each company to the console.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[31m\n", + ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[31m\n", + ">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is sh)...\u001b[0m\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change\n" + ] }, - "nbformat": 4, - "nbformat_minor": 2 - } + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33muser_proxy\u001b[0m (to assistant):\n", + "\n", + "exitcode: 0 (execution succeeded)\n", + "Code output: \n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for AAPL is 41.24%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for MSFT is 47.26%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for GOOGL is 44.86%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for AMZN is 61.50%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for META is 152.20%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for TSLA is 103.48%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for BABA is -7.25%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for TSM is 23.99%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for TCEHY is -12.16%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for ORCL is 29.06%\n", + "\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for AAPL is 41.24%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for MSFT is 47.26%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for GOOGL is 44.86%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for AMZN is 61.50%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for META is 152.20%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for TSLA is 103.48%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for BABA is -7.25%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for TSM is 23.99%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for TCEHY is -12.16%\n", + "\n", + "[*********************100%%**********************] 1 of 1 completed\n", + "The YTD return for ORCL is 29.06%\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35mToken Count (including 468 tokens from system msg and function descriptions). Before compression : 3684 | After: 1509\u001b[0m\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33massistant\u001b[0m (to user_proxy):\n", + "\n", + "It appears that you've run the script twice, as the results are duplicated. From the code output, here are the Year-to-Date (YTD) returns for the 10 largest technology companies:\n", + "\n", + "1. AAPL (Apple): 41.24% gain\n", + "2. MSFT (Microsoft): 47.26% gain\n", + "3. GOOGL (Alphabet Class A): 44.86% gain\n", + "4. AMZN (Amazon): 61.50% gain\n", + "5. META (Meta Platforms, previously Facebook): 152.20% gain\n", + "6. TSLA (Tesla): 103.48% gain\n", + "7. BABA (Alibaba): -7.25% loss\n", + "8. TSM (Taiwan Semiconductor Manufacturing): 23.99% gain\n", + "9. TCEHY (Tencent Holdings): -12.16% loss\n", + "10. ORCL (Oracle): 29.06% gain\n", + "\n", + "Please note, the percentage change could have slight differences due to market volatility and the exact times the prices were taken. \n", + "\n", + "If everything looks good, let's wrap up. If you need any more help with other tasks, just let me know! \n", + "\n", + "TERMINATE\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], + "source": [ + "import autogen\n", + "from autogen.agentchat.contrib.math_user_proxy_agent import MathUserProxyAgent\n", + "from autogen.agentchat.contrib.compressible_agent import CompressibleAgent\n", + "\n", + "def constrain_num_messages(messages):\n", + " \"\"\"Constrain the number of messages to 3.\n", + " \n", + " This is an example of a customized compression function.\n", + "\n", + " Returns:\n", + " bool: whether the compression is successful.\n", + " list: the compressed messages.\n", + " \"\"\"\n", + " if len(messages) <= 3:\n", + " # do nothing\n", + " return False, None\n", + " \n", + " # save the first and last two messages\n", + " return True, messages[:1] + messages[-2:]\n", + "\n", + "# create a CompressibleAgent instance named \"assistant\"\n", + "assistant = CompressibleAgent(\n", + " name=\"assistant\",\n", + " llm_config={\n", + " \"timeout\": 600,\n", + " \"cache_seed\": 43,\n", + " \"config_list\": config_list,\n", + " },\n", + " compress_config={\n", + " \"mode\": \"CUSTOMIZED\",\n", + " \"compress_function\": constrain_num_messages, # this is required for customized compression\n", + " \"trigger_count\": 1600, \n", + " },\n", + ")\n", + "\n", + "# create a UserProxyAgent instance named \"user_proxy\"\n", + "user_proxy = autogen.UserProxyAgent(\n", + " name=\"user_proxy\",\n", + " human_input_mode=\"TERMINATE\",\n", + " max_consecutive_auto_reply=10,\n", + " is_termination_msg=lambda x: x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\") or x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE.\"),\n", + " code_execution_config={\"work_dir\": \"web\"},\n", + " system_message=\"\"\"Reply TERMINATE if the task has been solved at full satisfaction.\n", + "Otherwise, reply CONTINUE, or the reason why the task is not solved yet.\"\"\"\n", + ")\n", + "\n", + "user_proxy.initiate_chat(\n", + " assistant,\n", + " message=\"\"\"Show me the YTD gain of 10 largest technology companies as of today.\"\"\",\n", + ")\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "msft", + "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.9.18" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/test/agentchat/contrib/test_compressible_agent.py b/test/agentchat/contrib/test_compressible_agent.py index 46fd1a321bb..06a1ba6146e 100644 --- a/test/agentchat/contrib/test_compressible_agent.py +++ b/test/agentchat/contrib/test_compressible_agent.py @@ -35,8 +35,8 @@ def test_mode_compress(): assistant = CompressibleAgent( name="assistant", llm_config={ - "request_timeout": 600, - "seed": 43, + "timeout": 600, + "cache_seed": 43, "config_list": config_list, }, compress_config={ @@ -73,8 +73,8 @@ def test_mode_customized(): assistant = CompressibleAgent( name="assistant", llm_config={ - "request_timeout": 600, - "seed": 43, + "timeout": 600, + "cache_seed": 43, "config_list": config_list, }, compress_config={ @@ -105,7 +105,7 @@ def constrain_num_messages(messages): name="assistant", llm_config={ "timeout": 600, - "seed": 43, + "cache_seed": 43, "config_list": config_list, "model": "gpt-3.5-turbo", }, @@ -142,8 +142,8 @@ def test_compress_messsage(): assistant = CompressibleAgent( name="assistant", llm_config={ - "request_timeout": 600, - "seed": 43, + "timeout": 600, + "cache_seed": 43, "config_list": config_list, }, compress_config={ @@ -166,15 +166,15 @@ def test_compress_messsage(): {"content": "Can you tell me a joke about programming?", "role": "assistant"}, ] ) - assert is_success, "Compression should be successful" + assert is_success, "Compression failed." def test_mode_terminate(): assistant = CompressibleAgent( name="assistant", llm_config={ - "request_timeout": 600, - "seed": 43, + "timeout": 600, + "cache_seed": 43, "config_list": config_list, }, compress_config=True,