Spaces:
Sleeping
Sleeping
File size: 648 Bytes
2bf5def c6e1096 2bf5def c6e1096 2bf5def |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from openai import OpenAI
import os
from dotenv import load_dotenv
load_dotenv()
OPENAI_API_KEY = os.environ['OPENAI_API_KEY']
client = OpenAI()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
# model="gpt-4-turbo",
# model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
)
print('')
print(response)
print('')
print(response.choices[0].message.content) |