File size: 1,043 Bytes
504f37b
38fd181
504f37b
 
38fd181
504f37b
38fd181
 
 
504f37b
 
38fd181
 
 
504f37b
38fd181
 
504f37b
 
 
38fd181
 
 
504f37b
38fd181
504f37b
38fd181
504f37b
 
 
 
 
 
 
38fd181
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
import os

from dotenv import load_dotenv
from openai import AzureOpenAI

load_dotenv()
AZURE_OPENAI_API_KEY = os.getenv("AZURE_OPENAI_API_KEY")
AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT")
AZURE_OPENAI_API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION")

azure_client = AzureOpenAI(
    azure_endpoint="https://quoc-nguyen.openai.azure.com/",
    api_key=AZURE_OPENAI_API_KEY,
    api_version="2024-05-01-preview",
)

deplopment_name = "o1-mini"  # or "gpt-4o"
TEXT_PROMPT = """
replace Ukraine with Denmark:

"Sir Keir Starmer has pledged to put Ukraine in the "strongest
possible position" on a trip to Kyiv where he signed a
"landmark" 100-year pact with the war-stricken country.
"""

response = azure_client.chat.completions.create(
    model=deplopment_name,  # model = "deployment_name".
    messages=[
        # {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": TEXT_PROMPT},
    ],
    # max_tokens=512,
    # temperature=0,
)
print(response.choices[0].message.content)