Skip to content

Instantly share code, notes, and snippets.

@Tknott95
Created February 23, 2023 05:38
Show Gist options
  • Save Tknott95/8c50c9c56007d09ceffd4c43580e5709 to your computer and use it in GitHub Desktop.
Save Tknott95/8c50c9c56007d09ceffd4c43580e5709 to your computer and use it in GitHub Desktop.
chatGPT Python CLI app. Use pyinstaller or cython to compile a binary if wanting to run with "gpt".
import openai
openai.api_key = "<YOUR-API-KEY-HERE>"
def makeGPT(prompt_using):
completion = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt_using,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
return completion
while(True):
choice = input("Ask GPT: ")
response = makeGPT(choice).choices[0].text
print(response, "\n\n")
@Tknott95
Copy link
Author

Tknott95 commented Feb 23, 2023

I compiled mine pyinstaller gpt.py --onefile ; mv ./dist/gpt ~/.local/bin/ ----- then I just call gpt to use it from anywhere. If you do not use a ~/.local/bin in your path then move it to /usr/bin if not wanting ~/.local/bin in your path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment