copy dicts before modifying (#551)

* copy dicts before modifying

* update notebooks

* update notebooks

* close #567
This commit is contained in:
Chi Wang 2023-11-06 13:14:05 -08:00 committed by GitHub
parent 8593807359
commit 306ac4d7f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 248 additions and 508 deletions

View File

@ -70,7 +70,8 @@ class OpenAIWrapper:
if type(config_list) is list and len(config_list) == 0:
logger.warning("openai client was provided with an empty config_list, which may not be intended.")
if config_list:
self._clients = [self._client(config, openai_config) for config in config_list]
config_list = [config.copy() for config in config_list] # make a copy before modifying
self._clients = [self._client(config, openai_config) for config in config_list] # could modify the config
self._config_list = [
{**extra_kwargs, **{k: v for k, v in config.items() if k not in self.openai_kwargs}}
for config in config_list
@ -108,9 +109,9 @@ class OpenAIWrapper:
base_url = config.get("base_url")
if base_url is None:
raise ValueError("to use azure openai api, base_url must be specified.")
suffix = f"openai/deployments/{model}"
suffix = f"/openai/deployments/{model}"
if not base_url.endswith(suffix):
config["base_url"] += suffix
config["base_url"] += suffix[1:] if base_url.endswith("/") else suffix
def _separate_openai_config(self, config):
"""Separate the config into openai_config and extra_kwargs."""

View File

@ -83,8 +83,8 @@ def config_list_openai_aoai(
os.environ["OPENAI_API_KEY"] = key_file.read().strip()
except FileNotFoundError:
logging.info(
"To use OpenAI API, please set OPENAI_API_KEY in os.environ "
"or create key_openai.txt in the specified path, or specify the api_key in config_list."
"OPENAI_API_KEY is not found in os.environ "
"and key_openai.txt is not found in the specified path. You can specify the api_key in the config_list."
)
if "AZURE_OPENAI_API_KEY" not in os.environ and exclude != "aoai":
try:
@ -92,8 +92,8 @@ def config_list_openai_aoai(
os.environ["AZURE_OPENAI_API_KEY"] = key_file.read().strip()
except FileNotFoundError:
logging.info(
"To use Azure OpenAI API, please set AZURE_OPENAI_API_KEY in os.environ "
"or create key_aoai.txt in the specified path, or specify the api_key in config_list."
"AZURE_OPENAI_API_KEY is not found in os.environ "
"and key_aoai.txt is not found in the specified path. You can specify the api_key in the config_list."
)
if "AZURE_OPENAI_API_BASE" not in os.environ and exclude != "aoai":
try:
@ -101,8 +101,8 @@ def config_list_openai_aoai(
os.environ["AZURE_OPENAI_API_BASE"] = key_file.read().strip()
except FileNotFoundError:
logging.info(
"To use Azure OpenAI API, please set AZURE_OPENAI_API_BASE in os.environ "
"or create base_aoai.txt in the specified path, or specify the api_base in config_list."
"AZURE_OPENAI_API_BASE is not found in os.environ "
"and base_aoai.txt is not found in the specified path. You can specify the base_url in the config_list."
)
aoai_config = (
get_config_list(
@ -111,7 +111,7 @@ def config_list_openai_aoai(
# Assuming Azure OpenAI api bases in os.environ["AZURE_OPENAI_API_BASE"], in separated lines
base_urls=os.environ.get("AZURE_OPENAI_API_BASE", "").split("\n"),
api_type="azure",
api_version="2023-07-01-preview", # change if necessary
api_version="2023-08-01-preview", # change if necessary
)
if exclude != "aoai"
else []

View File

@ -1 +1 @@
__version__ = "0.2.0b1"
__version__ = "0.2.0b2"

View File

@ -45,7 +45,7 @@
},
"outputs": [],
"source": [
"# %pip install pyautogen~=0.1.0"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -105,9 +105,7 @@
"]\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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{

View File

@ -35,7 +35,7 @@
"outputs": [],
"source": [
"%%capture --no-stderr\n",
"# %pip install pyautogen~=0.1.0\n",
"# %pip install \"pyautogen~=0.2.0b2\"\n",
"%pip install chess -U"
]
},
@ -119,9 +119,7 @@
"]\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 choosing \"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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{

File diff suppressed because one or more lines are too long

View File

@ -35,7 +35,7 @@
"outputs": [],
"source": [
"%%capture --no-stderr\n",
"# %pip install pyautogen~=0.1.0"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -107,9 +107,7 @@
"]\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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{

View File

@ -91,15 +91,13 @@
" \"model\": \"gpt-35-turbo-0631\", # 0631 or newer is needed to use functions\n",
" \"base_url\": \"<your Azure OpenAI API base>\", \n",
" \"api_type\": \"azure\", \n",
" \"api_version\": \"2023-07-01-preview\", # 2023-07-01-preview or newer is needed to use functions\n",
" \"api_version\": \"2023-08-01-preview\", # 2023-07-01-preview or newer is needed to use functions\n",
" \"api_key\": \"<your Azure OpenAI API key>\"\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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{
@ -424,6 +422,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -1087,6 +1086,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [

View File

@ -33,7 +33,7 @@
"outputs": [],
"source": [
"%%capture --no-stderr\n",
"# %pip install pyautogen~=0.1.0"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -93,9 +93,7 @@
"]\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 choosing \"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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{

View File

@ -33,7 +33,7 @@
"outputs": [],
"source": [
"%%capture --no-stderr\n",
"# %pip install pyautogen~=0.1.0"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -93,21 +93,19 @@
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" 'api_version': '2023-08-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-4-32k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" 'api_version': '2023-08-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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{
@ -119,6 +117,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -1038,7 +1037,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.4"
},
"orig_nbformat": 4
},

View File

@ -45,7 +45,7 @@
},
"outputs": [],
"source": [
"# %pip install pyautogen~=0.1.0"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -74,7 +74,7 @@
"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\".\n",
"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 models with matching names are kept in the list based on the filter condition.\n",
"\n",
"The config list looks like the following:\n",
"```python\n",
@ -82,45 +82,25 @@
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your OpenAI API key here>',\n",
" }, # OpenAI API endpoint for gpt-4\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your first Azure OpenAI API key here>',\n",
" 'base_url': '<your first Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # Azure OpenAI API endpoint for gpt-4\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your second Azure OpenAI API key here>',\n",
" 'base_url': '<your second Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # another Azure OpenAI API endpoint for gpt-4\n",
" },\n",
" {\n",
" 'model': 'gpt-3.5-turbo',\n",
" 'api_key': '<your OpenAI API key here>',\n",
" }, # OpenAI API endpoint for gpt-3.5-turbo\n",
" {\n",
" 'model': 'gpt-3.5-turbo',\n",
" 'api_key': '<your first Azure OpenAI API key here>',\n",
" 'base_url': '<your first Azure OpenAI API base here>',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # Azure OpenAI API endpoint for gpt-3.5-turbo\n",
" 'api_version': '2023-08-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-3.5-turbo',\n",
" 'api_key': '<your second Azure OpenAI API key here>',\n",
" 'base_url': '<your second Azure OpenAI API base here>',\n",
" 'model': 'gpt-3.5-turbo-16k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # another Azure OpenAI API endpoint for gpt-3.5-turbo\n",
" 'api_version': '2023-08-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 choosing \"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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{

View File

@ -28,12 +28,9 @@
"\n",
"## Requirements\n",
"\n",
"AutoGen requires `Python>=3.8`. To run this notebook example, please install the [mathchat] option since we will import functions from `MathUserProxyAgent`:\n",
"AutoGen requires `Python>=3.8`. To run this notebook example, please install `pyautogen` and `Langchain`:\n",
"```bash\n",
"pip install \"pyautogen[mathchat]\"\n",
"```\n",
"```bash\n",
"%pip install Langchain\n",
"pip install pyautogen Langchain\n",
"```"
]
},
@ -48,43 +45,9 @@
"id": "2b803c17",
"outputId": "2e12aa3f-e46c-4b82-cc2e-1495f70a2961"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pyautogen[mathchat]~=0.1.0 in /usr/local/lib/python3.10/dist-packages (0.1.4)\n",
"Requirement already satisfied: diskcache in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (5.6.3)\n",
"Requirement already satisfied: flaml in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (2.1.0)\n",
"Requirement already satisfied: openai in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (0.28.1)\n",
"Requirement already satisfied: termcolor in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (2.3.0)\n",
"Requirement already satisfied: pydantic==1.10.9 in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (1.10.9)\n",
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (1.12)\n",
"Requirement already satisfied: wolframalpha in /usr/local/lib/python3.10/dist-packages (from pyautogen[mathchat]~=0.1.0) (5.0.0)\n",
"Requirement already satisfied: typing-extensions>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from pydantic==1.10.9->pyautogen[mathchat]~=0.1.0) (4.5.0)\n",
"Requirement already satisfied: NumPy>=1.17.0rc1 in /usr/local/lib/python3.10/dist-packages (from flaml->pyautogen[mathchat]~=0.1.0) (1.23.5)\n",
"Requirement already satisfied: requests>=2.20 in /usr/local/lib/python3.10/dist-packages (from openai->pyautogen[mathchat]~=0.1.0) (2.31.0)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from openai->pyautogen[mathchat]~=0.1.0) (4.66.1)\n",
"Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from openai->pyautogen[mathchat]~=0.1.0) (3.8.5)\n",
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->pyautogen[mathchat]~=0.1.0) (1.3.0)\n",
"Requirement already satisfied: xmltodict in /usr/local/lib/python3.10/dist-packages (from wolframalpha->pyautogen[mathchat]~=0.1.0) (0.13.0)\n",
"Requirement already satisfied: more-itertools in /usr/local/lib/python3.10/dist-packages (from wolframalpha->pyautogen[mathchat]~=0.1.0) (10.1.0)\n",
"Requirement already satisfied: jaraco.context in /usr/local/lib/python3.10/dist-packages (from wolframalpha->pyautogen[mathchat]~=0.1.0) (4.3.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.20->openai->pyautogen[mathchat]~=0.1.0) (3.2.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.20->openai->pyautogen[mathchat]~=0.1.0) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.20->openai->pyautogen[mathchat]~=0.1.0) (2.0.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.20->openai->pyautogen[mathchat]~=0.1.0) (2023.7.22)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->openai->pyautogen[mathchat]~=0.1.0) (23.1.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->openai->pyautogen[mathchat]~=0.1.0) (6.0.4)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp->openai->pyautogen[mathchat]~=0.1.0) (4.0.3)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->openai->pyautogen[mathchat]~=0.1.0) (1.9.2)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->openai->pyautogen[mathchat]~=0.1.0) (1.4.0)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->openai->pyautogen[mathchat]~=0.1.0) (1.3.1)\n"
]
}
],
"outputs": [],
"source": [
"%pip install \"pyautogen[mathchat]~=0.1.0\""
"%pip install \"pyautogen~=0.2.0b2\" Langchain"
]
},
{
@ -120,7 +83,47 @@
"source": [
"import autogen\n",
"\n",
"config_list = autogen.config_list_from_models(model_list=[\"gpt-4\", \"gpt-3.5-turbo\", \"gpt-3.5-turbo-16k\"], exclude=\"aoai\", openai_api_key_file=\"key_openai.txt\")\n"
"config_list = autogen.config_list_from_json(\n",
" \"OAI_CONFIG_LIST\",\n",
" filter_dict={\n",
" \"model\": [\"gpt-4\", \"gpt-3.5-turbo\", \"gpt-3.5-turbo-16k\"],\n",
" },\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "dd1cda81",
"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 models with matching names 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-3.5-turbo',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-08-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-3.5-turbo-16k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-08-01-preview',\n",
" },\n",
"]\n",
"```\n",
"\n",
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{
@ -136,61 +139,6 @@
"In this example, we demonstrate function call execution with `AssistantAgent` and `UserProxyAgent`. With the default system prompt of `AssistantAgent`, we allow the LLM assistant to perform tasks with code, and the `UserProxyAgent` would extract code blocks from the LLM response and execute them. With the new \"function_call\" feature, we define functions and specify the description of the function in the OpenAI config for the `AssistantAgent`. Then we register the functions in `UserProxyAgent`.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ngpFkWh5ad9M",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ngpFkWh5ad9M",
"outputId": "d33b51c6-5dfe-402d-dce4-6b40fca85d3d"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: Langchain in /usr/local/lib/python3.10/dist-packages (0.0.305)\n",
"Requirement already satisfied: PyYAML>=5.3 in /usr/local/lib/python3.10/dist-packages (from Langchain) (6.0.1)\n",
"Requirement already satisfied: SQLAlchemy<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from Langchain) (2.0.20)\n",
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /usr/local/lib/python3.10/dist-packages (from Langchain) (3.8.5)\n",
"Requirement already satisfied: anyio<4.0 in /usr/local/lib/python3.10/dist-packages (from Langchain) (3.7.1)\n",
"Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from Langchain) (4.0.3)\n",
"Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /usr/local/lib/python3.10/dist-packages (from Langchain) (0.6.1)\n",
"Requirement already satisfied: jsonpatch<2.0,>=1.33 in /usr/local/lib/python3.10/dist-packages (from Langchain) (1.33)\n",
"Requirement already satisfied: langsmith<0.1.0,>=0.0.38 in /usr/local/lib/python3.10/dist-packages (from Langchain) (0.0.41)\n",
"Requirement already satisfied: numexpr<3.0.0,>=2.8.4 in /usr/local/lib/python3.10/dist-packages (from Langchain) (2.8.5)\n",
"Requirement already satisfied: numpy<2,>=1 in /usr/local/lib/python3.10/dist-packages (from Langchain) (1.23.5)\n",
"Requirement already satisfied: pydantic<3,>=1 in /usr/local/lib/python3.10/dist-packages (from Langchain) (1.10.9)\n",
"Requirement already satisfied: requests<3,>=2 in /usr/local/lib/python3.10/dist-packages (from Langchain) (2.31.0)\n",
"Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from Langchain) (8.2.3)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->Langchain) (23.1.0)\n",
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->Langchain) (3.2.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->Langchain) (6.0.4)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->Langchain) (1.9.2)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->Langchain) (1.4.0)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->Langchain) (1.3.1)\n",
"Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<4.0->Langchain) (3.4)\n",
"Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/dist-packages (from anyio<4.0->Langchain) (1.3.0)\n",
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<4.0->Langchain) (1.1.3)\n",
"Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->Langchain) (3.20.1)\n",
"Requirement already satisfied: typing-inspect<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->Langchain) (0.9.0)\n",
"Requirement already satisfied: jsonpointer>=1.9 in /usr/local/lib/python3.10/dist-packages (from jsonpatch<2.0,>=1.33->Langchain) (2.4)\n",
"Requirement already satisfied: typing-extensions>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->Langchain) (4.5.0)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->Langchain) (2.0.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->Langchain) (2023.7.22)\n",
"Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy<3,>=1.4->Langchain) (2.0.2)\n",
"Requirement already satisfied: packaging>=17.0 in /usr/local/lib/python3.10/dist-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json<0.7,>=0.5.7->Langchain) (23.1)\n",
"Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->Langchain) (1.0.0)\n"
]
}
],
"source": [
"%pip install Langchain"
]
},
{
"cell_type": "code",
"execution_count": null,

View File

@ -45,7 +45,7 @@
},
"outputs": [],
"source": [
"# %pip install pyautogen~=0.1.0 docker"
"# %pip install pyautogen~=0.2.0b2 docker"
]
},
{
@ -55,13 +55,9 @@
"source": [
"## Set your API Endpoint\n",
"\n",
"* The [`config_list_openai_aoai`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_openai_aoai) function tries to create a list of configurations using Azure OpenAI endpoints and OpenAI endpoints. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\n",
" - OpenAI API key: os.environ[\"OPENAI_API_KEY\"] or `openai_api_key_file=\"key_openai.txt\"`.\n",
" - Azure OpenAI API key: os.environ[\"AZURE_OPENAI_API_KEY\"] or `aoai_api_key_file=\"key_aoai.txt\"`. Multiple keys can be stored, one per line.\n",
" - Azure OpenAI API base: os.environ[\"AZURE_OPENAI_API_BASE\"] or `aoai_api_base_file=\"base_aoai.txt\"`. Multiple bases can be stored, one per line.\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. It first looks for an environment variable with a specified name. The value of the environment variable needs to be a valid json string. If that variable is not found, it looks for a json file with the same name. It filters the configs by filter_dict.\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. It first looks for an environment variable with a specified name. The value of the environment variable needs to be a valid json string. If that variable is not found, it looks for a json file with the same name. It filters the configs by filter_dict.\n",
"\n",
"It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base. If you open this notebook in colab, you can upload your files by clicking the file icon on the left panel and then choosing \"upload file\" icon.\n"
"It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base.\n"
]
},
{
@ -97,21 +93,19 @@
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-07-01-preview',\n",
" 'api_version': '2023-08-01-preview',\n",
" }, # Azure OpenAI API endpoint for gpt-4\n",
" {\n",
" 'model': 'gpt-4-32k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-07-01-preview',\n",
" 'api_version': '2023-08-01-preview',\n",
" }, # Azure OpenAI API endpoint for gpt-4-32k\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 choosing \"upload file\" icon.\n",
"\n",
"You can set the value of config_list in other ways, e.g., loading from a YAML file.\n",
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods.\n",
"\n",
"## Construct Agents\n",
"\n",
@ -163,8 +157,7 @@
" \"temperature\": 0,\n",
" \"timeout\": 600,\n",
" \"seed\": 42,\n",
" \"model\": \"gpt-4-0613\",\n",
" \"config_list\": autogen.config_list_openai_aoai(exclude=\"aoai\"),\n",
" \"config_list\": config_list,\n",
" \"functions\": [\n",
" {\n",
" \"name\": \"ask_planner\",\n",
@ -221,9 +214,7 @@
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"To suggest a fix to an open good first issue of FLAML, we first need to fetch the list of open issues labeled as \"good first issue\" from the FLAML GitHub repository. We can do this using the GitHub API.\n",
"\n",
"Here is a Python script that uses the requests library to fetch the list of open issues labeled as \"good first issue\" from the FLAML GitHub repository.\n",
"To suggest a fix to an open good first issue of FLAML, we first need to fetch the list of open issues labeled as \"good first issue\" from the FLAML GitHub repository. We can do this using the GitHub API. Here is a Python script that fetches and prints the list of open issues labeled as \"good first issue\" from the FLAML repository.\n",
"\n",
"```python\n",
"# filename: fetch_issues.py\n",
@ -238,44 +229,56 @@
" \"labels\": \"good first issue\"\n",
" }\n",
" response = requests.get(url, params=params)\n",
" issues = response.json()\n",
" issues = json.loads(response.text)\n",
" for issue in issues:\n",
" print(f\"Issue ID: {issue['id']}, Title: {issue['title']}, URL: {issue['html_url']}\")\n",
" print(f\"Issue #{issue['number']}: {issue['title']}\")\n",
"\n",
"fetch_issues()\n",
"if __name__ == \"__main__\":\n",
" fetch_issues()\n",
"```\n",
"\n",
"Please run this script to fetch the list of open issues. After that, we can select one issue and suggest a fix for it.\n",
"Please run this script to fetch the list of open issues. After that, I can help you analyze one of the issues and suggest a potential fix.\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",
">>>>>>>> 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[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
"Issue ID: 1809297895, Title: Moving function execution out of UserProxyAgent to be an openai util, URL: https://github.com/microsoft/FLAML/issues/1135\n",
"Issue ID: 1799114476, Title: use_label_encoder warning with xgboost, URL: https://github.com/microsoft/FLAML/issues/1120\n",
"Issue ID: 1705274482, Title: Use appropriate wait time for retry based on the error message. , URL: https://github.com/microsoft/FLAML/issues/1034\n",
"Issue ID: 1702580697, Title: Issues with Adding Custom APIs in Auto Generation, URL: https://github.com/microsoft/FLAML/issues/1029\n",
"Issue ID: 1658981020, Title: Running flaml[tune] using \"-O\" flag for python interpreter (optimization - disables assertions) crashes, URL: https://github.com/microsoft/FLAML/issues/981\n",
"Issue ID: 1560969891, Title: Conditional parameter flow2 crash, URL: https://github.com/microsoft/FLAML/issues/903\n",
"Issue ID: 1538549388, Title: indentation space, URL: https://github.com/microsoft/FLAML/issues/884\n",
"Issue ID: 1531028010, Title: Check if openml version is required, URL: https://github.com/microsoft/FLAML/issues/882\n",
"Issue ID: 1470354491, Title: Adjust the indent, URL: https://github.com/microsoft/FLAML/issues/834\n",
"Issue ID: 1456950742, Title: pip install flaml FAIL, URL: https://github.com/microsoft/FLAML/issues/821\n",
"Issue ID: 1441047067, Title: Isolate the ensemble part and expose it to users, URL: https://github.com/microsoft/FLAML/issues/807\n",
"Issue ID: 1440171793, Title: how to pass categorical features names or indices to learner, URL: https://github.com/microsoft/FLAML/issues/805\n",
"Issue ID: 1429945686, Title: Flaml/LightGBM - Shouldn't I found better/faster or equal results from FLAML than direct LightGBM?, URL: https://github.com/microsoft/FLAML/issues/785\n",
"Issue ID: 1408240042, Title: Add an announcement of the discord channel, URL: https://github.com/microsoft/FLAML/issues/764\n",
"Issue ID: 1396515109, Title: Documentation about small budget, URL: https://github.com/microsoft/FLAML/issues/748\n",
"Issue ID: 1378268096, Title: Make zero-shot automl more discoverable, URL: https://github.com/microsoft/FLAML/issues/737\n",
"Issue ID: 1189515901, Title: New HCrystalBall release, URL: https://github.com/microsoft/FLAML/issues/509\n",
"Issue ID: 1114253143, Title: samples about conversion to ONNX, URL: https://github.com/microsoft/FLAML/issues/429\n",
"Issue ID: 1107488969, Title: support anomaly detection, URL: https://github.com/microsoft/FLAML/issues/413\n",
"Issue ID: 1061332179, Title: CatBoost Fails with Keyword 'groups', URL: https://github.com/microsoft/FLAML/issues/304\n",
"Issue #1228: include that `retrain_full = True` does not include the user provided validation data in the docs.\n",
"Issue #1120: use_label_encoder warning with xgboost\n",
"Issue #981: Running flaml[tune] using \"-O\" flag for python interpreter (optimization - disables assertions) crashes\n",
"Issue #903: Conditional parameter flow2 crash\n",
"Issue #884: indentation space\n",
"Issue #882: Check if openml version is required\n",
"Issue #834: Adjust the indent\n",
"Issue #821: pip install flaml FAIL\n",
"Issue #807: Isolate the ensemble part and expose it to users\n",
"Issue #805: how to pass categorical features names or indices to learner\n",
"Issue #785: Flaml/LightGBM - Shouldn't I found better/faster or equal results from FLAML than direct LightGBM?\n",
"Issue #764: Add an announcement of the discord channel\n",
"Issue #748: Documentation about small budget\n",
"Issue #737: Make zero-shot automl more discoverable\n",
"Issue #509: New HCrystalBall release\n",
"Issue #429: samples about conversion to ONNX\n",
"Issue #413: support anomaly detection\n",
"Issue #304: CatBoost Fails with Keyword 'groups'\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
@ -284,7 +287,7 @@
"\u001b[32m***** Suggested function Call: ask_planner *****\u001b[0m\n",
"Arguments: \n",
"{\n",
"\"message\": \"We have fetched a list of open issues labeled as 'good first issue' from the FLAML GitHub repository. Now, we need to select one issue and suggest a fix for it. Could you please provide a plan for this?\"\n",
" \"message\": \"Here are the open issues labeled as 'good first issue' in the FLAML repository. Please suggest a plan to fix one of these issues. \\n\\n1. Issue #1228: include that `retrain_full = True` does not include the user provided validation data in the docs.\\n2. Issue #1120: use_label_encoder warning with xgboost\\n3. Issue #981: Running flaml[tune] using \\\"-O\\\" flag for python interpreter (optimization - disables assertions) crashes\\n4. Issue #903: Conditional parameter flow2 crash\\n5. Issue #884: indentation space\\n6. Issue #882: Check if openml version is required\\n7. Issue #834: Adjust the indent\\n8. Issue #821: pip install flaml FAIL\\n9. Issue #807: Isolate the ensemble part and expose it to users\\n10. Issue #805: how to pass categorical features names or indices to learner\\n11. Issue #785: Flaml/LightGBM - Shouldn't I found better/faster or equal results from FLAML than direct LightGBM?\\n12. Issue #764: Add an announcement of the discord channel\\n13. Issue #748: Documentation about small budget\\n14. Issue #737: Make zero-shot automl more discoverable\\n15. Issue #509: New HCrystalBall release\\n16. Issue #429: samples about conversion to ONNX\\n17. Issue #413: support anomaly detection\\n18. Issue #304: CatBoost Fails with Keyword 'groups'\"\n",
"}\n",
"\u001b[32m************************************************\u001b[0m\n",
"\n",
@ -295,92 +298,91 @@
">>>>>>>> EXECUTING FUNCTION ask_planner...\u001b[0m\n",
"\u001b[33mplanner_user\u001b[0m (to planner):\n",
"\n",
"We have fetched a list of open issues labeled as 'good first issue' from the FLAML GitHub repository. Now, we need to select one issue and suggest a fix for it. Could you please provide a plan for this?\n",
"Here are the open issues labeled as 'good first issue' in the FLAML repository. Please suggest a plan to fix one of these issues. \n",
"\n",
"1. Issue #1228: include that `retrain_full = True` does not include the user provided validation data in the docs.\n",
"2. Issue #1120: use_label_encoder warning with xgboost\n",
"3. Issue #981: Running flaml[tune] using \"-O\" flag for python interpreter (optimization - disables assertions) crashes\n",
"4. Issue #903: Conditional parameter flow2 crash\n",
"5. Issue #884: indentation space\n",
"6. Issue #882: Check if openml version is required\n",
"7. Issue #834: Adjust the indent\n",
"8. Issue #821: pip install flaml FAIL\n",
"9. Issue #807: Isolate the ensemble part and expose it to users\n",
"10. Issue #805: how to pass categorical features names or indices to learner\n",
"11. Issue #785: Flaml/LightGBM - Shouldn't I found better/faster or equal results from FLAML than direct LightGBM?\n",
"12. Issue #764: Add an announcement of the discord channel\n",
"13. Issue #748: Documentation about small budget\n",
"14. Issue #737: Make zero-shot automl more discoverable\n",
"15. Issue #509: New HCrystalBall release\n",
"16. Issue #429: samples about conversion to ONNX\n",
"17. Issue #413: support anomaly detection\n",
"18. Issue #304: CatBoost Fails with Keyword 'groups'\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mplanner\u001b[0m (to planner_user):\n",
"\n",
"Sure, here's a plan for selecting one issue from the list and suggesting a fix for it:\n",
"Here are the steps to fix the first issue (Issue #1228: include that `retrain_full = True` does not include the user provided validation data in the docs):\n",
"\n",
"1. Import the fetched list of open issues labeled as 'good first issue' from the FLAML GitHub repository into your AI assistant. \n",
"2. Examine the list for common issue attributes like 'title', 'description', 'labels', 'issue number', 'created at', and 'updated at'. \n",
"3. To select a suitable issue for fixing, apply a selection criteria based on your preferences, such as prioritizing by the 'created at' attribute in descending order to pick the most recent issue, or filtering by a specific label in addition to 'good first issue'. Write code to filter and sort the issues accordingly.\n",
"4. Inspect the execution result. If the selection criteria are not applied correctly, modify the code to fix any errors.\n",
"5. Once the issue is selected, read the issue's title, description, and any linked resources or documents to understand the problem to be solved.\n",
"6. Break down the issue into smaller tasks that can be addressed by writing code, and create a step-by-step plan.\n",
"1. **Identify where the issue is**: Understand the context of `retrain_full = True` within FLAML. Figure out how it works - whether it really ignores the user-provided validation data or not.\n",
"\n",
"For instance, the following could be smaller tasks to address the selected issue:\n",
" a. Understand the issue's background and requirements.\n",
" b. Write clear and concise instructions to reproduce the issue.\n",
" c. Analyze existing code or tests related to the issue.\n",
" d. Devise a solution to fix the issue.\n",
" e. Implement the solution in separate code pieces.\n",
" f. Verify that the solution addresses the issue.\n",
" g. Write unit tests to ensure the solution is robust and handles edge cases.\n",
"2. **Update the documentation**: Based on your understanding, update the corresponding part of the documentation to include a note or clarification about this fact. You can use Markdown language to do the documentation. The note can be written in a clear and concise way.\n",
"\n",
"7. Inspect the execution result. If the issue is misunderstood or the tasks' breakdown is incorrect, revise the understanding of the issue and modify the tasks accordingly.\n",
"8. With the defined tasks and step-by-step plan, work on each task, and test the implemented code to ensure the issue is solved.\n",
"9. If any issues arise during the task execution, analyze the errors and adjust the plan or code accordingly.\n",
"10. Once the issue is fixed, prepare a pull request on GitHub, mentioning the issue number and giving a brief description of the solution in the merge request.\n",
"3. **Commit and Push Code**: After making the necessary changes, commit and push the changes to your repository. Make sure to include a detailed commit message to make it clear what changes were made.\n",
"\n",
"Remember that this is meant to be a general plan, and the specific tasks may vary depending on the selected issue. Adjust the plan as needed, based on the selected issue's requirements and your problem-solving approach.\n",
"4. **Submit a Pull Request (PR)**: Then submit a pull request to the FLAML repository. In the message of the PR, be sure to reference the issue number (i.e. #1228), to automatically link it.\n",
"\n",
"5. **Wait for Review**: Maintainers will then review your code. They may suggest changes or improvements, and once they're satisfied, they'll merge your changes into the main repository.\n",
"\n",
"6. **Inspect the Results**: After the pull request is merged, verify that the changes have been successfully incorporated and the documentation correctly reflects the behavior of `retrain_full = True`.\n",
"\n",
"Please note, this plan does not involve writing code in any programming language. Instead, it focuses on understanding the library, editing Markdown files, and using Git and GitHub functionalities appropriately. \n",
"\n",
"Should any of your actions result in an error, this could be due to multiple reasons such as misinterpretation of the behaviour of `retrain_full = True`, errors in the markdown syntax, among others. You will need to debug the error based on the specific error message and review your changes. After making corrections, you should commit and push your changes and verify that the error has been fixed.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"\u001b[32m***** Response from calling function \"ask_planner\" *****\u001b[0m\n",
"Sure, here's a plan for selecting one issue from the list and suggesting a fix for it:\n",
"Here are the steps to fix the first issue (Issue #1228: include that `retrain_full = True` does not include the user provided validation data in the docs):\n",
"\n",
"1. Import the fetched list of open issues labeled as 'good first issue' from the FLAML GitHub repository into your AI assistant. \n",
"2. Examine the list for common issue attributes like 'title', 'description', 'labels', 'issue number', 'created at', and 'updated at'. \n",
"3. To select a suitable issue for fixing, apply a selection criteria based on your preferences, such as prioritizing by the 'created at' attribute in descending order to pick the most recent issue, or filtering by a specific label in addition to 'good first issue'. Write code to filter and sort the issues accordingly.\n",
"4. Inspect the execution result. If the selection criteria are not applied correctly, modify the code to fix any errors.\n",
"5. Once the issue is selected, read the issue's title, description, and any linked resources or documents to understand the problem to be solved.\n",
"6. Break down the issue into smaller tasks that can be addressed by writing code, and create a step-by-step plan.\n",
"1. **Identify where the issue is**: Understand the context of `retrain_full = True` within FLAML. Figure out how it works - whether it really ignores the user-provided validation data or not.\n",
"\n",
"For instance, the following could be smaller tasks to address the selected issue:\n",
" a. Understand the issue's background and requirements.\n",
" b. Write clear and concise instructions to reproduce the issue.\n",
" c. Analyze existing code or tests related to the issue.\n",
" d. Devise a solution to fix the issue.\n",
" e. Implement the solution in separate code pieces.\n",
" f. Verify that the solution addresses the issue.\n",
" g. Write unit tests to ensure the solution is robust and handles edge cases.\n",
"2. **Update the documentation**: Based on your understanding, update the corresponding part of the documentation to include a note or clarification about this fact. You can use Markdown language to do the documentation. The note can be written in a clear and concise way.\n",
"\n",
"7. Inspect the execution result. If the issue is misunderstood or the tasks' breakdown is incorrect, revise the understanding of the issue and modify the tasks accordingly.\n",
"8. With the defined tasks and step-by-step plan, work on each task, and test the implemented code to ensure the issue is solved.\n",
"9. If any issues arise during the task execution, analyze the errors and adjust the plan or code accordingly.\n",
"10. Once the issue is fixed, prepare a pull request on GitHub, mentioning the issue number and giving a brief description of the solution in the merge request.\n",
"3. **Commit and Push Code**: After making the necessary changes, commit and push the changes to your repository. Make sure to include a detailed commit message to make it clear what changes were made.\n",
"\n",
"Remember that this is meant to be a general plan, and the specific tasks may vary depending on the selected issue. Adjust the plan as needed, based on the selected issue's requirements and your problem-solving approach.\n",
"4. **Submit a Pull Request (PR)**: Then submit a pull request to the FLAML repository. In the message of the PR, be sure to reference the issue number (i.e. #1228), to automatically link it.\n",
"\n",
"5. **Wait for Review**: Maintainers will then review your code. They may suggest changes or improvements, and once they're satisfied, they'll merge your changes into the main repository.\n",
"\n",
"6. **Inspect the Results**: After the pull request is merged, verify that the changes have been successfully incorporated and the documentation correctly reflects the behavior of `retrain_full = True`.\n",
"\n",
"Please note, this plan does not involve writing code in any programming language. Instead, it focuses on understanding the library, editing Markdown files, and using Git and GitHub functionalities appropriately. \n",
"\n",
"Should any of your actions result in an error, this could be due to multiple reasons such as misinterpretation of the behaviour of `retrain_full = True`, errors in the markdown syntax, among others. You will need to debug the error based on the specific error message and review your changes. After making corrections, you should commit and push your changes and verify that the error has been fixed.\n",
"\u001b[32m********************************************************\u001b[0m\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"Based on the plan, let's select the most recent issue from the list. The most recent issue is \"Moving function execution out of UserProxyAgent to be an openai util\" with the URL: https://github.com/microsoft/FLAML/issues/1135\n",
"To fix the issue #1228, you need to follow these steps:\n",
"\n",
"To suggest a fix for this issue, we need to understand the problem first. Please visit the issue URL and read the issue's description and any comments to understand the problem.\n",
"1. **Identify where the issue is**: Understand the context of `retrain_full = True` within FLAML. Figure out how it works - whether it really ignores the user-provided validation data or not.\n",
"\n",
"Once you understand the problem, here are the steps you can follow to suggest a fix:\n",
"2. **Update the documentation**: Based on your understanding, update the corresponding part of the documentation to include a note or clarification about this fact. You can use Markdown language to do the documentation. The note can be written in a clear and concise way.\n",
"\n",
"1. Understand the issue's background and requirements: Read the issue description and any linked resources or documents to understand what needs to be done.\n",
"3. **Commit and Push Code**: After making the necessary changes, commit and push the changes to your repository. Make sure to include a detailed commit message to make it clear what changes were made.\n",
"\n",
"2. Write clear and concise instructions to reproduce the issue: Based on the issue description, write down the steps to reproduce the issue. This will help you understand the problem better and will be useful when you test your fix.\n",
"4. **Submit a Pull Request (PR)**: Then submit a pull request to the FLAML repository. In the message of the PR, be sure to reference the issue number (i.e. #1228), to automatically link it.\n",
"\n",
"3. Analyze existing code or tests related to the issue: Look at the code in the FLAML repository that is related to the issue. Try to understand how it works and how it might be causing the issue.\n",
"5. **Wait for Review**: Maintainers will then review your code. They may suggest changes or improvements, and once they're satisfied, they'll merge your changes into the main repository.\n",
"\n",
"4. Devise a solution to fix the issue: Based on your understanding of the problem and the code, come up with a solution to fix the issue. This might involve writing new code or modifying existing code.\n",
"6. **Inspect the Results**: After the pull request is merged, verify that the changes have been successfully incorporated and the documentation correctly reflects the behavior of `retrain_full = True`.\n",
"\n",
"5. Implement the solution in separate code pieces: Write the code for your solution. Make sure to break it down into small, manageable pieces. This will make it easier to understand and test.\n",
"Please note, this plan does not involve writing code in any programming language. Instead, it focuses on understanding the library, editing Markdown files, and using Git and GitHub functionalities appropriately. \n",
"\n",
"6. Verify that the solution addresses the issue: Test your code to make sure it solves the issue. You can do this by following the instructions you wrote to reproduce the issue.\n",
"\n",
"7. Write unit tests to ensure the solution is robust and handles edge cases: In addition to testing your solution manually, write unit tests to automatically test your code. This will help ensure that your solution works in all cases and that future changes to the code won't break your solution.\n",
"\n",
"8. Prepare a pull request on GitHub: Once you're confident that your solution works, prepare a pull request on GitHub. In the pull request description, mention the issue number and give a brief description of your solution.\n",
"\n",
"Please note that this is a general plan and the specific steps may vary depending on the issue. Adjust the plan as needed based on the issue's requirements and your problem-solving approach. \n",
"Should any of your actions result in an error, this could be due to multiple reasons such as misinterpretation of the behaviour of `retrain_full = True`, errors in the markdown syntax, among others. You will need to debug the error based on the specific error message and review your changes. After making corrections, you should commit and push your changes and verify that the error has been fixed.\n",
"\n",
"TERMINATE\n",
"\n",
@ -437,7 +439,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.11.4"
},
"vscode": {
"interpreter": {

View File

@ -45,7 +45,7 @@
},
"outputs": [],
"source": [
"# %pip install pyautogen~=0.1.0"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -82,45 +82,25 @@
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your OpenAI API key here>',\n",
" }, # OpenAI API endpoint for gpt-4\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your first Azure OpenAI API key here>',\n",
" 'base_url': '<your first Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # Azure OpenAI API endpoint for gpt-4\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your second Azure OpenAI API key here>',\n",
" 'base_url': '<your second Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # another Azure OpenAI API endpoint for gpt-4\n",
" },\n",
" {\n",
" 'model': 'gpt-3.5-turbo',\n",
" 'api_key': '<your OpenAI API key here>',\n",
" }, # OpenAI API endpoint for gpt-3.5-turbo\n",
" {\n",
" 'model': 'gpt-3.5-turbo',\n",
" 'api_key': '<your first Azure OpenAI API key here>',\n",
" 'base_url': '<your first Azure OpenAI API base here>',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # Azure OpenAI API endpoint for gpt-3.5-turbo\n",
" 'api_version': '2023-08-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-3.5-turbo',\n",
" 'api_key': '<your second Azure OpenAI API key here>',\n",
" 'base_url': '<your second Azure OpenAI API base here>',\n",
" 'model': 'gpt-3.5-turbo-16k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" }, # another Azure OpenAI API endpoint for gpt-3.5-turbo\n",
" 'api_version': '2023-08-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 choosing \"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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{

View File

@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
"# %pip install pyautogen~=0.1.1"
"# %pip install pyautogen~=0.2.0b2"
]
},
{
@ -70,19 +70,19 @@
" \"api_key\": \"<your Azure OpenAI API key here>\",\n",
" \"base_url\": \"<your Azure OpenAI API base here>\",\n",
" \"api_type\": \"azure\",\n",
" \"api_version\": \"2023-07-01-preview\"\n",
" \"api_version\": \"2023-08-01-preview\"\n",
" },\n",
" {\n",
" \"model\": \"gpt-4-32k\",\n",
" \"api_key\": \"<your Azure OpenAI API key here>\",\n",
" \"base_url\": \"<your Azure OpenAI API base here>\",\n",
" \"api_type\": \"azure\",\n",
" \"api_version\": \"2023-07-01-preview\"\n",
" \"api_version\": \"2023-08-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 choosing \"upload file\" icon.\n"
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{
@ -162,10 +162,7 @@
" llm_config={\n",
" \"timeout\": 600,\n",
" \"seed\": 42,\n",
" # Excluding azure openai endpoints from the config list.\n",
" # Change to `exclude=\"openai\"` to exclude openai endpoints, or remove the `exclude` argument to include both.\n",
" \"config_list\": autogen.config_list_openai_aoai(exclude=\"aoai\"),\n",
" \"model\": \"gpt-4-0613\", # make sure the endpoint you use supports the model\n",
" \"config_list\": config_list,\n",
" \"temperature\": 0,\n",
" \"functions\": [\n",
" {\n",

View File

@ -49,7 +49,7 @@
},
"outputs": [],
"source": [
"# %pip install pyautogen~=0.1.0 docker"
"# %pip install pyautogen~=0.2.0b2 docker"
]
},
{
@ -104,21 +104,19 @@
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" 'api_version': '2023-08-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-4-32k-0314',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'base_url': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" 'api_version': '2023-08-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 choosing \"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."
"You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
]
},
{
@ -606,7 +604,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.11.4"
},
"vscode": {
"interpreter": {