Skip to content

Commit ec4943f

Browse files
authored
Azure OpenAI 2022-12-01 (#159)
* Update api_version * Update README.md * Fix README * Fix README
1 parent cb120bf commit ec4943f

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

README.md

+7-12
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,32 @@ All endpoints have a `.create` method that support a `request_timeout` param. T
5858

5959
### Microsoft Azure Endpoints
6060

61-
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.
61+
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.
6262
In addition, the deployment name must be passed as the engine parameter.
6363

6464
```python
6565
import openai
6666
openai.api_type = "azure"
6767
openai.api_key = "..."
6868
openai.api_base = "https://example-endpoint.openai.azure.com"
69-
openai.api_version = "2021-11-01-preview"
69+
openai.api_version = "2022-12-01"
7070

7171
# create a completion
7272
completion = openai.Completion.create(engine="deployment-name", prompt="Hello world")
7373

7474
# print the completion
7575
print(completion.choices[0].text)
76-
77-
# create a search and pass the deployment-name as the engine Id.
78-
search = openai.Engine(id="deployment-name").search(documents=["White House", "hospital", "school"], query ="the president")
79-
80-
# print the search
81-
print(search)
8276
```
8377

84-
Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, search and fine-tuning operations.
78+
Please note that for the moment, the Microsoft Azure endpoints can only be used for completion, embedding, and fine-tuning operations.
8579
For a detailed example on how to use fine-tuning and other operations using Azure endpoints, please check out the following Jupyter notebooks:
80+
* [Using Azure completions](https://github.com/openai/openai-cookbook/tree/main/examples/azure/completions.ipynb)
8681
* [Using Azure fine-tuning](https://github.com/openai/openai-cookbook/tree/main/examples/azure/finetuning.ipynb)
8782
* [Using Azure embeddings](https://github.com/openai/openai-cookbook/blob/main/examples/azure/embeddings.ipynb)
8883

8984
### Microsoft Azure Active Directory Authentication
9085

91-
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.
86+
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.
9287

9388

9489
```python
@@ -97,13 +92,13 @@ import openai
9792

9893
# Request credential
9994
default_credential = DefaultAzureCredential()
100-
token = default_credential.get_token("https://cognitiveservices.azure.com")
95+
token = default_credential.get_token("https://cognitiveservices.azure.com/.default")
10196

10297
# Setup parameters
10398
openai.api_type = "azure_ad"
10499
openai.api_key = token.token
105100
openai.api_base = "https://example-endpoint.openai.azure.com/"
106-
openai.api_version = "2022-03-01-preview"
101+
openai.api_version = "2022-12-01"
107102

108103
# ...
109104
```

openai/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
3535
api_type = os.environ.get("OPENAI_API_TYPE", "open_ai")
3636
api_version = (
37-
"2022-03-01-preview" if api_type in ("azure", "azure_ad", "azuread") else None
37+
"2022-12-01" if api_type in ("azure", "azure_ad", "azuread") else None
3838
)
3939
verify_ssl_certs = True # No effect. Certificates are always verified.
4040
proxy = None

0 commit comments

Comments
 (0)