Metadata-Version: 2.1
Name: chainy
Version: 0.1.0.dev3
Summary: Declarative prompt chaining
Home-page: https://github.com/FyZyX/chainy
Author: Lucas Lofaro
Author-email: lucasmlofaro@gmail.com
License: MIT
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyyaml (~=6.0)

# Chainy

## Overview

Chainy is a Python package for declarative prompt chaining.
It allows users to define a chain of prompts to be run by a Large Language Model (LLM).
These chains are defined using a YAML configuration file and can include dependencies, which are handled automatically.

## Installation

To install `chainy`, you can use a package manager like `pip`.

```bash
pip install chainy
```

You can find the package repository [here](https://pypi.org/project/chainy/).

## Usage

Chainy uses YAML configuration files to define chains of prompts.
Here's an example of what these configuration files look like:

```yaml
inputs:
  - input_1
  - input_2
prompts:
  prompt_1:
    template: tmpl01.md
    substitute:
      var_1: input_1
      var_2: input_2
  prompt_2:
    template: tmpl02.md
    substitute:
      res_1: prompt_1
```

In this example, `prompt_1` and `prompt_2` are the prompts to be run.
Each prompt includes a template file and a dictionary of variables to be substituted into the template.
The dependencies between prompts are defined in the substitute section: `prompt_2` depends on `prompt_1`.

To run a chain, call the `Chain.start()` method with the required input values:

```python
import pathlib
import chainy.config

chain_path = pathlib.Path("chains/example-1.yml")
chain = chainy.config.parse_config(chain_path)
chain.start("hey", "bud")
```

### Expected Directory Structure

```
|- yourproject/
|--- prompts/
|----- tmpl01.md
|----- tmpl02.md
|--- chains/
|----- example-1.yml
|--- entrypoint.py
```

## Testing

Tests are located in the `tests/` directory. To run them, use your preferred test runner.

## Contributing

We welcome contributions! Please open an issue or submit a pull request if you have something to add.

## License

[MIT](https://choosealicense.com/licenses/mit/)
