Skip to content

Instantly share code, notes, and snippets.

@scaery
Created February 11, 2023 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scaery/79c3fc1d8765cd552c6beece9d57322c to your computer and use it in GitHub Desktop.
Save scaery/79c3fc1d8765cd552c6beece9d57322c to your computer and use it in GitHub Desktop.
ChatGPT Terminal - Hacking with AI knowledge
#!/usr/bin/env python3
import openai
import json
import io
openai.api_key = "YOUR-OPENAI-API-KEY"
question = input("\nHacking with AI knowledge... just ask a question on ChatGPT:\n\n")
response = openai.Completion.create(
model="text-davinci-003",
prompt=question,
temperature=1.0,
max_tokens=1000,
top_p=1.0,
frequency_penalty=0.0,
presence_penalty=0.0
)
json_object = json.loads(str(response))
answer = str(json_object['choices'][0]['text'])
f = io.open("chatgpt.log", "a", encoding="UTF-8")
print("\n\n# START #################################################\nYou:\n\n%s ???\n" % question, file=f)
print("ChatGPT:\n\n %s" % answer, file=f)
print("\n# END ###################################################\n", file=f)
f.close()
print(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment