Created
April 28, 2024 03:56
-
-
Save abhi-io/56f084d11201469a6973b0205b62cc0f to your computer and use it in GitHub Desktop.
ChatGPT test file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from openai import OpenAI | |
client = OpenAI( | |
api_key = os.getenv("OPENAI_API_KEY"), | |
) | |
completion = client.chat.completions.create( # Change the method | |
model = "gpt-3.5-turbo", | |
messages = [ # Change the prompt parameter to messages parameter | |
{"role": "system", "content": "You are a helpful assistant."}, | |
{"role": "user", "content": "Hello!"}, | |
] | |
) | |
print(completion.choices[0].message.content) # Change message content retrieval | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment