Skip to main content

调用LLM实现Jupyter代码的自动生成、执行、调试等功能

Project description

jupyter-agent

调用LLM实现Jupyter代码的自动生成、执行、调试等功能

特性

  • 提供%%bot指令,在juyter环境中,通过调用LLM实现代码生成、执行、调试等能力
  • 支持调用OpenAI兼容API,实现LLM相关的功能

打包(Build)

# 下载代码
git clone https://github.com/yourusername/jupyter-agent.git
cd jupyter-agent

# 安装打包环境
virtualenv .venv
source .venv/bin/activate
pip install build

# 编译打包
python -m build

# 退出打包环境
deactivate

安装

# 激活目标环境
source /path/to/target_env/bin/activate
# 安装编译好的wheel包
pip install /path/to/upyter-agent/dist/jupyter_agent-202506.1-py3-none-any.whl

使用方法

安装完成后,启动Jupyter环境(兼容Vscode的Notebook编译器)

全局配置

# 加载扩展的Magic命令
%load_ext jupyter_agent.bot_magics
# 设备模型调用的API地址,不同的Agent可以调用不同的模型,这里以调用lmstudio本地部署的模型为例
%config BotMagics.default_api_url = 'http://127.0.0.1:1234/v1'
%config BotMagics.default_api_key = 'API_KEY'
%config BotMagics.default_model_name = 'qwen3-30b-a3b' 
%config BotMagics.coding_model_name = 'devstral-small-2505-mlx'
# 设置当前Notebook的路径,由于vscode中运行里无法自动获取到该路径,需要手工指定
%config BotMagics.notebook_path = globals()["__vsc_ipynb_file__"]

全局任务规划

%%bot -P

# 全局目标
...

全局任务规划会解析用户输入的prompt,生成具体的执行计划,后续的%%bot指令会以该计划为蓝本自动生成每个步骤(子任务)的代码。

alt text alt text

生成并执行子任务代码

%% bot [-s stage]

# generated code ...

在完成全局任务规划后,开始执行子任务时,只需要新建一个cell,输入并执行%%bot命令,如下图:

alt text

注:由于cell magic命令无法直接定位当前cell,需要通过cell的内容进行匹配,因此首次执行%%bot命令时,需要在cell中额外添加一些随机字符

接下来工具会调用相应的agent自动生成并执行相应步骤的代码,如下图:

alt text

一个cell中只会执行全局计划中的一个步骤,当前步骤执行完成后,需要手工新建一个cell并重复上述过程,直到完成全局目标完成(此时工具不会再生成新代码)

在子任务执行的过程中,默认情况下每一个环节工具都会给出如下图的确认提示,可跟据实际情况输入相应的选项,或直接回车确认继续执行下一环节。

alt text

更详细用法可参考示例Notebook

贡献

欢迎提交 issue 或 pull request 参与贡献。

许可证

本项目基于 MIT License 开源。

Copyright (c) 2025 viewstar000

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_agent-2025.6.100.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_agent-2025.6.100-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_agent-2025.6.100.tar.gz.

File metadata

  • Download URL: jupyter_agent-2025.6.100.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jupyter_agent-2025.6.100.tar.gz
Algorithm Hash digest
SHA256 00f728eab4205f79baf687bbf94ccacec46c044b6bab104c2f91be87edf70911
MD5 7a5cb31ef7f8e1fdb3d815f976cf76d8
BLAKE2b-256 176387bccf7e6bce48a3ee464899015f6852daf927651035a2e6f12549d2cfb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_agent-2025.6.100.tar.gz:

Publisher: python-publish.yml on viewstar000/jupyter-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jupyter_agent-2025.6.100-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_agent-2025.6.100-py3-none-any.whl
Algorithm Hash digest
SHA256 51039056157f67e0bd8f46739f775a65051b930cb634e177e969adf1257e9347
MD5 0ef45c0be1b91c8416a8437e8367010f
BLAKE2b-256 f31523164bc7032ce8019f31bdae614ca704dbd33d3195231f8158b9b24c7c09

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_agent-2025.6.100-py3-none-any.whl:

Publisher: python-publish.yml on viewstar000/jupyter-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page