Metadata-Version: 2.4
Name: chATLAS_Chains
Version: 0.1.2
Summary: A modular Python package for implementing Retrieval Augmented Generation chains for the chATLAS project.
Home-page: https://gitlab.cern.ch/belliot/chatlas-packages/
Author: Joe Egan
Author-email: joseph.caimin.egan@cern.ch
Project-URL: Documentation, https://chatlas-packages.docs.cern.ch/chATLAS_Chain/
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: chATLAS_Benchmark
Requires-Dist: chATLAS_Embed>=0.1.14
Requires-Dist: langchain~=0.3.3
Requires-Dist: langchain_core
Requires-Dist: langchain_openai
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary


# chATLAS_Chains

This package implements and benchmarks various Retrieval Augmented Generation (RAG) chains for use in the [chATLAS](https://chatlas-flask-chatlas.app.cern.ch) project.

## Installation

```bash
conda create -n venv chatlas_chains_env python=3.10
conda activate chatlas_chains_env
pip install chatlas-chains
```

## Environment variables

These are required for the following use cases

1. Using an OpenAI LLM
```bash
export CHATLAS_OPENAI_KEY='your api key'
```

2. Benchmarking, set the path to the question set
```bash
export CHATLAS_BENCHMARK_QUESTIONS=/path/to/questions.josn
```

## Available Chains
- chains.basic.basic_retrieval_chain
- chains.basic_graph.basic_retrieval_graph

## Benchmarking

To benchmark e.g. the chains in `chATLAS_Chains.chains.basic` run this from the project root
```bash
python benchmark/basic.py
```

## Testing

The tests require a running postgres server to work. If on lxplus you can modify `TEST_DB_CONFIG` in [tests/conftest.py](tests/conftest.py) to connect to the chATLAS server.

If you want to create a local dummy postgres server, you need to install `psql`. This can be done on macOS using [homebrew](https://brew.sh):

Software install
```bash
brew install postgresql
brew services start postgresql
brew install pgvector
brew unlink pgvector && brew link pgvector
```

Create a user
```bash
psql -h localhost -U postgres
ALTER USER postgres WITH PASSWORD 'Set_your_password_here';
CREATE EXTENSION IF NOT EXISTS vector;
```
