Metadata-Version: 2.4
Name: codebind
Version: 0.5.0
Summary: A frontend-neutral model loop for persistent IPython sessions.
Keywords: ai,ipython,llm,repl,agents
Author: Giovanni Gravili
Author-email: Giovanni Gravili <ghovax@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Dist: ipython>=9.0
Requires-Dist: langchain-core>=1.0
Requires-Dist: models-provider>=0.1.1
Requires-Python: >=3.13
Project-URL: Repository, https://github.com/ghovax/codebind
Project-URL: Issues, https://github.com/ghovax/codebind/issues
Description-Content-Type: text/markdown

# Codebind

Codebind is an IPython extension that runs a model with one tool: an IPython cell executed in the active session. IPython owns execution, namespace, history, magics, tracebacks, and rich display; Codebind owns only conversation and model orchestration.

## Installation

Run Codebind without installing it permanently:

```console
uvx codebind
```

Or install it with any Python package installer:

```console
pip install codebind
```

After installation, start ordinary IPython with the Codebind extension from any directory:

```console
codebind
```

It opens standard IPython with `chat`, `models`, and `Models` in the user namespace. `models` loads provider values from `$XDG_CONFIG_HOME/codebind/models.json`, or `~/.config/codebind/models.json` when `XDG_CONFIG_HOME` is unset. Keep that credential file readable only by its owner. All normal IPython command-line options remain available.

```python
chat.send(
    "Inspect this project and tell me what to implement first.",
    models.chat("openai/gpt-5", reasoning_effort="medium"),
)
```

Codebind does not load files or construct a project prompt automatically. The user states what should be loaded as context. Pass `instructions=` to `Session` only when an application needs its own system instructions.

## Jupyter

Start JupyterLab with Codebind from any directory without a permanent installation:

```console
uvx --from jupyterlab --with codebind --with 'nbconvert[webpdf]' jupyter lab
```

Or install both packages into the same environment, then start JupyterLab normally:

```console
pip install codebind jupyterlab
jupyter lab
```

Load Codebind in a notebook:

```python
%load_ext codebind
```

Run that cell once so JupyterLab can connect to the extension, then use Codebind in later cells:

```python
model = models.chat("openai/gpt-5")
await chat.asend("Inspect the current notebook state.", model)
```

After assigning `model`, click **Question** in the notebook toolbar to insert a Question cell. Write ordinary Markdown and press `Shift+Enter`; Codebind sends the cell through `chat` using the `model` variable, renders the question as Markdown, and inserts tool executions and the assistant response beneath it. Question cells are stored as standard Markdown cells with Codebind metadata, so other notebook frontends can still read them.

The Codebind package includes a prebuilt JupyterLab extension. In JupyterLab, each model-authored IPython execution becomes a genuine code cell with its native execution count and outputs, and the assistant response becomes a rendered Markdown cell. The cells are ordinary notebook content and are saved with the notebook.

Other IPython frontends use the standard MIME display protocol instead. They still receive syntax-highlighted code, assistant Markdown, stdout, tracebacks, rich results, and native IPython history without Codebind depending on their UI.

## ChatGPT account login

Models Provider can start its OpenAI browser sign-in flow directly from IPython:

```python
import webbrowser

models = Models()
authorization = await models.sign_in("openai")
webbrowser.open(authorization.url)
await authorization.complete()

chat.send(
    "Inspect this project.",
    models.chat("openai/gpt-5", authorization=authorization),
)
```

The authorization remains in memory for this session. Save provider values as a JSON object in Codebind's XDG configuration file and reload the extension to expose them through `models`.

OpenAI officially supports ChatGPT subscription sign-in for Codex clients. Models Provider reproduces that account-access boundary for this library; it is separate from the public, pay-as-you-go OpenAI API and may require compatibility updates when the Codex account protocol changes.
