Skip to content

Instantly share code, notes, and snippets.

@danielgross
Created February 11, 2023 17:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielgross/786bd07742176a6c6297a93c50a6434a to your computer and use it in GitHub Desktop.
Save danielgross/786bd07742176a6c6297a93c50a6434a to your computer and use it in GitHub Desktop.
Add as final cell to notebook for easy transition to OpenAI
# ~~~magictext~~~
# update FILENAME to your file name
!jupyter nbconvert --to script --output "/tmp/copy" FILENAME.ipynb
# Trim empty lines from /tmp/copy.py
!sed -i '' '/^$/d' /tmp/copy.py
# Trim lines that start with "# In["
!sed -i '' '/^# In\[/d' /tmp/copy.py
# Remove this very section, e.g. anything after "# ~~~magictext~~~"
!sed -i '' '/# ~~~magictext~~~/,$d' /tmp/copy.py
!cat /tmp/copy.py | pbcopy
# And then focus the Chrome window on the OpenAI tab
model_id = "text-davinci-003"
!osascript -e 'tell application "Google Chrome" to tell the active tab of its first window to set URL to "https://platform.openai.com/playground?model=%s"' % model_id
@akshayvkt
Copy link

went back to find this on twitter but couldn't find it, glad that I opened this when it was first tweeted (found it in my ~100 open tabs). Thanks for this!

Question - what's the reason for the switch to OpenAI playground once the .py file is ready?

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