Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

ajndkr/pytest-langchain

Repository files navigation

🦜️🔗✅ pytest-langchain

Pytest-style test runner for langchain projects.

license CI Publish

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 for more details.

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

    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.