Metadata-Version: 2.1
Name: langrade
Version: 0.1.0
Summary: A library for grading and retrieving documents based on relevance
Home-page: https://github.com/nisaji/langrade
License: MIT
Keywords: nlp,document grading,retrieval
Author: nisaji
Author-email: nisaji27@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: anthropic (==0.2.8)
Requires-Dist: chromadb (>=0.4.22,<0.5.0)
Requires-Dist: google-generativeai (>=0.7.1,<0.8.0)
Requires-Dist: langchain (>=0.1.0,<0.2.0)
Requires-Dist: langchain_community (>=0.0.13,<0.0.14)
Requires-Dist: langchain_core (>=0.1.0,<0.2.0)
Requires-Dist: langchain_openai (>=0.0.2,<0.0.3)
Requires-Dist: openai (>=1.2.0,<2.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: tiktoken (>=0.5.2,<0.6.0)
Project-URL: Repository, https://github.com/nisaji/langrade
Description-Content-Type: text/markdown

# Langrade

Langrade is a Python library for grading and retrieving documents based on their relevance to a given question.

## Installation

You can install Langrade using pip:

```
pip install langrade
```

## Usage

Here's a quick example of how to use Langrade:

```python
from langrade import document_grader, create_retriever

# Initialize the grader
api_key = "your_openai_api_key_here"
grader = document_grader(api_key, reasoning=True)

# Prepare the retriever
urls = [
    "https://example.com/article1",
    "https://example.com/article2",
    "https://example.com/article3",
]
retriever = create_retriever(urls, api_key)

# Retrieve and grade a document
question = "What is AI?"
docs = retriever.get_relevant_documents(question)
doc_txt = docs[0].page_content

result = grader.grade_document(doc_txt, question)
print(f"Relevance: {result.binary_score}")
print(f"Reasoning: {result.reasoning}")
```

## Features

Document retrieval from web URLs

Document grading based on relevance to a question

Optional reasoning for grading decisions

## Requirements

Python 3.8+

OpenAI API key

## Running Tests

To run all tests:

```

poetry run test

```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License.

```

```

