Skip to content

Commit 2ecf6bc

Browse files
committed
update
1 parent 16f6163 commit 2ecf6bc

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

articles/ai-services/openai/how-to/migration.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,21 @@ Additional examples including how to handle semantic text search without `embedd
211211
OpenAI doesn't support calling asynchronous methods in the module-level client, instead you should instantiate an async client.
212212

213213
```python
214+
import os
215+
import asyncio
214216
from openai import AsyncAzureOpenAI
215217

216-
client = AsyncAzureOpenAI(
217-
api_key = os.getenv("AZURE_OPENAI_KEY"),
218-
api_version = "2023-10-01-preview",
219-
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
220-
)
221-
response = await client.chat.completions.create(model="gpt-35-turbo", messages=[{"role": "user", "content": "Hello world"}])
218+
async def main():
219+
client = AsyncAzureOpenAI(
220+
api_key = os.getenv("AZURE_OPENAI_KEY"),
221+
api_version = "2023-10-01-preview",
222+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
223+
)
224+
response = await client.chat.completions.create(model="gpt-35-turbo", messages=[{"role": "user", "content": "Hello world"}])
222225

223-
print(response.model_dump_json(indent=2))
226+
print(response.model_dump_json(indent=2))
227+
228+
asyncio.run(main())
224229
```
225230

226231
## Authentication

0 commit comments

Comments
 (0)