{"id":13643112,"url":"https://github.com/santiagobasulto/ipython-gpt","last_synced_at":"2025-05-16T19:05:53.038Z","repository":{"id":153118400,"uuid":"628228019","full_name":"santiagobasulto/ipython-gpt","owner":"santiagobasulto","description":"An ChatGPT integration for Jupyter Notebooks and the IPython Shell","archived":false,"fork":false,"pushed_at":"2023-08-02T13:02:17.000Z","size":44,"stargazers_count":593,"open_issues_count":5,"forks_count":40,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-14T17:12:35.214Z","etag":null,"topics":["ipython","ipython-magic","jupyter","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santiagobasulto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-15T09:47:05.000Z","updated_at":"2025-05-10T13:09:23.000Z","dependencies_parsed_at":"2024-07-29T10:43:17.428Z","dependency_job_id":null,"html_url":"https://github.com/santiagobasulto/ipython-gpt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santiagobasulto%2Fipython-gpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santiagobasulto%2Fipython-gpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santiagobasulto%2Fipython-gpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santiagobasulto%2Fipython-gpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santiagobasulto","download_url":"https://codeload.github.com/santiagobasulto/ipython-gpt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254592368,"owners_count":22097011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ipython","ipython-magic","jupyter","python"],"created_at":"2024-08-02T01:01:41.892Z","updated_at":"2025-05-16T19:05:53.016Z","avatar_url":"https://github.com/santiagobasulto.png","language":"Python","funding_links":[],"categories":["Browser-extensions","Python","Chat UIs","SDK, Libraries, Frameworks"],"sub_categories":["Python"],"readme":"# IPython ChatGPT extension\n\n[![Black badge](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![prettier badge](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier\u0026logoColor=white)](https://github.com/prettier/prettier)\n[![pre-commit](https://img.shields.io/badge/pre--commit-active-yellow?logo=pre-commit\u0026logoColor=white)](https://pre-commit.com/)\n[![test](https://img.shields.io/github/actions/workflow/status/santiagobasulto/ipython-gpt/test.yaml?logo=github\u0026logoColor=white)](https://github.com/santiagobasulto/ipython-gpt/actions/workflows/test.yaml)\n\nThis (standalone, no external dependencies required) extension allows you to use ChatGPT directly from your Jupyter Notebook or IPython Shell ([Demo](https://github.com/santiagobasulto/ipython-gpt/blob/master/Demo.ipynb)).\n\n\u003cimg width=\"900\" alt=\"IPython GPT, a Jupyter/IPython interface for Chat GPT\" src=\"https://user-images.githubusercontent.com/872296/232230454-44529ea4-920e-4294-9d61-550771a4a95e.png\"\u003e\n\n\u003cimg width=\"900\" alt=\"IPython GPT, a Jupyter/IPython interface for Chat GPT\" src=\"https://user-images.githubusercontent.com/872296/232230492-9bc50342-9d78-4adb-8168-2f94fcbc3b73.png\"\u003e\n\n**Important!** This is a very early and raw version, I have a lot of things to improve regarding code quality and missing functionality. Check [this issue](https://github.com/santiagobasulto/ipython-gpt/issues/4) for a rough \"roadmap\".\n\n## Installation\n\n```python\n!pip install ipython-gpt\n```\n\nThen in your notebook or ipython shell:\n\n```ipython\n%load_ext ipython_gpt\n```\n\n## Setup\n\nYou 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:\n\n```bash\n$ OPENAI_API_KEY=[YOUR-KEY] jupyter lab\n# ...\n$ OPENAI_API_KEY=[YOUR-KEY] ipython\n```\n\nIf you're working on Google Colab, you can use the `%env` magic method (keep in mind that if you don't delete the cell, your key will be visible):\n\n```python\n%env OPENAI_API_KEY=sk-W8b0... your key ...\n```\n\nThere are a few other ways to set the API KEY, but the envvar is the recommended one.\n\n## ChatGPT API\n\nThe command `%%chat` interfaces with ChatGPT. It accepts multiple parameters (see Usage). Here's an example:\n\n```python\n%%chat --max-tokens=25\n\nWhat's the purpose of life?\n...\n\n\u003e\u003e\u003e CHAT RESPONSE\n```\n\n**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`.\n\n```python\n%%chat --reset-conversation\n\nHow can I avoid pandas using scientific notation in outputs, and do it globally?\n...\n...\n\u003e\u003e\u003e CHAT RESPONSE\n```\n\n## Agent's role (system message) and other chat parameters\n\nBy 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`:\n\n```ipython\n%%chat --system-message=\"You're a R Data Science assistant\"\n\nYour message...\n```\n\nOnce the conversation has started, you can't change the original message, as the context is preserved. To do so, you must reset the conversation:\n\n```ipython\n%%chat --system-message=\"You're a R Data Science assistant\" --reset-conversation\n\nYour message...\n```\n\n## Setting global config\n\nYou can change the defaults using the `%chat_config` line magic:\n\n```ipython\n%chat_config --system-message=\"You're an R data scientist coding assistant specialized in visualizations\" --model \"other model\" --reset-conversation\n```\n\nInvoke it without parameters to see the defaults set:\n\n```python\n%chat_config\n...\n\n\u003e\u003e\u003e\n##### Conf set:\n\n* **Default model**: gpt-3.5-turbo\n* **Default system message**: You're a python data science coding assistant\n* **Chat history length**: 0\n```\n\n## Other methods\n\n#### Display available models\n\nUsage:\n\n```bash\n%chat_models [--all-models]\n```\n\n```python\n%chat_models\n```\n\n##### Available models:\n\n    - gpt-3.5-turbo-0301\n    - gpt-3.5-turbo\n\n#### Display usage and accepted parameters\n\n```python\n%reload_ext ipython_gpt\n%chat_help\n...\n\n\n    usage: ipykernel_launcher.py [-h] [--openai-api-key OPENAI_API_KEY]\n                                 [--reset-conversation]\n                                 [--system-message SYSTEM_MESSAGE]\n                                 [--no-system-message] [--model MODEL]\n                                 [--temperature TEMPERATURE]\n                                 [--max-tokens MAX_TOKENS] [--all-models]\n\n```\n\n## Alternative authentication\n\nAside 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`.\n\nThese alternative methods are NOT recommended, as you might leak your API Key in the notebooks' history, stored in `.ipynb_checkpoints`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantiagobasulto%2Fipython-gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantiagobasulto%2Fipython-gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantiagobasulto%2Fipython-gpt/lists"}