Created
February 23, 2023 05:38
-
-
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".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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