Last active
May 23, 2022 09:40
-
-
Save stuhlmueller/099b545e1718d7086cb180873601b7b9 to your computer and use it in GitHub Desktop.
OpenAI Codex in Emacs
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
(defun codex (&optional b e) | |
(interactive "r") | |
(shell-command-on-region b e "codex.py" nil nil)) |
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
#!/usr/bin/env python | |
# Make this file executable (chmod +x codex.py) | |
# and put it somewhere in your PATH | |
import sys | |
import openai | |
openai.api_key = "sk-[YOUR API KEY HERE]" | |
prompt = "".join(sys.stdin.readlines()) | |
completion = openai.Completion.create( | |
engine="davinci-codex", | |
prompt=prompt, | |
max_tokens=100, | |
temperature=0, | |
frequency_penalty=0.2 | |
) | |
print(completion.choices[0].text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How does it work? Will codex give working code completions? Can you also ask it questions in human languages and it will answer with code using your script?