forked from openai/openai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure_ad.py
More file actions
executable file
·49 lines (35 loc) · 1.11 KB
/
azure_ad.py
File metadata and controls
executable file
·49 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import asyncio
from aimlapi import AzureAIMLAPI, AsyncAzureAIMLAPI
scopes = "https://cognitiveservices.azure.com/.default"
api_version = "2023-07-01-preview" # ignore this value; any supported version will work
deployment_name = "gpt-4o" # set the model name (e.g., "gpt-4o", "gpt-3.5-turbo", etc.)
def sync_main() -> None:
client = AzureAIMLAPI(
api_version=api_version,
)
completion = client.chat.completions.create(
model=deployment_name,
messages=[
{
"role": "user",
"content": "How do I output all files in a directory using Python?",
}
],
)
print(completion.to_json())
async def async_main() -> None:
client = AsyncAzureAIMLAPI(
api_version=api_version,
)
completion = await client.chat.completions.create(
model=deployment_name,
messages=[
{
"role": "user",
"content": "How do I output all files in a directory using Python?",
}
],
)
print(completion.to_json())
sync_main()
asyncio.run(async_main())