From 93b9e091663e1fc7c7827638a25a2fbc4944ea46 Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Wed, 6 Sep 2023 19:17:53 -0700 Subject: [PATCH] admin takeover in group chat (#1209) * admin takeover in group chat * comments * add comments --- flaml/autogen/agentchat/groupchat.py | 36 +- ...autogen_agentchat_groupchat_research.ipynb | 565 ++++++++++++++++++ website/docs/Examples/AutoGen-AgentChat.md | 1 + website/docs/Use-Cases/Autogen.md | 1 + 4 files changed, 593 insertions(+), 10 deletions(-) create mode 100644 notebook/autogen_agentchat_groupchat_research.ipynb diff --git a/flaml/autogen/agentchat/groupchat.py b/flaml/autogen/agentchat/groupchat.py index 322cfd3101..72ea0c0ac5 100644 --- a/flaml/autogen/agentchat/groupchat.py +++ b/flaml/autogen/agentchat/groupchat.py @@ -12,6 +12,7 @@ class GroupChat: agents: List[Agent] messages: List[Dict] max_round: int = 10 + admin_name: str = "Admin" # the name of the admin agent @property def agent_names(self) -> List[str]: @@ -97,21 +98,36 @@ def run_chat( messages = self._oai_messages[sender] message = messages[-1] speaker = sender - for i in range(config.max_round): + groupchat = config + for i in range(groupchat.max_round): # set the name to speaker's name if the role is not function if message["role"] != "function": message["name"] = speaker.name - config.messages.append(message) + groupchat.messages.append(message) # broadcast the message to all agents except the speaker - for agent in config.agents: + for agent in groupchat.agents: if agent != speaker: self.send(message, agent, request_reply=False, silent=True) - if i != config.max_round - 1: - # speaker selection msg from an agent - speaker = config.select_speaker(speaker, self) + if i == groupchat.max_round - 1: + # the last round + break + try: + # select the next speaker + speaker = groupchat.select_speaker(speaker, self) + # let the speaker speak reply = speaker.generate_reply(sender=self) - if reply is None: - break - speaker.send(reply, self, request_reply=False) - message = self.last_message(speaker) + except KeyboardInterrupt: + # let the admin agent speak if interrupted + if groupchat.admin_name in groupchat.agent_names: + # admin agent is one of the participants + speaker = groupchat.agent_by_name(groupchat.admin_name) + reply = speaker.generate_reply(sender=self) + else: + # admin agent is not found in the participants + raise + if reply is None: + break + # The speaker sends the message without requesting a reply + speaker.send(reply, self, request_reply=False) + message = self.last_message(speaker) return True, None diff --git a/notebook/autogen_agentchat_groupchat_research.ipynb b/notebook/autogen_agentchat_groupchat_research.ipynb new file mode 100644 index 0000000000..6f405b6452 --- /dev/null +++ b/notebook/autogen_agentchat_groupchat_research.ipynb @@ -0,0 +1,565 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\"Open" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Auto Generated Agent Chat: Performs Research with Multi-Agent Group Chat\n", + "\n", + "`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n", + "Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n", + "\n", + "## Requirements\n", + "\n", + "FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the [autogen] option:\n", + "```bash\n", + "pip install flaml[autogen]\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "%%capture --no-stderr\n", + "# %pip install flaml[autogen]~=2.0.3" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set your API Endpoint\n", + "\n", + "The [`config_list_from_json`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from flaml import autogen\n", + "\n", + "config_list_gpt4 = autogen.config_list_from_json(\n", + " \"OAI_CONFIG_LIST\",\n", + " filter_dict={\n", + " \"model\": [\"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n", + " },\n", + ")" + ] + }, + { + "attachments": {}, + "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). Only the gpt-4-32k models are kept in the list based on the filter condition.\n", + "\n", + "The config list looks like the following:\n", + "```python\n", + "config_list = [\n", + " {\n", + " 'model': 'gpt-4-32k',\n", + " 'api_key': '',\n", + " },\n", + " {\n", + " 'model': 'gpt-4-32k',\n", + " 'api_key': '',\n", + " 'api_base': '',\n", + " 'api_type': 'azure',\n", + " 'api_version': '2023-06-01-preview',\n", + " },\n", + " {\n", + " 'model': 'gpt-4-32k-0314',\n", + " 'api_key': '',\n", + " 'api_base': '',\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." + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Construct Agents" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "gpt4_config = {\n", + " \"seed\": 42, # change the seed for different trials\n", + " \"temperature\": 0,\n", + " \"config_list\": config_list_gpt4,\n", + " \"request_timeout\": 120,\n", + "}\n", + "human = autogen.UserProxyAgent(\n", + " name=\"Admin\",\n", + " system_message=\"A human admin. Interact with the planner to discuss the plan. Plan execution needs to be approved by this admin.\",\n", + " code_execution_config=False,\n", + ")\n", + "engineer = autogen.AssistantAgent(\n", + " name=\"Engineer\",\n", + " llm_config=gpt4_config,\n", + " system_message='''Engineer. You follow an approved plan. You write python/shell code to solve tasks. Wrap the code in a code block that specifies the script type. The user can't modify your code. So do not suggest incomplete code which requires others to modify. Don't use a code block if it's not intended to be executed by the executor.\n", + "Don't include multiple code blocks in one response. Do not ask others to copy and paste the result. Check the execution result returned by the executor.\n", + "If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\n", + "''',\n", + ")\n", + "scientist = autogen.AssistantAgent(\n", + " name=\"Scientist\",\n", + " llm_config=gpt4_config,\n", + " system_message=\"\"\"Scientist. You follow an approved plan. You are able to categorize papers after seeing their abstracts printed. You don't write code.\"\"\"\n", + ")\n", + "planner = autogen.AssistantAgent(\n", + " name=\"Planner\",\n", + " system_message='''Planner. Suggest a plan. Revise the plan based on feedback from admin and critic, until admin approval.\n", + "The plan may involve an engineer who can write code and a scientist who doesn't write code.\n", + "Explain the plan first. Be clear which step is performed by an engineer, and which step is performed by a scientist.\n", + "''',\n", + " llm_config=gpt4_config,\n", + ")\n", + "executor = autogen.UserProxyAgent(\n", + " name=\"Executor\",\n", + " system_message=\"Executor. Execute the code written by the engineer and report the result.\",\n", + " human_input_mode=\"NEVER\",\n", + " code_execution_config={\"last_n_messages\": 3, \"work_dir\": \"paper\"},\n", + ")\n", + "critic = autogen.AssistantAgent(\n", + " name=\"Critic\",\n", + " system_message=\"Critic. Double check plan, claims, code from other agents and provide feedback. Check whether the plan includes adding verifiable info such as source URL.\",\n", + " llm_config=gpt4_config,\n", + ")\n", + "groupchat = autogen.GroupChat(agents=[human, engineer, scientist, planner, executor, critic], messages=[], max_round=50)\n", + "manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=gpt4_config)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Start Chat" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33mAdmin\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mPlanner\u001b[0m (to chat_manager):\n", + "\n", + "Plan:\n", + "\n", + "1. Engineer: Write a script to scrape the arXiv website for papers related to LLM (Language Model) applications published in the last week. The script should extract the title, authors, abstract, and link to the paper.\n", + "\n", + "2. Scientist: Review the scraped data to identify the different domains in which LLM is applied. This could be based on keywords in the title or abstract, or the scientist's knowledge of the field.\n", + "\n", + "3. Engineer: Modify the script to categorize the papers based on the domains identified by the scientist. The script should output a markdown table with columns for the domain, title, authors, abstract, and link.\n", + "\n", + "4. Scientist: Review the markdown table to ensure the papers are correctly categorized and the information is accurate.\n", + "\n", + "5. Engineer: Make any necessary revisions to the script based on the scientist's feedback.\n", + "\n", + "6. Scientist: Give final approval of the markdown table.\n", + "\n", + "7. Engineer: Submit the final markdown table.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mCritic\u001b[0m (to chat_manager):\n", + "\n", + "The plan seems solid and well-structured. However, it lacks the inclusion of verifiable information such as source URLs. Here's a revised version:\n", + "\n", + "1. Engineer: Write a script to scrape the arXiv website for papers related to LLM (Language Model) applications published in the last week. The script should extract the title, authors, abstract, and link to the paper.\n", + "\n", + "2. Scientist: Review the scraped data to identify the different domains in which LLM is applied. This could be based on keywords in the title or abstract, or the scientist's knowledge of the field.\n", + "\n", + "3. Engineer: Modify the script to categorize the papers based on the domains identified by the scientist. The script should output a markdown table with columns for the domain, title, authors, abstract, and link (source URL).\n", + "\n", + "4. Scientist: Review the markdown table to ensure the papers are correctly categorized and the information is accurate. Check the source URLs to verify the information.\n", + "\n", + "5. Engineer: Make any necessary revisions to the script based on the scientist's feedback.\n", + "\n", + "6. Scientist: Give final approval of the markdown table, ensuring all entries have a valid source URL.\n", + "\n", + "7. Engineer: Submit the final markdown table.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33mAdmin\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mEngineer\u001b[0m (to chat_manager):\n", + "\n", + "I'm sorry for the confusion, but as an AI model developed by OpenAI, I don't have the ability to directly scrape websites or access real-time data from external databases or websites, including arXiv. However, I can help you write a Python script that uses the arXiv API to fetch the data you need.\n", + "\n", + "Here's a Python script that uses the `arxiv` package to search for papers related to \"LLM applications\" from the last week. This script will print out the title, authors, summary, and URL of each paper.\n", + "\n", + "```python\n", + "import arxiv\n", + "import datetime\n", + "\n", + "# Calculate the date one week ago\n", + "one_week_ago = (datetime.datetime.now() - datetime.timedelta(days=7)).strftime('%Y%m%d%H%M%S')\n", + "\n", + "# Search for papers on LLM applications\n", + "search = arxiv.Search(\n", + " query=\"LLM applications\",\n", + " max_results=100,\n", + " sort_by=arxiv.SortCriterion.SubmittedDate,\n", + " sort_order=arxiv.SortOrder.Descending\n", + ")\n", + "\n", + "for result in search.get():\n", + " # Check if the paper was submitted in the last week\n", + " if result.submitted.strftime('%Y%m%d%H%M%S') > one_week_ago:\n", + " print(f\"Title: {result.title}\")\n", + " print(f\"Authors: {', '.join(author.name for author in result.authors)}\")\n", + " print(f\"Summary: {result.summary}\")\n", + " print(f\"URL: {result.entry_id}\")\n", + " print(\"\\n\")\n", + "```\n", + "\n", + "You can install the `arxiv` package using pip:\n", + "\n", + "```shell\n", + "pip install arxiv\n", + "```\n", + "\n", + "Please note that you'll need to replace `\"LLM applications\"` with the actual search term you're interested in. The arXiv API doesn't support searching by the submission date, so the script fetches the 100 most recent results and filters them manually. You may need to increase `max_results` if there are more than 100 papers submitted per week on your topic.\n", + "\n", + "To create a markdown table, you'll need to format the output like this:\n", + "\n", + "```markdown\n", + "| Title | Authors | Summary | URL |\n", + "|-------|---------|---------|-----|\n", + "| ... | ... | ... | ... |\n", + "```\n", + "\n", + "You can do this in Python using f-strings:\n", + "\n", + "```python\n", + "print(\"| Title | Authors | Summary | URL |\")\n", + "print(\"|-------|---------|---------|-----|\")\n", + "for result in search.get():\n", + " # Check if the paper was submitted in the last week\n", + " if result.submitted.strftime('%Y%m%d%H%M%S') > one_week_ago:\n", + " print(f\"| {result.title} | {', '.join(author.name for author in result.authors)} | {result.summary} | {result.entry_id} |\")\n", + "```\n", + "\n", + "This will print a markdown table to the console. If you want to write the table to a file, you can open a file and use the `write` method instead of `print`.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n", + "\u001b[33mExecutor\u001b[0m (to chat_manager):\n", + "\n", + "exitcode: 1 (execution failed)\n", + "Code output: \n", + ":15: DeprecationWarning: The 'get' method is deprecated, use 'results' instead\n", + " for result in search.get():\n", + "Traceback (most recent call last):\n", + " File \"\", line 17, in \n", + " if result.submitted.strftime('%Y%m%d%H%M%S') > one_week_ago:\n", + "AttributeError: 'Result' object has no attribute 'submitted'\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mEngineer\u001b[0m (to chat_manager):\n", + "\n", + "I apologize for the confusion. It seems there was a mistake in the code. The `arxiv` package's `Result` object doesn't have a `submitted` attribute. Instead, we should use the `published` attribute to get the date when the paper was published.\n", + "\n", + "Here's the corrected code:\n", + "\n", + "```python\n", + "import arxiv\n", + "import datetime\n", + "\n", + "# Calculate the date one week ago\n", + "one_week_ago = (datetime.datetime.now() - datetime.timedelta(days=7)).strftime('%Y%m%d%H%M%S')\n", + "\n", + "# Search for papers on LLM applications\n", + "search = arxiv.Search(\n", + " query=\"LLM applications\",\n", + " max_results=100,\n", + " sort_by=arxiv.SortCriterion.Relevance,\n", + " sort_order=arxiv.SortOrder.Descending\n", + ")\n", + "\n", + "print(\"| Title | Authors | Summary | URL |\")\n", + "print(\"|-------|---------|---------|-----|\")\n", + "for result in search.results():\n", + " # Check if the paper was published in the last week\n", + " if result.published.strftime('%Y%m%d%H%M%S') > one_week_ago:\n", + " print(f\"| {result.title} | {', '.join(author.name for author in result.authors)} | {result.summary} | {result.entry_id} |\")\n", + "```\n", + "\n", + "This script will print a markdown table of papers related to \"LLM applications\" that were published in the last week. The table includes the title, authors, summary, and URL of each paper.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n", + "\u001b[33mExecutor\u001b[0m (to chat_manager):\n", + "\n", + "exitcode: 0 (execution succeeded)\n", + "Code output: \n", + "| Title | Authors | Summary | URL |\n", + "|-------|---------|---------|-----|\n", + "| Large Language Models as Data Preprocessors | Haochen Zhang, Yuyang Dong, Chuan Xiao, Masafumi Oyamada | Large Language Models (LLMs), typified by OpenAI's GPT series and Meta's\n", + "LLaMA variants, have marked a significant advancement in artificial\n", + "intelligence. Trained on vast amounts of text data, LLMs are capable of\n", + "understanding and generating human-like text across a diverse range of topics.\n", + "This study expands on the applications of LLMs, exploring their potential in\n", + "data preprocessing, a critical stage in data mining and analytics applications.\n", + "We delve into the applicability of state-of-the-art LLMs such as GPT-3.5,\n", + "GPT-4, and Vicuna-13B for error detection, data imputation, schema matching,\n", + "and entity matching tasks. Alongside showcasing the inherent capabilities of\n", + "LLMs, we highlight their limitations, particularly in terms of computational\n", + "expense and inefficiency. We propose an LLM-based framework for data\n", + "preprocessing, which integrates cutting-edge prompt engineering techniques,\n", + "coupled with traditional methods like contextualization and feature selection,\n", + "to improve the performance and efficiency of these models. The effectiveness of\n", + "LLMs in data preprocessing is evaluated through an experimental study spanning\n", + "12 datasets. GPT-4 emerged as a standout, achieving 100\\% accuracy or F1 score\n", + "on 4 datasets, suggesting LLMs' immense potential in these tasks. Despite\n", + "certain limitations, our study underscores the promise of LLMs in this domain\n", + "and anticipates future developments to overcome current hurdles. | http://arxiv.org/abs/2308.16361v1 |\n", + "| Large language models in medicine: the potentials and pitfalls | Jesutofunmi A. Omiye, Haiwen Gui, Shawheen J. Rezaei, James Zou, Roxana Daneshjou | Large language models (LLMs) have been applied to tasks in healthcare,\n", + "ranging from medical exam questions to responding to patient questions. With\n", + "increasing institutional partnerships between companies producing LLMs and\n", + "healthcare systems, real world clinical application is coming closer to\n", + "reality. As these models gain traction, it is essential for healthcare\n", + "practitioners to understand what LLMs are, their development, their current and\n", + "potential applications, and the associated pitfalls when utilized in medicine.\n", + "This review and accompanying tutorial aim to give an overview of these topics\n", + "to aid healthcare practitioners in understanding the rapidly changing landscape\n", + "of LLMs as applied to medicine. | http://arxiv.org/abs/2309.00087v1 |\n", + "| Point-Bind & Point-LLM: Aligning Point Cloud with Multi-modality for 3D Understanding, Generation, and Instruction Following | Ziyu Guo, Renrui Zhang, Xiangyang Zhu, Yiwen Tang, Xianzheng Ma, Jiaming Han, Kexin Chen, Peng Gao, Xianzhi Li, Hongsheng Li, Pheng-Ann Heng | We introduce Point-Bind, a 3D multi-modality model aligning point clouds with\n", + "2D image, language, audio, and video. Guided by ImageBind, we construct a joint\n", + "embedding space between 3D and multi-modalities, enabling many promising\n", + "applications, e.g., any-to-3D generation, 3D embedding arithmetic, and 3D\n", + "open-world understanding. On top of this, we further present Point-LLM, the\n", + "first 3D large language model (LLM) following 3D multi-modal instructions. By\n", + "parameter-efficient fine-tuning techniques, Point-LLM injects the semantics of\n", + "Point-Bind into pre-trained LLMs, e.g., LLaMA, which requires no 3D instruction\n", + "data, but exhibits superior 3D and multi-modal question-answering capacity. We\n", + "hope our work may cast a light on the community for extending 3D point clouds\n", + "to multi-modality applications. Code is available at\n", + "https://github.com/ZiyuGuo99/Point-Bind_Point-LLM. | http://arxiv.org/abs/2309.00615v1 |\n", + "| Where Would I Go Next? Large Language Models as Human Mobility Predictors | Xinglei Wang, Meng Fang, Zichao Zeng, Tao Cheng | Accurate human mobility prediction underpins many important applications\n", + "across a variety of domains, including epidemic modelling, transport planning,\n", + "and emergency responses. Due to the sparsity of mobility data and the\n", + "stochastic nature of people's daily activities, achieving precise predictions\n", + "of people's locations remains a challenge. While recently developed large\n", + "language models (LLMs) have demonstrated superior performance across numerous\n", + "language-related tasks, their applicability to human mobility studies remains\n", + "unexplored. Addressing this gap, this article delves into the potential of LLMs\n", + "for human mobility prediction tasks. We introduce a novel method, LLM-Mob,\n", + "which leverages the language understanding and reasoning capabilities of LLMs\n", + "for analysing human mobility data. We present concepts of historical stays and\n", + "context stays to capture both long-term and short-term dependencies in human\n", + "movement and enable time-aware prediction by using time information of the\n", + "prediction target. Additionally, we design context-inclusive prompts that\n", + "enable LLMs to generate more accurate predictions. Comprehensive evaluations of\n", + "our method reveal that LLM-Mob excels in providing accurate and interpretable\n", + "predictions, highlighting the untapped potential of LLMs in advancing human\n", + "mobility prediction techniques. We posit that our research marks a significant\n", + "paradigm shift in human mobility modelling, transitioning from building complex\n", + "domain-specific models to harnessing general-purpose LLMs that yield accurate\n", + "predictions through language instructions. The code for this work is available\n", + "at https://github.com/xlwang233/LLM-Mob. | http://arxiv.org/abs/2308.15197v1 |\n", + "| Interactively Robot Action Planning with Uncertainty Analysis and Active Questioning by Large Language Model | Kazuki Hori, Kanata Suzuki, Tetsuya Ogata | The application of the Large Language Model (LLM) to robot action planning\n", + "has been actively studied. The instructions given to the LLM by natural\n", + "language may include ambiguity and lack of information depending on the task\n", + "context. It is possible to adjust the output of LLM by making the instruction\n", + "input more detailed; however, the design cost is high. In this paper, we\n", + "propose the interactive robot action planning method that allows the LLM to\n", + "analyze and gather missing information by asking questions to humans. The\n", + "method can minimize the design cost of generating precise robot instructions.\n", + "We demonstrated the effectiveness of our method through concrete examples in\n", + "cooking tasks. However, our experiments also revealed challenges in robot\n", + "action planning with LLM, such as asking unimportant questions and assuming\n", + "crucial information without asking. Shedding light on these issues provides\n", + "valuable insights for future research on utilizing LLM for robotics. | http://arxiv.org/abs/2308.15684v1 |\n", + "| AskIt: Unified Programming Interface for Programming with Large Language Models | Katsumi Okuda, Saman Amarasinghe | In the evolving landscape of software development, Large Language Models\n", + "(LLMs) exhibit a unique phenomenon known as emergent abilities, demonstrating\n", + "adeptness across numerous tasks, from text summarization to code generation.\n", + "While these abilities open up novel avenues in software design and crafting,\n", + "their incorporation presents substantial challenges. Developers grapple with\n", + "decisions surrounding the direct embedding of LLMs within applications versus\n", + "employing them for code generation. Moreover, effective prompt design becomes a\n", + "critical concern, given the necessity of data extraction from natural language\n", + "outputs. To address these intricacies, this paper introduces AskIt, a\n", + "domain-specific language (DSL) specifically designed for LLMs. AskIt simplifies\n", + "LLM integration, offering type-guided output control, template-based function\n", + "definitions, and a unified interface that diminishes the distinction between\n", + "LLM-based code generation and application integration. Furthermore, through\n", + "Programming by Example (PBE), AskIt harnesses the power of few-shot learning at\n", + "the programming language level. Our evaluations underscore AskIt's potency.\n", + "Across 50 tasks, AskIt generated concise prompts for the given tasks, achieving\n", + "a 16.14% reduction in prompt length relative to benchmarks. Additionally, by\n", + "enabling the transition from direct LLM application usage to function\n", + "generation, AskIt achieved significant speedups, as observed in our GSM8K\n", + "benchmark experiments. Through these advancements, AskIt streamlines the\n", + "integration of LLMs in software development, offering a more efficient,\n", + "versatile approach for leveraging emergent abilities. The implementations of\n", + "AskIt in TypeScript and Python are available at\n", + "https://github.com/katsumiok/ts-askit and https://github.com/katsumiok/pyaskit,\n", + "respectively. | http://arxiv.org/abs/2308.15645v1 |\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mScientist\u001b[0m (to chat_manager):\n", + "\n", + "Here are the papers related to LLM applications published in the last week:\n", + "\n", + "| Domain | Title | Authors | Summary | URL |\n", + "|-------|---------|---------|-----|-----|\n", + "| Data Preprocessing | [Large Language Models as Data Preprocessors](http://arxiv.org/abs/2308.16361v1) | Haochen Zhang, Yuyang Dong, Chuan Xiao, Masafumi Oyamada | This study expands on the applications of LLMs, exploring their potential in data preprocessing, a critical stage in data mining and analytics applications. | [Link](http://arxiv.org/abs/2308.16361v1) |\n", + "| Medicine | [Large language models in medicine: the potentials and pitfalls](http://arxiv.org/abs/2309.00087v1) | Jesutofunmi A. Omiye, Haiwen Gui, Shawheen J. Rezaei, James Zou, Roxana Daneshjou | This review and accompanying tutorial aim to give an overview of these topics to aid healthcare practitioners in understanding the rapidly changing landscape of LLMs as applied to medicine. | [Link](http://arxiv.org/abs/2309.00087v1) |\n", + "| 3D Understanding, Generation, and Instruction Following | [Point-Bind & Point-LLM: Aligning Point Cloud with Multi-modality for 3D Understanding, Generation, and Instruction Following](http://arxiv.org/abs/2309.00615v1) | Ziyu Guo, Renrui Zhang, Xiangyang Zhu, Yiwen Tang, Xianzheng Ma, Jiaming Han, Kexin Chen, Peng Gao, Xianzhi Li, Hongsheng Li, Pheng-Ann Heng | We introduce Point-Bind, a 3D multi-modality model aligning point clouds with 2D image, language, audio, and video. | [Link](http://arxiv.org/abs/2309.00615v1) |\n", + "| Human Mobility Prediction | [Where Would I Go Next? Large Language Models as Human Mobility Predictors](http://arxiv.org/abs/2308.15197v1) | Xinglei Wang, Meng Fang, Zichao Zeng, Tao Cheng | This article delves into the potential of LLMs for human mobility prediction tasks. | [Link](http://arxiv.org/abs/2308.15197v1) |\n", + "| Robotics | [Interactively Robot Action Planning with Uncertainty Analysis and Active Questioning by Large Language Model](http://arxiv.org/abs/2308.15684v1) | Kazuki Hori, Kanata Suzuki, Tetsuya Ogata | In this paper, we propose the interactive robot action planning method that allows the LLM to analyze and gather missing information by asking questions to humans. | [Link](http://arxiv.org/abs/2308.15684v1) |\n", + "| Software Development | [AskIt: Unified Programming Interface for Programming with Large Language Models](http://arxiv.org/abs/2308.15645v1) | Katsumi Okuda, Saman Amarasinghe | This paper introduces AskIt, a domain-specific language (DSL) specifically designed for LLMs. | [Link](http://arxiv.org/abs/2308.15645v1) |\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mCritic\u001b[0m (to chat_manager):\n", + "\n", + "The scientist has done a good job categorizing the papers into different domains and providing a summary for each. The markdown table is correctly formatted and includes the source URL for each paper, which allows for verification of the information. The domains identified are diverse, indicating a broad range of applications for Large Language Models (LLMs). This review and categorization should provide a useful resource for anyone interested in the recent applications of LLMs.\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], + "source": [ + "human.initiate_chat(\n", + " manager,\n", + " message=\"\"\"\n", + "find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n", + "\"\"\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create Group Chat without Critic for Comparison" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33mAdmin\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mPlanner\u001b[0m (to chat_manager):\n", + "\n", + "Plan:\n", + "\n", + "1. Engineer: Write a script to scrape the arXiv website for papers related to LLM (Language Model) applications published in the last week. The script should extract the title, authors, abstract, and link to the paper.\n", + "\n", + "2. Scientist: Review the scraped data to identify the different domains in which LLM is applied. This could be based on keywords in the title or abstract, or the scientist's knowledge of the field.\n", + "\n", + "3. Engineer: Modify the script to categorize the papers based on the domains identified by the scientist. The script should output a markdown table with columns for the domain, title, authors, abstract, and link.\n", + "\n", + "4. Scientist: Review the markdown table to ensure the papers are correctly categorized and the information is accurate.\n", + "\n", + "5. Engineer: Make any necessary revisions to the script based on the scientist's feedback.\n", + "\n", + "6. Scientist: Give final approval of the markdown table.\n", + "\n", + "7. Engineer: Submit the final markdown table.\n", + "\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], + "source": [ + "groupchat_nocritic = autogen.GroupChat(agents=[human, engineer, scientist, planner, executor], messages=[], max_round=50)\n", + "for agent in groupchat.agents:\n", + " agent.reset()\n", + "manager_nocritic = autogen.GroupChatManager(groupchat=groupchat_nocritic, llm_config=gpt4_config)\n", + "human.initiate_chat(\n", + " manager_nocritic,\n", + " message=\"\"\"\n", + "find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n", + "\"\"\",\n", + ")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "flaml", + "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.17" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/website/docs/Examples/AutoGen-AgentChat.md b/website/docs/Examples/AutoGen-AgentChat.md index 665930f3d0..632053ddfe 100644 --- a/website/docs/Examples/AutoGen-AgentChat.md +++ b/website/docs/Examples/AutoGen-AgentChat.md @@ -13,5 +13,6 @@ Links to notebook examples: * [Automated Task Solving with GPT-4 + Multiple Human Users](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_two_users.ipynb) * [Automated Chess Game Playing & Chitchatting by GPT-4 Agents](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_chess.ipynb) * [Automated Task Solving by Group Chat](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_groupchat.ipynb) +* [Automated Complex Task Solving by Group Chat](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_groupchat_research.ipynb) * [Automated Continual Learning from New Data](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_stream.ipynb) * [Automated Code Generation and Question Answering with Retrieval Augemented Agents](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_RetrieveChat.ipynb) diff --git a/website/docs/Use-Cases/Autogen.md b/website/docs/Use-Cases/Autogen.md index eeac9f3e8a..f62068fd96 100644 --- a/website/docs/Use-Cases/Autogen.md +++ b/website/docs/Use-Cases/Autogen.md @@ -157,6 +157,7 @@ user_proxy.initiate_chat( * [Automated Task Solving with GPT-4 + Multiple Human Users](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_two_users.ipynb) * [Automated Chess Game Playing & Chitchatting by GPT-4 Agents](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_chess.ipynb) * [Automated Task Solving by Group Chat](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_groupchat.ipynb) +* [Automated Complex Task Solving by Group Chat](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_groupchat_research.ipynb) * [Automated Continual Learning from New Data](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_stream.ipynb) * [Automated Code Generation and Question Answering with Retrieval Augemented Agents](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_RetrieveChat.ipynb)