You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importopenai# Set your OpenAI API keyopenai.api_key="your-openai-api-key"# Define the text you want to analyze or interact withtext="I am very happy today!"# Make a request to the OpenAI GPT-3.5 APIresponse=openai.ChatCompletion.create(
model="gpt-3.5-turbo-0125",
messages=[
{"role": "system", "content": "Analyze the sentiment of the following text:"},
{"role": "user", "content": text}
]
)
# Extract the response textresponse_text=response['choices'][0]['message']['content'].strip()
print("Response from GPT-3.5:", response_text)