Selaa lähdekoodia

Add ChatGPT test

Michael Tang 2 vuotta sitten
vanhempi
commit
22f94ad4b6
1 muutettua tiedostoa jossa 27 lisäystä ja 0 poistoa
  1. 27 0
      chatgpt.py

+ 27 - 0
chatgpt.py

@@ -0,0 +1,27 @@
+import openai
+import os
+
+# Set API key
+openai.api_key = os.getenv("OPENAI_API_KEY")
+
+# Define the prompt you want to send to ChatGPT
+
+user_input = input("Please enter some text: ")
+print("You entered: " + user_input)
+prompt = user_input
+print("Prompt to be sent to ChatGPT: " + prompt)
+
+
+
+# Send the prompt to ChatGPT and receive a response
+# response = openai.Completion.create(
+#     engine="davinci",
+#     prompt=prompt, 
+#     max_tokens=60,
+#     n=1,
+#     stop=None,
+#     temperature=0.7,
+# )
+
+# Print the response
+# print(response.choices[0].text.strip())