From 9a529ee5798328bb4f5ff23d6fa0455515dfacc5 Mon Sep 17 00:00:00 2001 From: Christian Muertz Date: Fri, 16 Dec 2022 16:27:07 +0100 Subject: [PATCH 1/4] Update api_version --- openai/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openai/__init__.py b/openai/__init__.py index b65b86d003..d935ea8ca5 100644 --- a/openai/__init__.py +++ b/openai/__init__.py @@ -34,7 +34,7 @@ api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1") api_type = os.environ.get("OPENAI_API_TYPE", "open_ai") api_version = ( - "2022-03-01-preview" if api_type in ("azure", "azure_ad", "azuread") else None + "2022-12-01" if api_type in ("azure", "azure_ad", "azuread") else None ) verify_ssl_certs = True # No effect. Certificates are always verified. proxy = None From 2262a0e63fddb7420553c753321027538e85885c Mon Sep 17 00:00:00 2001 From: Christian Muertz Date: Fri, 16 Dec 2022 16:49:54 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1dad8c0a96..e44ca041ce 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ All endpoints have a `.create` method that support a `request_timeout` param. T ### Microsoft Azure Endpoints -In order to use the library with Microsoft Azure endpoints, you need to set the api_type, api_base and api_version in addition to the api_key. The api_type must be set to 'azure' and the others correspond to the properties of your endpoint. +In order to use the library with Microsoft Azure endpoints, you need to set the `api_type`, `api_base` and `api_version` in addition to the `api_key`. The `api_type` must be set to 'azure' and the others correspond to the properties of your endpoint. In addition, the deployment name must be passed as the engine parameter. ```python @@ -66,7 +66,7 @@ import openai openai.api_type = "azure" openai.api_key = "..." openai.api_base = "https://example-endpoint.openai.azure.com" -openai.api_version = "2021-11-01-preview" +openai.api_version = "2022-12-01" # create a completion completion = openai.Completion.create(engine="deployment-name", prompt="Hello world") @@ -74,21 +74,19 @@ completion = openai.Completion.create(engine="deployment-name", prompt="Hello wo # print the completion print(completion.choices[0].text) -# create a search and pass the deployment-name as the engine Id. -search = openai.Engine(id="deployment-name").search(documents=["White House", "hospital", "school"], query ="the president") - # print the search print(search) ``` -Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, search and fine-tuning operations. +Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, embeddings, and fine-tuning operations. For a detailed example on how to use fine-tuning and other operations using Azure endpoints, please check out the following Jupyter notebooks: +* [Using Azure completions](https://github.com/openai/openai-cookbook/tree/main/examples/azure/completions.ipynb) * [Using Azure fine-tuning](https://github.com/openai/openai-cookbook/tree/main/examples/azure/finetuning.ipynb) * [Using Azure embeddings](https://github.com/openai/openai-cookbook/blob/main/examples/azure/embeddings.ipynb) ### Microsoft Azure Active Directory Authentication -In order to use Microsoft Active Directory to authenticate to your Azure endpoint, you need to set the api_type to "azure_ad" and pass the acquired credential token to api_key. The rest of the parameters need to be set as specified in the previous section. +In order to use Microsoft Active Directory to authenticate to your Azure endpoint, you need to set the `api_type` to "azure_ad" and pass the acquired credential token to `api_key`. The rest of the parameters need to be set as specified in the previous section. ```python @@ -103,7 +101,7 @@ token = default_credential.get_token("https://cognitiveservices.azure.com") openai.api_type = "azure_ad" openai.api_key = token.token openai.api_base = "https://example-endpoint.openai.azure.com/" -openai.api_version = "2022-03-01-preview" +openai.api_version = "2022-12-01" # ... ``` From cf087da2a1d24f196b830696006008bd9c3d7c8a Mon Sep 17 00:00:00 2001 From: Christian Muertz Date: Tue, 20 Dec 2022 16:03:42 +0100 Subject: [PATCH 3/4] Fix README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e44ca041ce..516d4c6eee 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ print(completion.choices[0].text) print(search) ``` -Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, embeddings, and fine-tuning operations. +Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, embedding, and fine-tuning operations. For a detailed example on how to use fine-tuning and other operations using Azure endpoints, please check out the following Jupyter notebooks: * [Using Azure completions](https://github.com/openai/openai-cookbook/tree/main/examples/azure/completions.ipynb) * [Using Azure fine-tuning](https://github.com/openai/openai-cookbook/tree/main/examples/azure/finetuning.ipynb) @@ -95,7 +95,7 @@ import openai # Request credential default_credential = DefaultAzureCredential() -token = default_credential.get_token("https://cognitiveservices.azure.com") +token = default_credential.get_token("https://cognitiveservices.azure.com/.default") # Setup parameters openai.api_type = "azure_ad" From 3ee2bc92cf78c5203f9b8fe6aebae2b9d2ce6d75 Mon Sep 17 00:00:00 2001 From: Christian Muertz Date: Tue, 20 Dec 2022 16:05:54 +0100 Subject: [PATCH 4/4] Fix README --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 516d4c6eee..5bd40a7919 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,6 @@ completion = openai.Completion.create(engine="deployment-name", prompt="Hello wo # print the completion print(completion.choices[0].text) - -# print the search -print(search) ``` Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, embedding, and fine-tuning operations.