Metadata-Version: 2.4
Name: openeval-ai
Version: 0.1.0
Summary: Model-agnostic LLM evaluation that feels like pytest.
Project-URL: Homepage, https://github.com/yourusername/openeval
Project-URL: Repository, https://github.com/yourusername/openeval
Project-URL: Documentation, https://yourusername.github.io/openeval
Project-URL: Issues, https://github.com/yourusername/openeval/issues
Author: OpenEval Contributors
License: MIT License
        
        Copyright (c) 2026 OpenEval
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
License-File: LICENSE
Keywords: evaluation,llm,pytest,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.11
Requires-Dist: httpx>=0.24
Requires-Dist: pydantic>=2.0
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.20; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: mkdocs-material>=9.5.0; extra == 'dev'
Requires-Dist: mkdocs>=1.6.0; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.25.0; extra == 'dev'
Requires-Dist: mypy>=1.10.0; extra == 'dev'
Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == 'openai'
Provides-Extra: semantic
Requires-Dist: sentence-transformers>=2.2; extra == 'semantic'
Description-Content-Type: text/markdown

```
   ____                   ______          __
  / __ \____  ___  ____  / ____/___  ____/ /____
 / / / / __ \/ _ \/ __ \/ __/ / __ \/ __  / ___/
/ /_/ / /_/ /  __/ / / / /___/ / / / /_/ (__  )
\____/ .___/\___/_/ /_/_____/_/ /_/\__,_/____/
    /_/
```

[![PyPI](https://img.shields.io/pypi/v/openeval)](https://pypi.org/project/openeval/)
![Python](https://img.shields.io/badge/python-3.11%2B-blue)
![License](https://img.shields.io/badge/license-MIT-green)

**Model-agnostic LLM evaluation that feels like pytest.**

![Demo](assets/demo.gif)

## Install

```bash
pip install openeval-ai
```

Optional extras:

```bash
pip install "openeval-ai[openai]"      # OpenAI adapter
pip install "openeval-ai[anthropic]"   # Anthropic adapter
pip install "openeval-ai[semantic]"    # semantic_sim scorer
```

## Quickstart (10 lines, zero config)

```python
from openeval import EvalCase, run
from openeval.scorers import exact_match

cases = [EvalCase(input="2+2", expected_output="4")]

def my_model(prompt: str) -> str:
    return "4"

summary = run(my_model, cases, {"exact": exact_match})
print(summary.pass_rate)  # 1.0
```

## Why OpenEval

- **Scorers are just Python functions** — composable, testable, versionable.
- **Model-agnostic** — OpenAI, Anthropic, Ollama, or any callable.
- **CI-first** — pytest plugin + GitHub Action for evals on every PR.

## Architecture

```mermaid
flowchart LR
  M[Your Model] --> A[Adapter]
  A --> R[Runner / Async Runner]
  R --> S[Scorers]
  S --> E[EvalSummary]
  E --> H[HTML Report]
  E --> C[CLI]
  E --> G[GitHub Action]
```

## Comparison (benchmarks)

Benchmarks live in `benchmarks/` and use a fully offline mock model for reproducibility.

Measured on **2026-03-20** with `uv run benchmarks/run_all.py` (see `benchmarks/results.json`).

Task A: 20-case Q&A (exact match), mock model with 10ms latency per call.

| Tool | Setup (LOC) | Setup time (s) | Run time (s) | Notes |
|---|---:|---:|---:|---|
| OpenEval | 38 | 0.090 | 0.203 | ✅ |
| DeepEval | 44 | 2.250 | 0.261 | ✅ |
| Promptfoo | 50 | — | — | not run |

Notes:
- Promptfoo is optional in the harness; set `OPENEVAL_BENCH_PROMPTFOO=1` to run it.
- Promptfoo may require Node.js `>=20.20.0` or `>=22.22.0` (newer than `v22.17.x`).

## Built-in scorers

| Scorer | What it does |
|---|---|
| `exact_match` | 1.0 if output equals expected |
| `contains` | 1.0 if expected appears in output |
| `regex(pattern)` | 1.0 if output matches a regex |
| `semantic_sim` | cosine similarity via embeddings (optional extra) |
| `llm_judge(judge_fn)` | judge output quality 0.0–1.0 (bring your own judge) |

## Built-in suites

| Suite | What it tests |
|---|---|
| `hallucination` | admits uncertainty vs fabricates |
| `factuality` | basic factual QA |
| `instruction_following` | formatting/constraint compliance |

Run a suite:

```python
from openeval.suites import factuality
summary = factuality.run(lambda _: "Paris")
print(summary.pass_rate)
```

## GitHub Action

```yaml
# .github/workflows/eval.yml
name: LLM Eval
on: [pull_request]
jobs:
  eval:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: OWNER/openeval-action@v1 # replace OWNER
        with:
          suite: hallucination
          model: openai:gpt-4o-mini
          threshold: "0.8"
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

## CLI

```bash
# Run a suite
openeval run --suite factuality --model ollama:llama3.2

# Parallel (async) + HTML report
openeval run --suite hallucination --model openai:gpt-4o-mini --async --concurrency 20 --output report.html
```

## Async evaluation

```python
import asyncio
from openeval import EvalCase, arun
from openeval.scorers import exact_match

cases = [EvalCase(input="2+2", expected_output="4")]

async def model(_prompt: str) -> str:
    return "4"

summary = asyncio.run(arun(model, cases, {"exact": exact_match}, concurrency=20))
print(summary.pass_rate)
```

## Examples

- `examples/01_basic_qa.py`
- `examples/02_openai_eval.py`
- `examples/03_compare_models.py`
- `examples/04_rag_eval.py`
- `examples/05_chatbot_eval.py`
- `examples/06_code_eval.py`
- `examples/07_custom_scorer.py`
- `examples/08_cicd_integration.py`

## Contributing

See `CONTRIBUTING.md`.

## License

MIT — see `LICENSE`.
