chatgpt.py 565 B

123456789101112131415161718192021222324252627
  1. import openai
  2. import os
  3. # Set API key
  4. openai.api_key = os.getenv("OPENAI_API_KEY")
  5. # Define the prompt you want to send to ChatGPT
  6. user_input = input("Please enter some text: ")
  7. print("You entered: " + user_input)
  8. prompt = user_input
  9. print("Prompt to be sent to ChatGPT: " + prompt)
  10. # Send the prompt to ChatGPT and receive a response
  11. # response = openai.Completion.create(
  12. # engine="davinci",
  13. # prompt=prompt,
  14. # max_tokens=60,
  15. # n=1,
  16. # stop=None,
  17. # temperature=0.7,
  18. # )
  19. # Print the response
  20. # print(response.choices[0].text.strip())