Jupyter Notebook ChatCompletion is VSCode extension that brings the power of OpenAI’s ChatCompletion API to your Jupyter Notebooks!
With this extension, you can generate completions for your code cells, effectively using Jupyter Notebooks like you would use the OpenAI Playground. The notebook content is sent along the notebook cells, as well as the outputs and errors/warnings for python code cells that have been executed.
When you try to send content larger than the model max token size, a dialogue with token reduction strategy appears.
ctrl+shift+enter
): Generate completions using the current cell and all cells above it. You can simply karate-chop the center keys (right shift, right ctrl and main enter key) 🥋 or use the corresponding action from the cell menu.ctrl+shift+pagedown
): Generate completions using only the current cell. You can also use the corresponding action from the cell menutop_p
parameter for nucleus sampling, where the model considers the results of the tokens with top_p probability mass (e.g., 0.1 means only the tokens comprising the top 10% probability mass are considered).max_tokens
parameter to limit the maximum number of tokens generated in the chat completion.presence_penalty
parameter to penalize new tokens based on whether they appear in the text so far, influencing the model’s likelihood to talk about new topics.frequency_penalty
parameter to penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.logit_bias
parameter to modify the likelihood of specified tokens appearing in the completion by providing a JSON object that maps tokens to their associated bias values.user
parameter to provide a unique identifier representing your end-user, which can help OpenAI monitor and detect abuse.
You can expect the same level of flexibility as with the OpenAI Playground, but combined with the powerful features of Jupyter notebooks.
This extension will only include the following system message by default:
“Format your answer as markdown. If you include a markdown code block, specify the language.
”
This default system message is not necessary for the extension to function but increases the chance that the extension will detect python code as code cell instead of generic code-block (unknown language). You can set a notebook to the role “System” to override this and define your own system message.
This extension doesn’t (and will never) collect any information.
The release version’s code can be inspected at the main branch in GitHub
The pre-release version’s code can be inspected at the edge branch in GitHub
Please note that the use of the OpenAPI API is still subject to OpenAI API data usage policies.
If you encounter any issues or have questions, please head over to GitHub Issues page and create a new issue. I’ll be happy to help! Feature Request are also welcome!