https://github.com/santiagobasulto/ipython-gpt Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} santiagobasulto / ipython-gpt Public * Notifications * Fork 5 * Star 176 176 stars 5 forks Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights santiagobasulto/ipython-gpt This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/s] Use Git or checkout with SVN using the web URL. [gh repo clone santia] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @santiagobasulto santiagobasulto Added link to Demo ... 7ae6d60 Apr 15, 2023 Added link to Demo 7ae6d60 Git stats * 6 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .gitignore Initial commit April 15, 2023 11:45 Demo.ipynb Better formatting April 15, 2023 16:12 README.md Added link to Demo April 15, 2023 11:30 ipython_gpt.py Switched back to print for shell April 15, 2023 16:28 poetry.lock Initial commit April 15, 2023 11:45 pyproject.toml Switched back to print for shell April 15, 2023 16:28 View code [ ] IPython ChatGPT extension Installation Setup ChatGPT API Agent's role (system message) and other chat parameters Setting global config Other methods Display available models Available models: Display usage and accepted parameters Alternative authentication README.md IPython ChatGPT extension This extension allows you to use ChatGPT directly from your Jupyter Notebook or IPython Shell (Demo). IPython GPT, a Jupyter/IPython interface for Chat GPT IPython GPT, a Jupyter/IPython interface for Chat GPT Important! This is a very early and raw version, I have a lot of things to improve regarding code quality and missing functionality. Installation !pip install ipython-gpt Then in your notebook or ipython shell: %load_ext ipython_gpt Setup You must first generate an API key at OpenAI (https:// platform.openai.com/account/api-keys) and set is an environment variable OPENAI_API_KEY. You can do it by modifying your .bashrc /.zshrc or starting jupyter with it: $ OPENAI_API_KEY=[YOUR-KEY] jupyter lab # ... $ OPENAI_API_KEY=[YOUR-KEY] ipython There are a few other ways to set the API KEY, but the envvar is the recommended one. ChatGPT API The command %%chat interfaces with ChatGPT. It accepts multiple parameters (see Usage). Here's an example: %%chat --max-tokens=25 What's the purpose of life? ... >>> CHAT RESPONSE Important by default, the %%chat command preserves the conversation to give the Agent some context, in the same way that ChatGPT works. You can "reset" its status passing the flag --reset-conversation. %%chat --reset-conversation How can I avoid pandas using scientific notation in outputs, and do it globally? ... ... >>> CHAT RESPONSE Agent's role (system message) and other chat parameters By default, the Chat is started with the role: "You're a python data science coding assistant". You can change that by passing something different in your first %%chat: %%chat --system-message="You're a R Data Science assistant" Your message... Once the conversation has started, you can't change the original message, as the context is preserved. To do so, you must reset the conversation: %%chat --system-message="You're a R Data Science assistant" --reset-conversation Your message... Setting global config You can change the defaults using the %chat_config line magic: %chat_config --system-message="You're an R data scientist coding assistant specialized in visualizations" --model "other model" --reset-conversation Invoke it without parameters to see the defaults set: %chat_config ... >>> ##### Conf set: * **Default model**: gpt-3.5-turbo * **Default system message**: You're a python data science coding assistant * **Chat history length**: 0 Other methods Display available models Usage: %chat_models [--all-models] %chat_models Available models: - gpt-3.5-turbo-0301 - gpt-3.5-turbo Display usage and accepted parameters %reload_ext ipython_gpt %chat_help ... usage: ipykernel_launcher.py [-h] [--openai-api-key OPENAI_API_KEY] [--reset-conversation] [--system-message SYSTEM_MESSAGE] [--no-system-message] [--model MODEL] [--temperature TEMPERATURE] [--max-tokens MAX_TOKENS] [--all-models] Alternative authentication Aside from setting the environment variable, you can also set OPENAI_API_KEY as a global variable in your notebook, or pass it directly as a parameter in any method ``--openai-api-key=YOUR-KEY`. These alternative methods are NOT recommended, as you might leak your API Key in the notebooks' history, stored in .ipynb_checkpoints. About No description, website, or topics provided. Resources Readme Stars 176 stars Watchers 4 watching Forks 5 forks Report repository Releases No releases published Packages 0 No packages published Languages * Jupyter Notebook 71.5% * Python 28.5% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.