"`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",
"This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb\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."
"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 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',\n",
" 'api_key': '<your OpenAI API key here>',\n",
" },\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'api_base': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-4-32k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'api_base': '<your Azure OpenAI API base here>',\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."
" system_message=\"Code and answer reviewer.\"\n",
" \"For code, prevent code execution if unsafe or missing important details, e.g., sort order in arxiv API. Suggest changes. Otherwise, approve and return the final code to execute.\"\n",
" \"For answer, carefully check the interpretation of code result and fix any errors. If the interpretation is correct, approve and return the final answer to the user.\",\n",
"To find the latest papers about gpt-4, we can use APIs of scholarly databases like Google Scholar, PubMed, Arxiv, etc., or automation tools like Beautiful Soup to scrape the information from webpages. However, a significant number of these methods are in violation of the terms of service of these platforms. Therefore, it's recommended to manually search these databases. \n",
"But in our case, we'll use the arXiv API, which is a freely accessible database. It holds a vast collection of articles in the field of computer science and many other disciplines. It is often used by researchers to share their papers before they are published, so it could include articles about GPT-4. \n",
"The following Python code uses the requests and feedparser libraries to do this. Requests is used to make a GET request to the arXiv API with the search query as a parameter. Feedparser is used to parse the returned RSS feed. The result is the information of the most recent articles based on publication time related to gpt-4 from arXiv. \n",
"The provided code is mostly correct, but it is missing some important error handling measures. As mentioned in the comments, it does not check if the feed entries are empty. It also does not check if the request was successful before trying to parse the response.\n",
"This version of the script will handle the HTTP, Connection, and Timeout errors as well as any other request error. It also checks that there are results before trying to print.\n",
"Based on the output of the code, the latest paper on GPT-4 found was \"Language as Reality: A Co-Creative Storytelling Game Experience in 1001 Nights using Generative AI\" by Ali Asadipour, published on 24th August 2023. \n",
"This shows the latest found document related to the search term \"GPT-4\" in the arXiv scholarly paper database. Please note that the search query includes all parts of the articles: the title, the abstract, and the full text if available, so it might not be necessarily about GPT-4 but includes the term in some section of the paper.\n",
"The interpretation of the code output is correct. The latest document retrieved related to \"GPT-4\" is indeed \"Language as Reality: A Co-Creative Storytelling Game Experience in 1001 Nights using Generative AI\" by Ali Asadipour, published on 24th August 2023.\n",
"Make sure to understand that the document might not be solely about GPT-4 as the search used covered all aspects of the document. The term \"GPT-4\" could be mentioned anywhere in the paper.\n",