Metadata-Version: 2.1
Name: pytest-langchain
Version: 0.1.0
Summary: Pytest-style test runner for langchain agents
Home-page: https://github.com/ajndkr/pytest-langchain
Author: Ajinkya Indulkar
Author-email: 26824103+ajndkr@users.noreply.github.com
License: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: <3.11,>=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# 🦜️🔗✅ pytest-langchain

Pytest-style test runner for langchain projects.

<div align="center">

[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/ajndkr/pytest-langchain/dot/blob/main/LICENSE)
[![CI](https://github.com/ajndkr/pytest-langchain/actions/workflows/ci.yaml/badge.svg)](https://github.com/ajndkr/pytest-langchain/actions/workflows/ci.yaml)
[![Publish](https://github.com/ajndkr/pytest-langchain/actions/workflows/publish.yaml/badge.svg)](https://github.com/ajndkr/pytest-langchain/actions/workflows/publish.yaml)

</div>

## Installation

### Install from PyPI:

```
pip install pytest-langchain
```

### Install from source:

```
git clone https://github.com/ajndkr/pytest-langchain
cd pytest-langchain
pip install .
```

## Usage

-   Serialise your LLM chain into a YAML file.
    Refer to [docs](https://langchain.readthedocs.io/en/latest/modules/chains/generic/serialization.html)
    for more details.

-   Create a new configuration YAML file to run `pytest-langchain` with the following structure:

    ```yaml
    chain_file: <path to chain YAML file>
    test_cases:
    - [<input-1>, <expected output-1>]
    - [<input-2>, <expected output-2>]
    - ...
    ```

-   Run `pytest-langchain`:

    ```
    pytest-langchain -c <path to config YAML file> --openai-api-key <OPENAI API key>
    ```

    For more options, run `pytest-langchain --help`.
