Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Use AI to explain code #2517

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

✨ Use AI to explain code #2517

wants to merge 1 commit into from

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Mar 30, 2023

Schermopname.2023-03-30.om.14.35.21.mov

@github-actions
Copy link
Contributor

github-actions bot commented Mar 30, 2023

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="openai-explain-this-code")
julia> using Pluto

You need an OpenAI API key to run this PR unfortunately. Generate one, and then:

julia> Pluto.run(_experimental_openai_key="your_key_here")

"Authorization": `Bearer ${key}`,
},
body: JSON.stringify({
model: "text-davinci-003",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use gpt-3.5-turbo then that's cheaper and more accurate. The API call is slightly different because it's via the chat endpoint, but it should work for now and also for the people who have GPT-4 access. Also, maybe allow people to set the endpoint because things are moving fast in OpenAI-land?

Comment on lines +847 to +849
prompt: `\`\`\`\n${code}\n\`\`\`\n\n${
code.length > 100 ? "Summarize the the intent of" : "Explain"
} this Julia code in a consise way. Use Markdown to highlight important concepts:\n1.`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can now officially add prompt engineer to your resume 🚀

@@ -46,6 +46,7 @@ const PORT_HINT_DEFAULT = 1234
const LAUNCH_BROWSER_DEFAULT = true
const DISMISS_UPDATE_NOTIFICATION_DEFAULT = false
const SHOW_FILE_SYSTEM_DEFAULT = true
const _EXPERIMENTAL_OPENAI_KEY_DEFAULT = nothing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the secret should be inserted in the browser and be kept in the browser storage? That saves the hassle with having to make the secret key available inside the Julia process and might therefore be more secure?

@fonsp fonsp added documentation enhancement New feature or request frontend Concerning the HTML editor Live Docs The Live Docs panel on the bottom right of the editor user request Requested using the feedback form inside Pluto notebooks labels Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation enhancement New feature or request frontend Concerning the HTML editor Live Docs The Live Docs panel on the bottom right of the editor user request Requested using the feedback form inside Pluto notebooks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants