Metadata-Version: 2.4
Name: llm-bench-cli
Version: 0.1.0
Summary: A developer-centric CLI tool to systematically evaluate and compare Large Language Models (LLMs)
Project-URL: Homepage, https://github.com/abdulbb/llm-bench-cli
Project-URL: Repository, https://github.com/abdulbb/llm-bench-cli.git
Project-URL: Issues, https://github.com/abdulbb/llm-bench-cli/issues
Project-URL: Documentation, https://github.com/abdulbb/llm-bench-cli#readme
Project-URL: Changelog, https://github.com/abdulbb/llm-bench-cli/releases
Author: Abdul Basit Banbhan
License: MIT License
        
        Copyright (c) 2025 Abdul Basit Banbhan
        
        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: ai,anthropic,benchmark,claude,cli,evaluation,gemini,gpt,llm,openai,testing
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: deepdiff>=6.0.0
Requires-Dist: diskcache>=5.6.0
Requires-Dist: litellm>=1.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.9.0
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
Description-Content-Type: text/markdown

<div align="center">

# LLM-Bench

A developer-centric CLI tool to systematically evaluate and compare Large Language Models (LLMs). Define prompts, test cases, and expected outputs, run them concurrently against multiple providers, and get detailed performance metrics (Accuracy, Latency, Throughput, Cost) in your terminal.

![Preview](docs/preview.png)

![Demo](docs/demo.gif)

</div>

## Features

- **Multi-Provider Support**: OpenAI, Anthropic, Google Gemini, Groq, Mistral, Cohere, Together AI, Azure, and more (via `litellm`).
- **Rich Terminal Output**: Real-time progress bars with ETA.
- **Detailed Metrics**: Pass rates, P95 latency, TTFT, tokens/sec, and cost.
- **Flexible Validation**: Regex patterns, custom Python validators, JSON Schema, LLM judges.
- **ROUGE-L Scoring**: Compare outputs against reference texts.
- **Concurrent Execution**: Fast parallel testing with rate limiting.
- **Caching**: Saves money on repeated runs.
- **Export**: HTML, CSV, or JSON reports with interactive charts.
- **Comparison**: Compare benchmark results across runs.
- **External Data**: Load test cases from CSV or JSONL files.
- **Interactive Setup**: Config wizard to get started quickly.
- **CI/CD Friendly**: Quiet mode, no-color output, fail-fast, and dry-run support.

## Installation

```bash
pip install llm-bench-cli
```

Or install from source:

```bash
git clone https://github.com/abdulbb/llm-bench-cli.git
cd llm-bench-cli
pip install -e .
```

 ## Setting Up API Keys

 Set your API keys as environment variables before running benchmarks:

 ```bash
 export OPENAI_API_KEY="sk-..."
 export ANTHROPIC_API_KEY="sk-ant-..."
 export GEMINI_API_KEY="..."
 export GROQ_API_KEY="gsk_..."
 export OPENROUTER_API_KEY="sk-or-..."
 ```

 To make these persistent across terminal sessions, add them to your `~/.bashrc`, `~/.zshrc`, or use a tool like `direnv`.

 For more detailed setup instructions, see [**Provider Setup**](docs/providers.md).

 ## Documentation

*   [**CLI Reference**](docs/cli.md): All commands and options.
*   [**Configuration Guide**](docs/configuration.md): Learn how to write `bench.config.yaml`.
*   [**Real-World Examples**](docs/examples.md): **Start Here!** Code generation, summarization, and data extraction scenarios.
*   [**Evaluation & Validation**](docs/evaluation.md): How results are judged (Regex, Custom Validators, JSON Schema, LLM Judge).
*   [**Exporting Results**](docs/export.md): Details on HTML, CSV, and JSON output.
*   [**Provider Setup**](docs/providers.md): How to setup API keys for OpenAI, Gemini, Groq, etc.
*   [**Development**](docs/development.md): How to contribute to this project.

## Quick Start

**1. Create a new benchmark configuration:**
```bash
# Interactive wizard
llm-bench init

# Or generate a template
llm-bench init --non-interactive
```

**2. Validate your configuration:**
```bash
llm-bench validate --config bench.config.yaml
```

**3. Preview without making API calls:**
```bash
llm-bench run --config bench.config.yaml --dry-run
```

**4. Run the benchmark:**
```bash
llm-bench run --config bench.config.yaml
```

## Usage Examples

**Run a Standard Benchmark:**
```bash
llm-bench run --config code_gen.yaml
```

**Compare Models on the Fly:**
```bash
llm-bench run --model openai/gpt-4o --model anthropic/claude-3-5-sonnet-20241022
```

**Generate an Interactive Report:**
```bash
llm-bench run --config summarization.yaml --export html --output report.html
```

**Set Safety Limits:**
```bash
llm-bench run --config expensive_test.yaml --max-cost 1.0
```

**Stop on First Failure:**
```bash
llm-bench run --config ci_tests.yaml --fail-fast
```

**CI/CD Mode (quiet, no colors):**
```bash
llm-bench run --config bench.config.yaml --quiet --no-color
```

**List Available Models:**
```bash
llm-bench models
llm-bench models --provider openai
llm-bench models --provider groq
```

**Manage Cache:**
```bash
llm-bench cache info
llm-bench cache clear
```

**Compare Benchmark Results:**
```bash
llm-bench compare run1.json run2.json --export html --output comparison.html
```

**Enable Shell Completions:**
```bash
# Install completions for your shell
llm-bench --install-completion

# Show completion script without installing
llm-bench --show-completion
```

See [**CLI Reference**](docs/cli.md) for all commands and options, and [**Real-World Examples**](docs/examples.md) for full configuration files.

## Example Configuration

```yaml
name: "Code Generation Benchmark"
system_prompt: "You are a Python coding assistant."
models:
  - "openai/gpt-4o"
  - "anthropic/claude-3-5-sonnet-20241022"
  - "groq/llama-3.1-70b-versatile"

validators_file: "validators.py"

test_cases:
  - input: "Write a function to calculate factorial"
    regex_pattern: "def factorial"
    validator: "is_valid_python"
    
  - input: "What is 2+2?"
    expected: 4
```

## License

MIT
