forked from microsoft/generative-ai-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoai-app.py
More file actions
29 lines (22 loc) · 744 Bytes
/
aoai-app.py
File metadata and controls
29 lines (22 loc) · 744 Bytes
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
# pylint: disable=all
from openai import AzureOpenAI
import os
from dotenv import load_dotenv
# load environment variables from .env file
load_dotenv()
# configure Azure OpenAI service client
client = AzureOpenAI(
azure_endpoint = "https://nsf-openai-dev.openai.azure.com/",
api_key="",
api_version = "2023-10-01-preview"
)
deployment="nsf-gpt-4"
# add your completion code
prompt = "Complete the following: Once upon a time there was a"
messages = [{"role": "user", "content": prompt}]
# make completion
completion = client.chat.completions.create(model=deployment, messages=messages)
# print response
print(completion.choices[0].message.content)
# very unhappy _____.
# Once upon a time there was a very unhappy mermaid.