Hi there! I’ve created a new Python script that uses the OpenAI API to interact with ChatGPT. Unfortunately, I’ve reached my API request limit, so I’ll have to wait until tomorrow to continue testing it.
import openai
openai.api_key = "You-Want-My-API?LOL"
def chat_with_gpt(prompt):
response = openai.Completion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": prompt}],
)
return response.choices[0].message.content.strip()
if __name__ == "__main__":
while True:
user_input = input("You: ")
if user_input.lower() in ["exit", "quit", "bye", "911"]:
break
response = chat_with_gpt(user_input)
print("Chatbot:", response)