jupyter-ai-agents


Namejupyter-ai-agents JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2025-01-22 06:50:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseBSD 3-Clause License Copyright (c) 2024, Datalayer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- This library reuse part of Jupyter Server code licensed under BSD 3-Clause License Source: https://github.com/jupyter-server/jupyter_server/blame/v2.12.0/jupyter_server/services/kernels/connection/base.py This library reuse part of traitlets code licensed under BSD 3-Clause License Source: https://github.com/ipython/traitlets/blob/v5.14.3/traitlets/log.py
keywords jupyter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--
  ~ Copyright (c) 2023-2024 Datalayer, Inc.
  ~
  ~ BSD 3-Clause License
-->

[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)

[![Become a Sponsor](https://img.shields.io/static/v1?label=Become%20a%20Sponsor&message=%E2%9D%A4&logo=GitHub&style=flat&color=1ABC9C)](https://github.com/sponsors/datalayer)

# 🪐 ✨ Jupyter AI Agents

[![Github Actions Status](https://github.com/datalayer/jupyter-ai-agents/workflows/Build/badge.svg)](https://github.com/datalayer/jupyter-ai-agents/actions/workflows/build.yml)
[![PyPI - Version](https://img.shields.io/pypi/v/jupyter-ai-agents)](https://pypi.org/project/jupyter-ai-agents)

*The Jupyter AI Agents are equipped with tools like 'execute', 'insert_cell', and more, to transform your Jupyter Notebooks into an intelligent, interactive workspace!*

![Jupyter AI Agents](https://assets.datalayer.tech/jupyter-ai-agents/ai-agents-prompt-demo-terminal.gif)

```
Jupyter AI Agents <-----------> JupyterLab
    |
    |   (RTC Real Time Collaboration)
    |
JNC + JKC

- JNC https://github.com/datalayer/jupyter-nbmodel-client
- JKC https://github.com/datalayer/jupyter-kernel-client
```

Jupyter AI Agents empowers **AI** models to **interact** with and **modify Jupyter Notebooks**. The agent is equipped with tools such as adding code cells, inserting markdown cells, executing code, enabling it to modify the notebook comprehensively based on user instructions or by reacting to notebook and kernel events.

This agent is **innovative** as it is designed to **operate on the entire notebook**, not just at the cell level, enabling more comprehensive and seamless modifications.

This powerful functionality is made possible through [jupyter-nbmodel-client](https://github.com/datalayer/jupyter-nbmodel-client) and [jupyter-kernel-client](https://github.com/datalayer/jupyter-kernel-client), enabling interaction with Jupyter Notebooks and Kernels.

[LangChain Agent Framework](https://python.langchain.com/v0.1/docs/modules/agents/how_to/custom_agent/) is used to manage the interactions between the AI model and the tools.

> [!WARNING] 
>
> jupyter-nbmodel-client and jupyter-kernel-client are experimental and under active development.
> Unexpected behavior may occur, due to potential issue generated by 3rd party projects.

## Usage

This library is documented on https://jupyter-ai-agents.datalayer.tech.

We put here a quick example for a Out-Kernel Stateless Agent helping your JupyterLab session.

To install Jupyter AI Agents, run the following command.

```bash
pip install jupyter_ai_agents
```

Or clone this repository and install it from source.

```bash
git clone https://github.com/datalayer/jupyter-ai-agents
cd jupyter-ai-agents
pip install -e .
```

The Jupyter AI Agents can directly interact with JupyterLab. The modifications made by the Jupyter AI Agents can be seen in real-time thanks to [Jupyter Real Time Collaboration](https://jupyterlab.readthedocs.io/en/stable/user/rtc.html). Make sure you have JupyterLab installed with the Collaboration extension.

```bash
pip install jupyterlab jupyter-collaboration ipykernel
```

Start JupyterLab, setting a `port` and a `token` to be reused by the agent, and create a notebook `test.ipynb`.

```bash
jupyter lab --port 8888 --IdentityProvider.token MY_TOKEN
```

Read the [Azure Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai) to get the needed credentials and make sure you define them in the following `.env` file.

```bash
cat << EOF >>.env
OPENAI_API_VERSION="..."
AZURE_OPENAI_ENDPOINT="..."
AZURE_OPENAI_API_KEY="..."
EOF
```

To use the Jupyter AI Agents, an easy way is to launch a CLI (update the Azure deployment name based on your setup).

```bash
# Prompt agent example.
jupyter-ai-agents prompt \
  --url http://localhost:8888 \
  --token MY_TOKEN \
  --azure-ai-deployment-name gpt-40-mini \
  --path test.ipynb \
  --input "Create a matplotlib example"
```

![Jupyter AI Agents](https://assets.datalayer.tech/jupyter-ai-agents/ai-agents-prompt-demo-terminal.gif)

```bash
# Explain Error agent example.
jupyter-ai-agents explain-error \
  --url http://localhost:8888 \
  --token MY_TOKEN \
  --azure-ai-deployment-name gpt-40-mini \
  --path test.ipynb
```

![Jupyter AI Agents](https://assets.datalayer.tech/jupyter-ai-agents/ai-agents-explainerror-demo-terminal.gif)

## Uninstall

To uninstall the agent, execute.

```bash
pip uninstall jupyter_ai_agents
```

## Contributing

### Development install

```bash
# Clone the repo to your local environment
# Change directory to the jupyter_ai_agents directory
# Install package in development mode - will automatically enable
# The server extension.
pip install -e ".[test,lint,typing]"
```

### Running Tests

Install dependencies:

```bash
pip install -e ".[test]"
```

To run the python tests, use:

```bash
pytest
```

### Development uninstall

```bash
pip uninstall jupyter_ai_agents
```

### Packaging the library

See [RELEASE](RELEASE.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jupyter-ai-agents",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Jupyter",
    "author": null,
    "author_email": "Datalayer <info@datalayer.io>",
    "download_url": null,
    "platform": null,
    "description": "<!--\n  ~ Copyright (c) 2023-2024 Datalayer, Inc.\n  ~\n  ~ BSD 3-Clause License\n-->\n\n[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)\n\n[![Become a Sponsor](https://img.shields.io/static/v1?label=Become%20a%20Sponsor&message=%E2%9D%A4&logo=GitHub&style=flat&color=1ABC9C)](https://github.com/sponsors/datalayer)\n\n# \ud83e\ude90 \u2728 Jupyter AI Agents\n\n[![Github Actions Status](https://github.com/datalayer/jupyter-ai-agents/workflows/Build/badge.svg)](https://github.com/datalayer/jupyter-ai-agents/actions/workflows/build.yml)\n[![PyPI - Version](https://img.shields.io/pypi/v/jupyter-ai-agents)](https://pypi.org/project/jupyter-ai-agents)\n\n*The Jupyter AI Agents are equipped with tools like 'execute', 'insert_cell', and more, to transform your Jupyter Notebooks into an intelligent, interactive workspace!*\n\n![Jupyter AI Agents](https://assets.datalayer.tech/jupyter-ai-agents/ai-agents-prompt-demo-terminal.gif)\n\n```\nJupyter AI Agents <-----------> JupyterLab\n    |\n    |   (RTC Real Time Collaboration)\n    |\nJNC + JKC\n\n- JNC https://github.com/datalayer/jupyter-nbmodel-client\n- JKC https://github.com/datalayer/jupyter-kernel-client\n```\n\nJupyter AI Agents empowers **AI** models to **interact** with and **modify Jupyter Notebooks**. The agent is equipped with tools such as adding code cells, inserting markdown cells, executing code, enabling it to modify the notebook comprehensively based on user instructions or by reacting to notebook and kernel events.\n\nThis agent is **innovative** as it is designed to **operate on the entire notebook**, not just at the cell level, enabling more comprehensive and seamless modifications.\n\nThis powerful functionality is made possible through [jupyter-nbmodel-client](https://github.com/datalayer/jupyter-nbmodel-client) and [jupyter-kernel-client](https://github.com/datalayer/jupyter-kernel-client), enabling interaction with Jupyter Notebooks and Kernels.\n\n[LangChain Agent Framework](https://python.langchain.com/v0.1/docs/modules/agents/how_to/custom_agent/) is used to manage the interactions between the AI model and the tools.\n\n> [!WARNING] \n>\n> jupyter-nbmodel-client and jupyter-kernel-client are experimental and under active development.\n> Unexpected behavior may occur, due to potential issue generated by 3rd party projects.\n\n## Usage\n\nThis library is documented on https://jupyter-ai-agents.datalayer.tech.\n\nWe put here a quick example for a Out-Kernel Stateless Agent helping your JupyterLab session.\n\nTo install Jupyter AI Agents, run the following command.\n\n```bash\npip install jupyter_ai_agents\n```\n\nOr clone this repository and install it from source.\n\n```bash\ngit clone https://github.com/datalayer/jupyter-ai-agents\ncd jupyter-ai-agents\npip install -e .\n```\n\nThe Jupyter AI Agents can directly interact with JupyterLab. The modifications made by the Jupyter AI Agents can be seen in real-time thanks to [Jupyter Real Time Collaboration](https://jupyterlab.readthedocs.io/en/stable/user/rtc.html). Make sure you have JupyterLab installed with the Collaboration extension.\n\n```bash\npip install jupyterlab jupyter-collaboration ipykernel\n```\n\nStart JupyterLab, setting a `port` and a `token` to be reused by the agent, and create a notebook `test.ipynb`.\n\n```bash\njupyter lab --port 8888 --IdentityProvider.token MY_TOKEN\n```\n\nRead the [Azure Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai) to get the needed credentials and make sure you define them in the following `.env` file.\n\n```bash\ncat << EOF >>.env\nOPENAI_API_VERSION=\"...\"\nAZURE_OPENAI_ENDPOINT=\"...\"\nAZURE_OPENAI_API_KEY=\"...\"\nEOF\n```\n\nTo use the Jupyter AI Agents, an easy way is to launch a CLI (update the Azure deployment name based on your setup).\n\n```bash\n# Prompt agent example.\njupyter-ai-agents prompt \\\n  --url http://localhost:8888 \\\n  --token MY_TOKEN \\\n  --azure-ai-deployment-name gpt-40-mini \\\n  --path test.ipynb \\\n  --input \"Create a matplotlib example\"\n```\n\n![Jupyter AI Agents](https://assets.datalayer.tech/jupyter-ai-agents/ai-agents-prompt-demo-terminal.gif)\n\n```bash\n# Explain Error agent example.\njupyter-ai-agents explain-error \\\n  --url http://localhost:8888 \\\n  --token MY_TOKEN \\\n  --azure-ai-deployment-name gpt-40-mini \\\n  --path test.ipynb\n```\n\n![Jupyter AI Agents](https://assets.datalayer.tech/jupyter-ai-agents/ai-agents-explainerror-demo-terminal.gif)\n\n## Uninstall\n\nTo uninstall the agent, execute.\n\n```bash\npip uninstall jupyter_ai_agents\n```\n\n## Contributing\n\n### Development install\n\n```bash\n# Clone the repo to your local environment\n# Change directory to the jupyter_ai_agents directory\n# Install package in development mode - will automatically enable\n# The server extension.\npip install -e \".[test,lint,typing]\"\n```\n\n### Running Tests\n\nInstall dependencies:\n\n```bash\npip install -e \".[test]\"\n```\n\nTo run the python tests, use:\n\n```bash\npytest\n```\n\n### Development uninstall\n\n```bash\npip uninstall jupyter_ai_agents\n```\n\n### Packaging the library\n\nSee [RELEASE](RELEASE.md)\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2024, Datalayer All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  ---  This library reuse part of Jupyter Server code licensed under BSD 3-Clause License Source: https://github.com/jupyter-server/jupyter_server/blame/v2.12.0/jupyter_server/services/kernels/connection/base.py  This library reuse part of traitlets code licensed under BSD 3-Clause License Source: https://github.com/ipython/traitlets/blob/v5.14.3/traitlets/log.py",
    "summary": null,
    "version": "0.2.0",
    "project_urls": {
        "Home": "https://github.com/datalayer/jupyter-ai-agents"
    },
    "split_keywords": [
        "jupyter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c1e04c393c0adb6c5ba3bdd2efdab2abbf19a2d04e14cfc7c1ec739bd400a10",
                "md5": "2f5f87731056b7ef0cf1853bda42d376",
                "sha256": "50f1c59fe99e69254b3f1d8e9e143d24a429e3ceeada1da40cc443b78a508dd4"
            },
            "downloads": -1,
            "filename": "jupyter_ai_agents-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2f5f87731056b7ef0cf1853bda42d376",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 14453,
            "upload_time": "2025-01-22T06:50:57",
            "upload_time_iso_8601": "2025-01-22T06:50:57.125208Z",
            "url": "https://files.pythonhosted.org/packages/4c/1e/04c393c0adb6c5ba3bdd2efdab2abbf19a2d04e14cfc7c1ec739bd400a10/jupyter_ai_agents-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-22 06:50:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datalayer",
    "github_project": "jupyter-ai-agents",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jupyter-ai-agents"
}
        
Elapsed time: 3.40534s