Metadata-Version: 2.4
Name: langchain_widget
Version: 0.0.1
Summary: A widget to run  in Jupyter Notebook.
Author-email: Xing Wang <xingwang1991@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Xing Wang
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Dist: anywidget
Requires-Dist: langchain-core>=0.3.0
Provides-Extra: anthropic
Requires-Dist: langchain-anthropic>=0.3.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: jupyterlab; extra == 'dev'
Requires-Dist: watchfiles; extra == 'dev'
Provides-Extra: openai
Requires-Dist: langchain-openai>=0.3.0; extra == 'openai'
Provides-Extra: pre-commit
Requires-Dist: pre-commit~=2.2; extra == 'pre-commit'
Requires-Dist: pylint~=2.17.4; extra == 'pre-commit'
Description-Content-Type: text/markdown

# LangChain Widget
[![PyPI version](https://badge.fury.io/py/langchain-widget.svg)](https://badge.fury.io/py/langchain-widget)
[![Unit test](https://github.com/superstar54/langchain-widget/actions/workflows/ci.yml/badge.svg)](https://github.com/superstar54/langchain-widget/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/superstar54/langchain-widget/branch/main/graph/badge.svg)](https://codecov.io/gh/superstar54/langchain-widget)
[![Docs status](https://readthedocs.org/projects/langchain-widget/badge)](http://langchain-widget.readthedocs.io/)

Run a `LangChain` agent in Jupyter notebooks.

An `anywidget` + React chat UI for LangChain tool-calling chat models, built for notebooks and designed to compose with other Jupyter widgets.


- Works in JupyterLab / Notebook (and VS Code notebooks)
- Tool calling out of the box (your tools, your model)
- Easy to embed alongside plots, tables, and domain widgets

## Installation

```sh
pip install langchain-widget
```

## Quick start

In a notebook, create a `LangChainWidget` with your chat model and tools:

```python
from langchain_widget import LangChainWidget
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool

chat_model = ChatOpenAI(model="gpt-4o-mini")

@tool
def add(a: int, b: int) -> int:
    "Add two integers."
    return a + b

w = LangChainWidget(
    chat_model=chat_model,
    tools=[add],
    system_prompt="You are a helpful scientific assistant.",
)
w
```

Here is how it looks in a Jupyter notebook:

<img src="docs/source/_static/images/langchain-widget.png" width="100%"/>


## Documentation

Full documentation at: https://langchain-widget.readthedocs.io/


## Development

See `langchain-widget/docs/source/development.rst`.

## Contact

* Xing Wang  <xingwang1991@gmail.com>

## License

[MIT](http://opensource.org/licenses/MIT)
