You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/openai/how-to/migration.md
+112-3Lines changed: 112 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,13 @@ ms.author: mbullwin
7
7
ms.service: azure-ai-openai
8
8
ms.custom:
9
9
ms.topic: how-to
10
-
ms.date: 11/06/2023
10
+
ms.date: 11/10/2023
11
11
manager: nitinme
12
12
---
13
13
14
14
# Migrating to the OpenAI Python API library 1.x
15
15
16
-
OpenAI has just released a new version of the [OpenAI Python API library](https://github.com/openai/openai-python/). This guide is supplemental to [OpenAI's migration guide](https://github.com/openai/openai-python/discussions/631) and will help bring you up to speed on the changes specific to Azure OpenAI.
16
+
OpenAI has just released a new version of the [OpenAI Python API library](https://github.com/openai/openai-python/). This guide is supplemental to [OpenAI's migration guide](https://github.com/openai/openai-python/discussions/742) and will help bring you up to speed on the changes specific to Azure OpenAI.
17
17
18
18
## Updates
19
19
@@ -30,7 +30,7 @@ OpenAI has just released a new version of the [OpenAI Python API library](https:
30
30
31
31
- The latest release of the [OpenAI Python library](https://pypi.org/project/openai/) doesn't currently support DALL-E when used with Azure OpenAI. DALL-E with Azure OpenAI is still supported with `0.28.1`. For those who can't wait for native support for DALL-E and Azure OpenAI we're providing [two code examples](#dall-e-fix) which can be used as a workaround.
32
32
-`embeddings_utils.py` which was used to provide functionality like cosine similarity for semantic text search is [no longer part of the OpenAI Python API library](https://github.com/openai/openai-python/issues/676).
33
-
- You should also check the active [GitHub Issues](https://github.com/openai/openai-python/issues/703) for the OpenAI Python library.
33
+
- You should also check the active [GitHub Issues](https://github.com/openai/openai-python/issues/) for the OpenAI Python library.
For the full configuration steps that are required to make these code examples work, please consult the [use your data quickstart](../use-your-data-quickstart.md).
258
+
# [OpenAI Python 0.28.1](#tab/python)
259
+
260
+
```python
261
+
import os
262
+
import openai
263
+
import dotenv
264
+
import requests
265
+
266
+
dotenv.load_dotenv()
267
+
268
+
openai.api_base = os.environ.get("AOAIEndpoint")
269
+
openai.api_version ="2023-08-01-preview"
270
+
openai.api_type ='azure'
271
+
openai.api_key = os.environ.get("AOAIKey")
272
+
273
+
defsetup_byod(deployment_id: str) -> None:
274
+
"""Sets up the OpenAI Python SDK to use your own data for the chat endpoint.
275
+
276
+
:param deployment_id: The deployment ID for the model to use with your own data.
277
+
278
+
To remove this configuration, simply set openai.requestssession to None.
Copy file name to clipboardExpand all lines: articles/ai-services/openai/includes/use-your-data-python.md
+78-19Lines changed: 78 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
services: cognitive-services
3
3
manager: nitinme
4
-
author: travisw
5
-
ms.author: travisw
4
+
author: mrbullwinkle #travisw
5
+
ms.author: mbullwin #travisw
6
6
ms.service: azure-ai-openai
7
7
ms.topic: include
8
-
ms.date: 08/29/2023
8
+
ms.date: 11/09/2023
9
9
---
10
10
11
11
[!INCLUDE [Set up required variables](./use-your-data-common-variables.md)]
@@ -14,22 +14,35 @@ ms.date: 08/29/2023
14
14
15
15
1. Create a new folder named *openai-python* for your project and a new Python code file named *main.py*. Change into that directory:
16
16
17
-
```cmd
18
-
mkdir openai-python
19
-
cd openai-python
20
-
```
17
+
```cmd
18
+
mkdir openai-python
19
+
cd openai-python
20
+
```
21
21
22
-
1. Install the following Python Libraries:
22
+
2. Install the following Python Libraries:
23
23
24
-
```cmd
25
-
pip install openai==0.28.1
26
-
pip install python-dotenv
27
-
```
24
+
# [OpenAI Python 0.28.1](#tab/python)
25
+
26
+
```console
27
+
pip install openai==0.28.1
28
+
pip install python-dotenv
29
+
```
28
30
31
+
# [OpenAI Python 1.x](#tab/python-new)
32
+
33
+
```console
34
+
pip install openai
35
+
pip install python-dotenv
36
+
```
37
+
38
+
---
39
+
29
40
## Create the Python app
30
41
31
42
1. From the project directory, open the *main.py* file and add the following code:
32
43
44
+
# [OpenAI Python 0.28.1](#tab/python)
45
+
33
46
```python
34
47
import os
35
48
import openai
@@ -89,16 +102,62 @@ ms.date: 08/29/2023
89
102
print(completion)
90
103
```
91
104
92
-
> [!IMPORTANT]
93
-
> For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../key-vault/general/overview.md). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
"content": "How is Azure machine learning different than Azure OpenAI?",
130
+
},
131
+
],
132
+
extra_body={
133
+
"dataSources": [
134
+
{
135
+
"type": "AzureCognitiveSearch",
136
+
"parameters": {
137
+
"endpoint": os.environ["SearchEndpoint"],
138
+
"key": os.environ["SearchKey"],
139
+
"indexName": os.environ["SearchIndex"]
140
+
}
141
+
}
142
+
]
143
+
}
144
+
)
145
+
146
+
print(completion.model_dump_json(indent=2))
147
+
```
94
148
95
-
1. Execute the following command:
149
+
---
96
150
97
-
```cmd
98
-
python main.py
99
-
```
151
+
> [!IMPORTANT]
152
+
> For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../key-vault/general/overview.md). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
153
+
154
+
2. Execute the following command:
155
+
156
+
```cmd
157
+
python main.py
158
+
```
100
159
101
-
The application prints the response in a JSON format suitable for use in many scenarios. It includes both answers to your query and citations from your uploaded files.
160
+
The application prints the response in a JSON format suitable for use in many scenarios. It includes both answers to your query and citations from your uploaded files.
102
161
103
162
> [!div class="nextstepaction"]
104
163
> [I ran into an issue when running the code samples.](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=dotnet&Pillar=AOAI&Product=ownData&Page=quickstart&Section=Create-dotnet-application)
0 commit comments