Semantic Testing for LLMs - Test your AI outputs with semantic similarity validation
Project description
🧪 PromptEval
Semantic Testing for LLMs - Test your AI outputs with semantic similarity validation.
🚀 Quick Start
Installation
pip install prompteval-core
CLI Usage
# Run tests
prompteval run adapter.yml --tests tests.yml --api-key $PROMPTEVAL_API_KEY
# Validate YAML files
prompteval validate tests.yml
# Generate HTML report
prompteval report results.json --output report.html
# Check license/quota
prompteval licenses --api-key $PROMPTEVAL_API_KEY
Python SDK
from prompteval import PromptEval
# Initialize client
client = PromptEval(api_key="pe_xxxxx")
# Run tests from files
result = client.run_from_files(
adapter_path="adapter.yml",
tests_path="tests.yml"
)
# Check results
print(f"Success rate: {result.success_rate}%")
print(f"Passed: {result.total_passed}/{result.total_tests}")
if not result.success:
for test in result.failed_tests:
print(f"❌ {test.id_test}: {test.similarity:.1%} similarity")
📋 Configuration Files
Adapter YAML
Define your LLM endpoint configuration:
name: fitness-llm-api
description: Fitness LLM Testing
# Endpoint
endpoint:
url: https://fitness-llm.com/v1/chat
method: POST
timeout: 10
# Request template
request:
headers:
Content-Type: application/json
template:
prompt: "{{PROMPT}}"
type: "{{TYPE}}"
max_tokens: 150
# Response extraction
response:
type: json
path: choices.0.message.content
# Validation
validation:
ml_threshold: 0.75
use_semantic: true
execution:
parallel_limit: 10
batch_delay: 0.3
output_dir: ./output
Test Cases YAML
Define your test cases:
tests:
- name: duration_basic
id: FIT-001
description: Pregunta sobre tiempo de entrenamiento
prompt: "Ask about training duration"
context:
PROMPT: "Ask about training duration"
TYPE: "duration"
expected: "Desde cuando estas entrenando este ejercicio o rutina"
variants:
- "Hace cuanto tiempo empezaste con este entrenamiento"
- "Cuanto tiempo llevas entrenando este ejercicio"
- "Por favor, dime cuándo empezaste con este entrenamiento."
- "Cuéntame, ¿desde cuándo entrenas así?"
threshold: 0.70
tags:
- duration
🔧 SDK Reference
PromptEval Client
from prompteval import PromptEval
client = PromptEval(
api_key="pe_xxxxx", # Required
base_url="https://...", # Optional (default: production)
timeout=300 # Optional (default: 300s)
)
Running Tests
# From files
result = client.run_from_files("adapter.yml", "tests.yml")
# From dictionaries
result = client.run(
adapter={"name": "test", "endpoint": {...}},
tests=[{"id": "T1", "expected": "..."}]
)
# From raw YAML
result = client.run_from_yaml(yaml_string)
EvalResult Object
result.success # bool - True if all tests passed
result.success_rate # float - Percentage of passed tests
result.total_tests # int - Total number of tests
result.total_passed # int - Number of passed tests
result.total_failed # int - Number of failed tests
result.total_errors # int - Number of errors
result.duration_ms # float - Total duration in milliseconds
result.test_results # List[TestResult] - All test results
result.failed_tests # List[TestResult] - Only failed tests
result.passed_tests # List[TestResult] - Only passed tests
TestResult Object
test.id_test # str - Test identifier
test.description # str - Test description
test.passed # bool - Whether test passed
test.expected # str - Expected result
test.actual # str - Actual result
test.similarity # float - Semantic similarity (0-1)
test.threshold # float - Required threshold
test.duration_ms # float - Test duration
test.error # str - Error message if any
Account Methods
# Get licenses
licenses = client.get_licenses()
for lic in licenses:
print(f"{lic.plan}: {lic.tests_remaining} tests remaining")
# Get usage
usage = client.get_usage(license_id)
print(f"Tests this month: {usage['tests_this_month']}")
# Get API keys
keys = client.get_api_keys(license_id)
🔑 Environment Variables
# Set API key (recommended)
export PROMPTEVAL_API_KEY=pe_xxxxx
# Then use without --api-key flag
prompteval run adapter.yml --tests tests.yml
🎯 CI/CD Integration
GitHub Actions
name: LLM Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install PromptEval
run: pip install prompteval
- name: Run Tests
env:
PROMPTEVAL_API_KEY: ${{ secrets.PROMPTEVAL_API_KEY }}
run: |
prompteval run adapter.yml --tests tests.yml --output results.json
prompteval report results.json --output report.html
- name: Upload Report
uses: actions/upload-artifact@v4
with:
name: test-report
path: report.html
📊 Semantic Validation
PromptEval uses sentence transformers to compute semantic similarity between expected and actual outputs. This allows flexible matching that understands meaning, not just exact text.
Example:
- Expected:
"The capital of France is Paris" - Actual:
"Paris is the capital city of France" - Similarity: 94% ✅
Threshold configuration:
0.90+- Very strict (nearly exact match)0.75-0.89- Strict (same meaning, different words)0.60-0.74- Moderate (similar concept)<0.60- Loose (related topic)
🔗 Links
- Website: https://getprompteval.com
- Documentation: https://docs.getprompteval.com
- API Reference: https://api.getprompteval.com/docs
- GitHub: https://github.com/prompteval/prompteval-sdk
📄 License
Copyright (c) 2026 PromptEval. All Rights Reserved.
This source code is proprietary and confidential. Unauthorized copying, distribution, or use is strictly prohibited.
Made with ❤️ by the PromptEval Team
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prompteval_core-0.1.3.tar.gz.
File metadata
- Download URL: prompteval_core-0.1.3.tar.gz
- Upload date:
- Size: 3.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
491ceffc4223693dda4860d9dca3fa0917d95802b924bbb792fdc73d3283ca10
|
|
| MD5 |
a8ffa60ab63d9da268876fd810b94ef2
|
|
| BLAKE2b-256 |
d1573dc2612445587454415140f9aa8866bd5b7bd4c7ea86ac5bf1cf51895db8
|
File details
Details for the file prompteval_core-0.1.3-py3-none-any.whl.
File metadata
- Download URL: prompteval_core-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1147ffb7484a043211133e12f64c7ac082907802f997444f17d6c8e0428d57d3
|
|
| MD5 |
652574cf8c6ceb1520641cbb593c47de
|
|
| BLAKE2b-256 |
e1c58b8f1f8f4242afe2842b6200f5f80d7be0db1b2da2c35801abec6c60b185
|