news_verification / gpt_test.py
pmkhanh7890's picture
run pre-commit
38fd181
raw
history blame
1.04 kB
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)