From ddf10044a1184153e532e9a7ef7129a647ffdde7 Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Wed, 27 Sep 2023 16:29:12 +0000 Subject: [PATCH] cleanup --- autogen/oai/openai_utils.py | 2 +- notebook/agentchat_function_call.ipynb | 2 +- notebook/agentchat_planning.ipynb | 4 +- notebook/agentchat_two_users.ipynb | 4 +- website/docs/FAQ.md | 83 ++++++++++++++++++++ website/docs/Use-Cases/enhanced_inference.md | 2 +- 6 files changed, 90 insertions(+), 7 deletions(-) diff --git a/autogen/oai/openai_utils.py b/autogen/oai/openai_utils.py index 0215eeeea..5d2e03919 100644 --- a/autogen/oai/openai_utils.py +++ b/autogen/oai/openai_utils.py @@ -107,7 +107,7 @@ def config_list_openai_aoai( # Assuming Azure OpenAI api bases in os.environ["AZURE_OPENAI_API_BASE"], in separated lines api_bases=os.environ.get("AZURE_OPENAI_API_BASE", "").split("\n"), api_type="azure", - api_version="2023-06-01-preview", # change if necessary + api_version="2023-07-01-preview", # change if necessary ) if exclude != "aoai" else [] diff --git a/notebook/agentchat_function_call.ipynb b/notebook/agentchat_function_call.ipynb index 35e051f38..3c481fffd 100644 --- a/notebook/agentchat_function_call.ipynb +++ b/notebook/agentchat_function_call.ipynb @@ -56,7 +56,7 @@ "It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base.\n", "If you open this notebook in google colab, you can upload your files by click the file icon on the left panel and then choose \"upload file\" icon.\n", "\n", - "The following code excludes Azure OpenAI endpoints from the config list because they don't support functions yet. Remove the `exclude` argument after they do." + "The following code excludes Azure OpenAI endpoints from the config list because some endpoints don't support functions yet. Remove the `exclude` argument if they do." ] }, { diff --git a/notebook/agentchat_planning.ipynb b/notebook/agentchat_planning.ipynb index 8b0d822be..7a2110280 100644 --- a/notebook/agentchat_planning.ipynb +++ b/notebook/agentchat_planning.ipynb @@ -97,14 +97,14 @@ " 'api_key': '',\n", " 'api_base': '',\n", " 'api_type': 'azure',\n", - " 'api_version': '2023-06-01-preview',\n", + " 'api_version': '2023-07-01-preview',\n", " }, # Azure OpenAI API endpoint for gpt-4\n", " {\n", " 'model': 'gpt-4-32k',\n", " 'api_key': '',\n", " 'api_base': '',\n", " 'api_type': 'azure',\n", - " 'api_version': '2023-06-01-preview',\n", + " 'api_version': '2023-07-01-preview',\n", " }, # Azure OpenAI API endpoint for gpt-4-32k\n", "]\n", "```\n", diff --git a/notebook/agentchat_two_users.ipynb b/notebook/agentchat_two_users.ipynb index 07164504b..026efb4d9 100644 --- a/notebook/agentchat_two_users.ipynb +++ b/notebook/agentchat_two_users.ipynb @@ -70,14 +70,14 @@ " \"api_key\": \"\",\n", " \"api_base\": \"\",\n", " \"api_type\": \"azure\",\n", - " \"api_version\": \"2023-06-01-preview\"\n", + " \"api_version\": \"2023-07-01-preview\"\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", + " \"api_version\": \"2023-07-01-preview\"\n", " }\n", "]\n", "```\n", diff --git a/website/docs/FAQ.md b/website/docs/FAQ.md index 318b08dc2..7bb8a2cdf 100644 --- a/website/docs/FAQ.md +++ b/website/docs/FAQ.md @@ -1 +1,84 @@ # Frequently Asked Questions + +## Set your API endpoints + +There are multiple ways to construct a list of configurations for LLM inference. + +### Load a list of endpoints from json + +The [`config_list_from_json`](/docs/reference/autogen/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file. + +For example, + +```python +import autogen +config_list = autogen.config_list_from_json( + "OAI_CONFIG_LIST", + file_location=".", + filter_dict={ + "model": { + "gpt-4", + "gpt-3.5-turbo", + } + } +) +``` + +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" under the specified `file_location`. It then filters the configs by models (you can filter by other keys as well). + +The `OAI_CONFIG_LIST` var or file content looks like the following: +```json +[ + { + "model": "gpt-4", + "api_key": "" + }, + { + "model": "gpt-4", + "api_key": "", + "api_base": "", + "api_type": "azure", + "api_version": "2023-07-01-preview" + }, + { + "model": "gpt-3.5-turbo", + "api_key": "", + "api_base": "", + "api_type": "azure", + "api_version": "2023-07-01-preview" + }, +] +``` + +### Construct a list of endpoints for OpenAI or Azure OpenAI + +he [`config_list_from_models`](/docs/reference/autogen/oai/openai_utils#config_list_from_models) function tries to create a list of configurations using Azure OpenAI endpoints and OpenAI endpoints for the provided list of models. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files: + +- OpenAI API key: os.environ["OPENAI_API_KEY"] or `openai_api_key_file="key_openai.txt"`. +- 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. +- 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. + +It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base. + +```python +import autogen +config_list = autogen.config_list_from_models(model_list=["gpt-4", "gpt-3.5-turbo", "gpt-3.5-turbo-16k"]) +``` + +The config list looks like the following, if only OpenAI API key is available: +```python +config_list = [ + { + 'model': 'gpt-4', + 'api_key': '', + }, # OpenAI API endpoint for gpt-4 + { + 'model': 'gpt-3.5-turbo', + 'api_key': '', + }, # OpenAI API endpoint for gpt-3.5-turbo + { + 'model': 'gpt-3.5-turbo-16k', + 'api_key': '', + }, # OpenAI API endpoint for gpt-3.5-turbo-16k +] +``` diff --git a/website/docs/Use-Cases/enhanced_inference.md b/website/docs/Use-Cases/enhanced_inference.md index 91ab8ea07..d50d67b81 100644 --- a/website/docs/Use-Cases/enhanced_inference.md +++ b/website/docs/Use-Cases/enhanced_inference.md @@ -135,7 +135,7 @@ response = autogen.Completion.create( "api_key": os.environ.get("AZURE_OPENAI_API_KEY"), "api_type": "azure", "api_base": os.environ.get("AZURE_OPENAI_API_BASE"), - "api_version": "2023-06-01-preview", + "api_version": "2023-07-01-preview", }, { "model": "gpt-3.5-turbo",