fasteval-core 1.2.0__tar.gz → 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/PKG-INFO +95 -23
- fasteval_core-1.2.1/README.md +259 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/core/scoring.py +2 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/pyproject.toml +34 -3
- fasteval_core-1.2.0/README.md +0 -187
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/cache/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/cache/memory.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/collector.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/reporters/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/reporters/base.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/reporters/html_reporter.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/reporters/json_reporter.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/collectors/summary.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/core/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/core/decorators.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/core/evaluator.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/audio.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/base.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/code_judge.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/conversation.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/deterministic.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/llm.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/multimodal.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/metrics/vision.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/models/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/models/config.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/models/evaluation.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/models/multimodal.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/providers/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/providers/anthropic.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/providers/base.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/providers/openai.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/providers/registry.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/py.typed +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/testing/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/testing/plugin.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/__init__.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/async_helpers.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/audio.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/formatting.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/image.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/json_parsing.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/terminal_ui.py +0 -0
- {fasteval_core-1.2.0 → fasteval_core-1.2.1}/fasteval/utils/text.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: fasteval-core
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: A decorator-first LLM evaluation library for testing AI agents
|
|
5
5
|
Keywords: llm,evaluation,testing,ai,agents,pytest
|
|
6
6
|
Author: Intuit
|
|
@@ -36,7 +36,7 @@ Requires-Dist: httpx>=0.25 ; extra == 'vision'
|
|
|
36
36
|
Requires-Python: >=3.10, <4.0
|
|
37
37
|
Project-URL: Homepage, https://github.com/intuit/fasteval
|
|
38
38
|
Project-URL: Repository, https://github.com/intuit/fasteval
|
|
39
|
-
Project-URL: Documentation, https://
|
|
39
|
+
Project-URL: Documentation, https://fasteval.io
|
|
40
40
|
Project-URL: Issues, https://github.com/intuit/fasteval/issues
|
|
41
41
|
Project-URL: Changelog, https://github.com/intuit/fasteval/blob/main/CHANGELOG.md
|
|
42
42
|
Provides-Extra: anthropic
|
|
@@ -57,19 +57,34 @@ Description-Content-Type: text/markdown
|
|
|
57
57
|

|
|
58
58
|
[](https://github.com/intuit/fasteval/actions/workflows/ci.yml)
|
|
59
59
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
60
|
+
[](https://fasteval.io)
|
|
60
61
|
|
|
61
|
-
A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Stack decorators to define evaluation criteria, run with pytest.
|
|
62
|
+
A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Stack decorators to define evaluation criteria, run with pytest. [Read the docs](https://fasteval.io/docs).
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
<img src="hero-evaluation-journey.png" alt="The Evaluation Journey -- from non-deterministic LLM outputs to reliable engineering metrics" width="800">
|
|
66
|
+
</p>
|
|
62
67
|
|
|
63
68
|
## Features
|
|
64
69
|
|
|
65
|
-
- **
|
|
70
|
+
- **50+ built-in metrics** -- stack `@fe.correctness`, `@fe.relevance`, `@fe.hallucination`, and more
|
|
66
71
|
- **pytest native** -- run evaluations with `pytest`, get familiar pass/fail output
|
|
67
72
|
- **LLM-as-judge + deterministic** -- semantic LLM metrics alongside ROUGE, exact match, JSON schema, regex
|
|
73
|
+
- **Custom criteria** -- `@fe.criteria("Is the response empathetic?")` for any evaluation you can describe in plain English
|
|
68
74
|
- **Multi-modal** -- evaluate vision, audio, and image generation models
|
|
69
75
|
- **Conversation metrics** -- context retention, topic drift, consistency for multi-turn agents
|
|
70
76
|
- **RAG metrics** -- faithfulness, contextual precision, contextual recall, answer correctness
|
|
71
77
|
- **Tool trajectory** -- verify agent tool calls, argument matching, call sequences
|
|
72
|
-
- **
|
|
78
|
+
- **Reusable metric stacks** -- `@fe.stack()` to compose and reuse metric sets across tests
|
|
79
|
+
- **Human-in-the-loop** -- `@fe.human_review()` for manual review alongside automated metrics
|
|
80
|
+
- **Data-driven testing** -- `@fe.csv("test_data.csv")` to load test cases from CSV files
|
|
81
|
+
- **Pluggable providers** -- OpenAI (default), Anthropic, or bring your own `LLMClient`
|
|
82
|
+
|
|
83
|
+
## How It Works
|
|
84
|
+
|
|
85
|
+
<p align="center">
|
|
86
|
+
<img src="fasteval-overview.png" alt="How fasteval works -- Decorate, Test, Score, Evaluate, Result" width="800">
|
|
87
|
+
</p>
|
|
73
88
|
|
|
74
89
|
## Quick Start
|
|
75
90
|
|
|
@@ -146,6 +161,23 @@ def test_summary_quality():
|
|
|
146
161
|
fe.score(actual_output=summary, expected_output=reference)
|
|
147
162
|
```
|
|
148
163
|
|
|
164
|
+
### Custom Criteria
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
@fe.criteria("Is the response empathetic and professional?")
|
|
168
|
+
def test_tone():
|
|
169
|
+
response = agent("I'm frustrated with this product!")
|
|
170
|
+
fe.score(response)
|
|
171
|
+
|
|
172
|
+
@fe.criteria(
|
|
173
|
+
"Does the response include a legal disclaimer?",
|
|
174
|
+
threshold=0.9,
|
|
175
|
+
)
|
|
176
|
+
def test_compliance():
|
|
177
|
+
response = agent("Can I break my lease?")
|
|
178
|
+
fe.score(response)
|
|
179
|
+
```
|
|
180
|
+
|
|
149
181
|
### RAG Evaluation
|
|
150
182
|
|
|
151
183
|
```python
|
|
@@ -167,7 +199,8 @@ def test_rag_pipeline():
|
|
|
167
199
|
def test_agent_tools():
|
|
168
200
|
result = agent.run("Book a flight to Paris")
|
|
169
201
|
fe.score(
|
|
170
|
-
|
|
202
|
+
result.response,
|
|
203
|
+
tool_calls=result.tool_calls,
|
|
171
204
|
expected_tools=[
|
|
172
205
|
{"name": "search_flights", "args": {"destination": "Paris"}},
|
|
173
206
|
{"name": "book_flight"},
|
|
@@ -175,24 +208,54 @@ def test_agent_tools():
|
|
|
175
208
|
)
|
|
176
209
|
```
|
|
177
210
|
|
|
211
|
+
### Multi-Turn Conversations
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
@fe.context_retention(threshold=0.8)
|
|
215
|
+
@fe.conversation([
|
|
216
|
+
{"query": "My name is Alice and I'm a vegetarian"},
|
|
217
|
+
{"query": "Suggest a restaurant for me"},
|
|
218
|
+
{"query": "What dietary restriction should they accommodate?"},
|
|
219
|
+
])
|
|
220
|
+
async def test_memory(query, expected, history):
|
|
221
|
+
response = await agent(query, history=history)
|
|
222
|
+
fe.score(response, input=query, history=history)
|
|
223
|
+
```
|
|
224
|
+
|
|
178
225
|
### Metric Stacks
|
|
179
226
|
|
|
180
227
|
```python
|
|
228
|
+
# Define a reusable metric stack
|
|
229
|
+
@fe.stack()
|
|
181
230
|
@fe.correctness(threshold=0.8, weight=2.0)
|
|
182
231
|
@fe.relevance(threshold=0.7, weight=1.0)
|
|
183
232
|
@fe.coherence(threshold=0.6, weight=1.0)
|
|
184
|
-
def
|
|
233
|
+
def quality_metrics():
|
|
234
|
+
pass
|
|
235
|
+
|
|
236
|
+
# Apply to multiple tests
|
|
237
|
+
@quality_metrics
|
|
238
|
+
def test_chatbot():
|
|
185
239
|
response = agent("Explain quantum computing")
|
|
186
240
|
fe.score(response, expected_output=reference_answer, input="Explain quantum computing")
|
|
241
|
+
|
|
242
|
+
@quality_metrics
|
|
243
|
+
def test_summarizer():
|
|
244
|
+
summary = summarize(long_article)
|
|
245
|
+
fe.score(summary, expected_output=reference_summary)
|
|
187
246
|
```
|
|
188
247
|
|
|
189
248
|
## Plugins
|
|
190
249
|
|
|
191
250
|
| Plugin | Description | Install |
|
|
192
251
|
|--------|-------------|---------|
|
|
193
|
-
| [fasteval-langfuse](
|
|
194
|
-
| [fasteval-langgraph](
|
|
195
|
-
| [fasteval-observe](
|
|
252
|
+
| [fasteval-langfuse](https://fasteval.io/docs/plugins/langfuse/overview) | Evaluate Langfuse production traces with fasteval metrics | `pip install fasteval-langfuse` |
|
|
253
|
+
| [fasteval-langgraph](https://fasteval.io/docs/plugins/langgraph/overview) | Test harness for LangGraph agents | `pip install fasteval-langgraph` |
|
|
254
|
+
| [fasteval-observe](https://fasteval.io/docs/plugins/observe/overview) | Runtime monitoring with async sampling | `pip install fasteval-observe` |
|
|
255
|
+
|
|
256
|
+
<p align="center">
|
|
257
|
+
<img src="testing-pyramid-agents.png" alt="Testing Pyramid for Agents -- layered testing strategy with fasteval-langgraph" width="700">
|
|
258
|
+
</p>
|
|
196
259
|
|
|
197
260
|
## Local Development
|
|
198
261
|
|
|
@@ -200,12 +263,15 @@ def test_comprehensive():
|
|
|
200
263
|
# Install uv
|
|
201
264
|
brew install uv
|
|
202
265
|
|
|
203
|
-
# Create virtual environment and install dependencies
|
|
204
|
-
uv sync --all-extras
|
|
266
|
+
# Create virtual environment and install all dependencies
|
|
267
|
+
uv sync --all-extras --group dev --group test
|
|
205
268
|
|
|
206
269
|
# Run the test suite
|
|
207
270
|
uv run tox
|
|
208
271
|
|
|
272
|
+
# Run tests with coverage
|
|
273
|
+
uv run pytest tests/ --cov=fasteval --cov-report=term -v
|
|
274
|
+
|
|
209
275
|
# Format code
|
|
210
276
|
uv run black .
|
|
211
277
|
uv run isort .
|
|
@@ -216,17 +282,23 @@ uv run mypy .
|
|
|
216
282
|
|
|
217
283
|
## Documentation
|
|
218
284
|
|
|
219
|
-
Full documentation is available
|
|
220
|
-
|
|
221
|
-
- [Getting Started](
|
|
222
|
-
- [
|
|
223
|
-
- [
|
|
224
|
-
- [
|
|
225
|
-
- [
|
|
226
|
-
- [
|
|
227
|
-
- [
|
|
228
|
-
- [
|
|
229
|
-
- [
|
|
285
|
+
Full documentation is available at **[fasteval.io](https://fasteval.io)**.
|
|
286
|
+
|
|
287
|
+
- [Getting Started](https://fasteval.io/docs/getting-started/quickstart) -- installation and quickstart guide
|
|
288
|
+
- [Why FastEval](https://fasteval.io/docs/getting-started/introduction/why-fasteval) -- motivation and design philosophy
|
|
289
|
+
- [Core Concepts](https://fasteval.io/docs/core-concepts/decorators) -- decorators, metrics, scoring, data sources
|
|
290
|
+
- [Concepts](https://fasteval.io/docs/concepts/llm-as-judge) -- LLM-as-judge, scoring thresholds, evaluation strategies
|
|
291
|
+
- [LLM Metrics](https://fasteval.io/docs/llm-metrics/correctness) -- correctness, relevance, hallucination, and more
|
|
292
|
+
- [Deterministic Metrics](https://fasteval.io/docs/deterministic-metrics/exact-match) -- ROUGE, exact match, regex, JSON schema
|
|
293
|
+
- [RAG Metrics](https://fasteval.io/docs/rag-metrics/faithfulness) -- faithfulness, contextual precision/recall
|
|
294
|
+
- [Tool Trajectory](https://fasteval.io/docs/tool-tranjectory-metrics/tool-call-accuracy) -- tool call accuracy, sequence, argument matching
|
|
295
|
+
- [Conversation Metrics](https://fasteval.io/docs/conversation-metrics/context-retention) -- context retention, consistency, topic drift
|
|
296
|
+
- [Multi-Modal](https://fasteval.io/docs/multimodal/overview) -- vision, audio, image generation evaluation
|
|
297
|
+
- [Human Review](https://fasteval.io/docs/human-review/overview) -- human-in-the-loop evaluation
|
|
298
|
+
- [Cookbooks](https://fasteval.io/docs/cookbooks/rag-pipeline) -- RAG pipelines, CI/CD setup, prompt regression, production monitoring
|
|
299
|
+
- [Plugins](https://fasteval.io/docs/plugins/langfuse/overview) -- Langfuse, LangGraph, Observe
|
|
300
|
+
- [Advanced](https://fasteval.io/docs/advanced/custom-metrics) -- custom metrics, providers, output collectors, traces
|
|
301
|
+
- [API Reference](https://fasteval.io/docs/api-reference/decorators) -- decorators, evaluator, models, score
|
|
230
302
|
|
|
231
303
|
## Contributing
|
|
232
304
|
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# fasteval
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/fasteval-core/)
|
|
4
|
+
[](https://pypi.org/project/fasteval-langgraph/)
|
|
5
|
+
[](https://pypi.org/project/fasteval-langfuse/)
|
|
6
|
+
[](https://pypi.org/project/fasteval-observe/)
|
|
7
|
+

|
|
8
|
+
[](https://github.com/intuit/fasteval/actions/workflows/ci.yml)
|
|
9
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
10
|
+
[](https://fasteval.io)
|
|
11
|
+
|
|
12
|
+
A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Stack decorators to define evaluation criteria, run with pytest. [Read the docs](https://fasteval.io/docs).
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<img src="hero-evaluation-journey.png" alt="The Evaluation Journey -- from non-deterministic LLM outputs to reliable engineering metrics" width="800">
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **50+ built-in metrics** -- stack `@fe.correctness`, `@fe.relevance`, `@fe.hallucination`, and more
|
|
21
|
+
- **pytest native** -- run evaluations with `pytest`, get familiar pass/fail output
|
|
22
|
+
- **LLM-as-judge + deterministic** -- semantic LLM metrics alongside ROUGE, exact match, JSON schema, regex
|
|
23
|
+
- **Custom criteria** -- `@fe.criteria("Is the response empathetic?")` for any evaluation you can describe in plain English
|
|
24
|
+
- **Multi-modal** -- evaluate vision, audio, and image generation models
|
|
25
|
+
- **Conversation metrics** -- context retention, topic drift, consistency for multi-turn agents
|
|
26
|
+
- **RAG metrics** -- faithfulness, contextual precision, contextual recall, answer correctness
|
|
27
|
+
- **Tool trajectory** -- verify agent tool calls, argument matching, call sequences
|
|
28
|
+
- **Reusable metric stacks** -- `@fe.stack()` to compose and reuse metric sets across tests
|
|
29
|
+
- **Human-in-the-loop** -- `@fe.human_review()` for manual review alongside automated metrics
|
|
30
|
+
- **Data-driven testing** -- `@fe.csv("test_data.csv")` to load test cases from CSV files
|
|
31
|
+
- **Pluggable providers** -- OpenAI (default), Anthropic, or bring your own `LLMClient`
|
|
32
|
+
|
|
33
|
+
## How It Works
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="fasteval-overview.png" alt="How fasteval works -- Decorate, Test, Score, Evaluate, Result" width="800">
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install fasteval-core
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Set your LLM provider key:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export OPENAI_API_KEY=sk-your-key-here
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Write your first evaluation test:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import fasteval as fe
|
|
55
|
+
|
|
56
|
+
@fe.correctness(threshold=0.8)
|
|
57
|
+
@fe.relevance(threshold=0.7)
|
|
58
|
+
def test_qa_agent():
|
|
59
|
+
response = my_agent("What is the capital of France?")
|
|
60
|
+
fe.score(response, expected_output="Paris", input="What is the capital of France?")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Run it:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pytest test_qa_agent.py -v
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# pip
|
|
73
|
+
pip install fasteval-core
|
|
74
|
+
|
|
75
|
+
# uv
|
|
76
|
+
uv add fasteval-core
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Optional Extras
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Anthropic provider
|
|
83
|
+
pip install fasteval-core[anthropic]
|
|
84
|
+
|
|
85
|
+
# Vision-language evaluation (GPT-4V, Claude Vision)
|
|
86
|
+
pip install fasteval-core[vision]
|
|
87
|
+
|
|
88
|
+
# Audio/speech evaluation (Whisper, ASR)
|
|
89
|
+
pip install fasteval-core[audio]
|
|
90
|
+
|
|
91
|
+
# Image generation evaluation (DALL-E, Stable Diffusion)
|
|
92
|
+
pip install fasteval-core[image-gen]
|
|
93
|
+
|
|
94
|
+
# All multi-modal features
|
|
95
|
+
pip install fasteval-core[multimodal]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Usage Examples
|
|
99
|
+
|
|
100
|
+
### Deterministic Metrics
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
import fasteval as fe
|
|
104
|
+
|
|
105
|
+
@fe.contains()
|
|
106
|
+
def test_keyword_present():
|
|
107
|
+
fe.score("The answer is 42", expected_output="42")
|
|
108
|
+
|
|
109
|
+
@fe.rouge(threshold=0.6, rouge_type="rougeL")
|
|
110
|
+
def test_summary_quality():
|
|
111
|
+
fe.score(actual_output=summary, expected_output=reference)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Custom Criteria
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
@fe.criteria("Is the response empathetic and professional?")
|
|
118
|
+
def test_tone():
|
|
119
|
+
response = agent("I'm frustrated with this product!")
|
|
120
|
+
fe.score(response)
|
|
121
|
+
|
|
122
|
+
@fe.criteria(
|
|
123
|
+
"Does the response include a legal disclaimer?",
|
|
124
|
+
threshold=0.9,
|
|
125
|
+
)
|
|
126
|
+
def test_compliance():
|
|
127
|
+
response = agent("Can I break my lease?")
|
|
128
|
+
fe.score(response)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### RAG Evaluation
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
@fe.faithfulness(threshold=0.8)
|
|
135
|
+
@fe.contextual_precision(threshold=0.7)
|
|
136
|
+
def test_rag_pipeline():
|
|
137
|
+
result = rag_pipeline("How does photosynthesis work?")
|
|
138
|
+
fe.score(
|
|
139
|
+
actual_output=result.answer,
|
|
140
|
+
context=result.retrieved_docs,
|
|
141
|
+
input="How does photosynthesis work?",
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Tool Trajectory
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
@fe.tool_call_accuracy(threshold=0.9)
|
|
149
|
+
def test_agent_tools():
|
|
150
|
+
result = agent.run("Book a flight to Paris")
|
|
151
|
+
fe.score(
|
|
152
|
+
result.response,
|
|
153
|
+
tool_calls=result.tool_calls,
|
|
154
|
+
expected_tools=[
|
|
155
|
+
{"name": "search_flights", "args": {"destination": "Paris"}},
|
|
156
|
+
{"name": "book_flight"},
|
|
157
|
+
],
|
|
158
|
+
)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Multi-Turn Conversations
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
@fe.context_retention(threshold=0.8)
|
|
165
|
+
@fe.conversation([
|
|
166
|
+
{"query": "My name is Alice and I'm a vegetarian"},
|
|
167
|
+
{"query": "Suggest a restaurant for me"},
|
|
168
|
+
{"query": "What dietary restriction should they accommodate?"},
|
|
169
|
+
])
|
|
170
|
+
async def test_memory(query, expected, history):
|
|
171
|
+
response = await agent(query, history=history)
|
|
172
|
+
fe.score(response, input=query, history=history)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Metric Stacks
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
# Define a reusable metric stack
|
|
179
|
+
@fe.stack()
|
|
180
|
+
@fe.correctness(threshold=0.8, weight=2.0)
|
|
181
|
+
@fe.relevance(threshold=0.7, weight=1.0)
|
|
182
|
+
@fe.coherence(threshold=0.6, weight=1.0)
|
|
183
|
+
def quality_metrics():
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
# Apply to multiple tests
|
|
187
|
+
@quality_metrics
|
|
188
|
+
def test_chatbot():
|
|
189
|
+
response = agent("Explain quantum computing")
|
|
190
|
+
fe.score(response, expected_output=reference_answer, input="Explain quantum computing")
|
|
191
|
+
|
|
192
|
+
@quality_metrics
|
|
193
|
+
def test_summarizer():
|
|
194
|
+
summary = summarize(long_article)
|
|
195
|
+
fe.score(summary, expected_output=reference_summary)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Plugins
|
|
199
|
+
|
|
200
|
+
| Plugin | Description | Install |
|
|
201
|
+
|--------|-------------|---------|
|
|
202
|
+
| [fasteval-langfuse](https://fasteval.io/docs/plugins/langfuse/overview) | Evaluate Langfuse production traces with fasteval metrics | `pip install fasteval-langfuse` |
|
|
203
|
+
| [fasteval-langgraph](https://fasteval.io/docs/plugins/langgraph/overview) | Test harness for LangGraph agents | `pip install fasteval-langgraph` |
|
|
204
|
+
| [fasteval-observe](https://fasteval.io/docs/plugins/observe/overview) | Runtime monitoring with async sampling | `pip install fasteval-observe` |
|
|
205
|
+
|
|
206
|
+
<p align="center">
|
|
207
|
+
<img src="testing-pyramid-agents.png" alt="Testing Pyramid for Agents -- layered testing strategy with fasteval-langgraph" width="700">
|
|
208
|
+
</p>
|
|
209
|
+
|
|
210
|
+
## Local Development
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Install uv
|
|
214
|
+
brew install uv
|
|
215
|
+
|
|
216
|
+
# Create virtual environment and install all dependencies
|
|
217
|
+
uv sync --all-extras --group dev --group test
|
|
218
|
+
|
|
219
|
+
# Run the test suite
|
|
220
|
+
uv run tox
|
|
221
|
+
|
|
222
|
+
# Run tests with coverage
|
|
223
|
+
uv run pytest tests/ --cov=fasteval --cov-report=term -v
|
|
224
|
+
|
|
225
|
+
# Format code
|
|
226
|
+
uv run black .
|
|
227
|
+
uv run isort .
|
|
228
|
+
|
|
229
|
+
# Type checking
|
|
230
|
+
uv run mypy .
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Documentation
|
|
234
|
+
|
|
235
|
+
Full documentation is available at **[fasteval.io](https://fasteval.io)**.
|
|
236
|
+
|
|
237
|
+
- [Getting Started](https://fasteval.io/docs/getting-started/quickstart) -- installation and quickstart guide
|
|
238
|
+
- [Why FastEval](https://fasteval.io/docs/getting-started/introduction/why-fasteval) -- motivation and design philosophy
|
|
239
|
+
- [Core Concepts](https://fasteval.io/docs/core-concepts/decorators) -- decorators, metrics, scoring, data sources
|
|
240
|
+
- [Concepts](https://fasteval.io/docs/concepts/llm-as-judge) -- LLM-as-judge, scoring thresholds, evaluation strategies
|
|
241
|
+
- [LLM Metrics](https://fasteval.io/docs/llm-metrics/correctness) -- correctness, relevance, hallucination, and more
|
|
242
|
+
- [Deterministic Metrics](https://fasteval.io/docs/deterministic-metrics/exact-match) -- ROUGE, exact match, regex, JSON schema
|
|
243
|
+
- [RAG Metrics](https://fasteval.io/docs/rag-metrics/faithfulness) -- faithfulness, contextual precision/recall
|
|
244
|
+
- [Tool Trajectory](https://fasteval.io/docs/tool-tranjectory-metrics/tool-call-accuracy) -- tool call accuracy, sequence, argument matching
|
|
245
|
+
- [Conversation Metrics](https://fasteval.io/docs/conversation-metrics/context-retention) -- context retention, consistency, topic drift
|
|
246
|
+
- [Multi-Modal](https://fasteval.io/docs/multimodal/overview) -- vision, audio, image generation evaluation
|
|
247
|
+
- [Human Review](https://fasteval.io/docs/human-review/overview) -- human-in-the-loop evaluation
|
|
248
|
+
- [Cookbooks](https://fasteval.io/docs/cookbooks/rag-pipeline) -- RAG pipelines, CI/CD setup, prompt regression, production monitoring
|
|
249
|
+
- [Plugins](https://fasteval.io/docs/plugins/langfuse/overview) -- Langfuse, LangGraph, Observe
|
|
250
|
+
- [Advanced](https://fasteval.io/docs/advanced/custom-metrics) -- custom metrics, providers, output collectors, traces
|
|
251
|
+
- [API Reference](https://fasteval.io/docs/api-reference/decorators) -- decorators, evaluator, models, score
|
|
252
|
+
|
|
253
|
+
## Contributing
|
|
254
|
+
|
|
255
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, coding standards, and how to submit pull requests.
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
Apache License 2.0 -- see [LICENSE](./LICENSE) for details.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fasteval-core"
|
|
3
|
-
version = "1.2.
|
|
3
|
+
version = "1.2.1"
|
|
4
4
|
description = "A decorator-first LLM evaluation library for testing AI agents"
|
|
5
5
|
authors = [{name = "Intuit"}]
|
|
6
6
|
license = {text = "Apache-2.0"}
|
|
@@ -31,7 +31,7 @@ dependencies = [
|
|
|
31
31
|
[project.urls]
|
|
32
32
|
Homepage = "https://github.com/intuit/fasteval"
|
|
33
33
|
Repository = "https://github.com/intuit/fasteval"
|
|
34
|
-
Documentation = "https://
|
|
34
|
+
Documentation = "https://fasteval.io"
|
|
35
35
|
Issues = "https://github.com/intuit/fasteval/issues"
|
|
36
36
|
Changelog = "https://github.com/intuit/fasteval/blob/main/CHANGELOG.md"
|
|
37
37
|
|
|
@@ -110,9 +110,40 @@ testpaths = [
|
|
|
110
110
|
"tests",
|
|
111
111
|
]
|
|
112
112
|
looponfailroots = ["fasteval", "tests"]
|
|
113
|
-
addopts = "-p no:warnings -o log_cli=true --log-cli-level=INFO"
|
|
113
|
+
addopts = "-p no:warnings -p no:fasteval -o log_cli=true --log-cli-level=INFO"
|
|
114
114
|
asyncio_mode = "auto"
|
|
115
115
|
|
|
116
|
+
[tool.coverage.run]
|
|
117
|
+
source = ["fasteval"]
|
|
118
|
+
omit = [
|
|
119
|
+
"fasteval/__init__.py",
|
|
120
|
+
"fasteval/models/*",
|
|
121
|
+
"fasteval/metrics/vision.py",
|
|
122
|
+
"fasteval/metrics/multimodal.py",
|
|
123
|
+
"fasteval/metrics/audio.py",
|
|
124
|
+
"fasteval/metrics/__init__.py",
|
|
125
|
+
"fasteval/utils/image.py",
|
|
126
|
+
"fasteval/utils/audio.py",
|
|
127
|
+
"fasteval/utils/terminal_ui.py",
|
|
128
|
+
"fasteval/utils/__init__.py",
|
|
129
|
+
"fasteval/providers/base.py",
|
|
130
|
+
"fasteval/providers/__init__.py",
|
|
131
|
+
"fasteval/collectors/__init__.py",
|
|
132
|
+
"fasteval/collectors/reporters/__init__.py",
|
|
133
|
+
"fasteval/collectors/reporters/base.py",
|
|
134
|
+
"fasteval/core/__init__.py",
|
|
135
|
+
"fasteval/cache/__init__.py",
|
|
136
|
+
"fasteval/testing/__init__.py",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[tool.coverage.report]
|
|
140
|
+
exclude_lines = [
|
|
141
|
+
"pragma: no cover",
|
|
142
|
+
"if TYPE_CHECKING:",
|
|
143
|
+
"raise NotImplementedError",
|
|
144
|
+
"except ImportError",
|
|
145
|
+
]
|
|
146
|
+
|
|
116
147
|
[build-system]
|
|
117
148
|
requires = ["uv_build>=0.10.0,<0.11.0"]
|
|
118
149
|
build-backend = "uv_build"
|
fasteval_core-1.2.0/README.md
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# fasteval
|
|
2
|
-
|
|
3
|
-
[](https://pypi.org/project/fasteval-core/)
|
|
4
|
-
[](https://pypi.org/project/fasteval-langgraph/)
|
|
5
|
-
[](https://pypi.org/project/fasteval-langfuse/)
|
|
6
|
-
[](https://pypi.org/project/fasteval-observe/)
|
|
7
|
-

|
|
8
|
-
[](https://github.com/intuit/fasteval/actions/workflows/ci.yml)
|
|
9
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
10
|
-
|
|
11
|
-
A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Stack decorators to define evaluation criteria, run with pytest.
|
|
12
|
-
|
|
13
|
-
## Features
|
|
14
|
-
|
|
15
|
-
- **Decorator-based metrics** -- stack `@fe.correctness`, `@fe.relevance`, `@fe.hallucination`, and 30+ more
|
|
16
|
-
- **pytest native** -- run evaluations with `pytest`, get familiar pass/fail output
|
|
17
|
-
- **LLM-as-judge + deterministic** -- semantic LLM metrics alongside ROUGE, exact match, JSON schema, regex
|
|
18
|
-
- **Multi-modal** -- evaluate vision, audio, and image generation models
|
|
19
|
-
- **Conversation metrics** -- context retention, topic drift, consistency for multi-turn agents
|
|
20
|
-
- **RAG metrics** -- faithfulness, contextual precision, contextual recall, answer correctness
|
|
21
|
-
- **Tool trajectory** -- verify agent tool calls, argument matching, call sequences
|
|
22
|
-
- **Pluggable providers** -- OpenAI (default), Anthropic, Azure OpenAI, Ollama
|
|
23
|
-
|
|
24
|
-
## Quick Start
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pip install fasteval-core
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Set your LLM provider key:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
export OPENAI_API_KEY=sk-your-key-here
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Write your first evaluation test:
|
|
37
|
-
|
|
38
|
-
```python
|
|
39
|
-
import fasteval as fe
|
|
40
|
-
|
|
41
|
-
@fe.correctness(threshold=0.8)
|
|
42
|
-
@fe.relevance(threshold=0.7)
|
|
43
|
-
def test_qa_agent():
|
|
44
|
-
response = my_agent("What is the capital of France?")
|
|
45
|
-
fe.score(response, expected_output="Paris", input="What is the capital of France?")
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Run it:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
pytest test_qa_agent.py -v
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
# pip
|
|
58
|
-
pip install fasteval-core
|
|
59
|
-
|
|
60
|
-
# uv
|
|
61
|
-
uv add fasteval-core
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Optional Extras
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
# Anthropic provider
|
|
68
|
-
pip install fasteval-core[anthropic]
|
|
69
|
-
|
|
70
|
-
# Vision-language evaluation (GPT-4V, Claude Vision)
|
|
71
|
-
pip install fasteval-core[vision]
|
|
72
|
-
|
|
73
|
-
# Audio/speech evaluation (Whisper, ASR)
|
|
74
|
-
pip install fasteval-core[audio]
|
|
75
|
-
|
|
76
|
-
# Image generation evaluation (DALL-E, Stable Diffusion)
|
|
77
|
-
pip install fasteval-core[image-gen]
|
|
78
|
-
|
|
79
|
-
# All multi-modal features
|
|
80
|
-
pip install fasteval-core[multimodal]
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Usage Examples
|
|
84
|
-
|
|
85
|
-
### Deterministic Metrics
|
|
86
|
-
|
|
87
|
-
```python
|
|
88
|
-
import fasteval as fe
|
|
89
|
-
|
|
90
|
-
@fe.contains()
|
|
91
|
-
def test_keyword_present():
|
|
92
|
-
fe.score("The answer is 42", expected_output="42")
|
|
93
|
-
|
|
94
|
-
@fe.rouge(threshold=0.6, rouge_type="rougeL")
|
|
95
|
-
def test_summary_quality():
|
|
96
|
-
fe.score(actual_output=summary, expected_output=reference)
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### RAG Evaluation
|
|
100
|
-
|
|
101
|
-
```python
|
|
102
|
-
@fe.faithfulness(threshold=0.8)
|
|
103
|
-
@fe.contextual_precision(threshold=0.7)
|
|
104
|
-
def test_rag_pipeline():
|
|
105
|
-
result = rag_pipeline("How does photosynthesis work?")
|
|
106
|
-
fe.score(
|
|
107
|
-
actual_output=result.answer,
|
|
108
|
-
context=result.retrieved_docs,
|
|
109
|
-
input="How does photosynthesis work?",
|
|
110
|
-
)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Tool Trajectory
|
|
114
|
-
|
|
115
|
-
```python
|
|
116
|
-
@fe.tool_call_accuracy(threshold=0.9)
|
|
117
|
-
def test_agent_tools():
|
|
118
|
-
result = agent.run("Book a flight to Paris")
|
|
119
|
-
fe.score(
|
|
120
|
-
actual_tools=result.tool_calls,
|
|
121
|
-
expected_tools=[
|
|
122
|
-
{"name": "search_flights", "args": {"destination": "Paris"}},
|
|
123
|
-
{"name": "book_flight"},
|
|
124
|
-
],
|
|
125
|
-
)
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Metric Stacks
|
|
129
|
-
|
|
130
|
-
```python
|
|
131
|
-
@fe.correctness(threshold=0.8, weight=2.0)
|
|
132
|
-
@fe.relevance(threshold=0.7, weight=1.0)
|
|
133
|
-
@fe.coherence(threshold=0.6, weight=1.0)
|
|
134
|
-
def test_comprehensive():
|
|
135
|
-
response = agent("Explain quantum computing")
|
|
136
|
-
fe.score(response, expected_output=reference_answer, input="Explain quantum computing")
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Plugins
|
|
140
|
-
|
|
141
|
-
| Plugin | Description | Install |
|
|
142
|
-
|--------|-------------|---------|
|
|
143
|
-
| [fasteval-langfuse](./plugins/fasteval-langfuse/) | Evaluate Langfuse production traces with fasteval metrics | `pip install fasteval-langfuse` |
|
|
144
|
-
| [fasteval-langgraph](./plugins/fasteval-langgraph/) | Test harness for LangGraph agents | `pip install fasteval-langgraph` |
|
|
145
|
-
| [fasteval-observe](./plugins/fasteval-observe/) | Runtime monitoring with async sampling | `pip install fasteval-observe` |
|
|
146
|
-
|
|
147
|
-
## Local Development
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
# Install uv
|
|
151
|
-
brew install uv
|
|
152
|
-
|
|
153
|
-
# Create virtual environment and install dependencies
|
|
154
|
-
uv sync --all-extras
|
|
155
|
-
|
|
156
|
-
# Run the test suite
|
|
157
|
-
uv run tox
|
|
158
|
-
|
|
159
|
-
# Format code
|
|
160
|
-
uv run black .
|
|
161
|
-
uv run isort .
|
|
162
|
-
|
|
163
|
-
# Type checking
|
|
164
|
-
uv run mypy .
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Documentation
|
|
168
|
-
|
|
169
|
-
Full documentation is available in the [docs/](./docs/) directory, covering:
|
|
170
|
-
|
|
171
|
-
- [Getting Started](./docs/getting-started/) -- installation, quickstart
|
|
172
|
-
- [Core Concepts](./docs/core-concepts/) -- decorators, metrics, scoring, data sources
|
|
173
|
-
- [LLM Metrics](./docs/llm-metrics/) -- correctness, relevance, hallucination, and more
|
|
174
|
-
- [Deterministic Metrics](./docs/deterministic-metrics/) -- ROUGE, exact match, regex, JSON schema
|
|
175
|
-
- [RAG Metrics](./docs/rag-metrics/) -- faithfulness, contextual precision/recall
|
|
176
|
-
- [Conversation Metrics](./docs/conversation-metrics/) -- context retention, consistency
|
|
177
|
-
- [Multi-Modal](./docs/multimodal/) -- vision, audio, image generation evaluation
|
|
178
|
-
- [Plugins](./docs/plugins/) -- Langfuse, LangGraph, Observe
|
|
179
|
-
- [API Reference](./docs/api-reference/) -- decorators, evaluator, models, score
|
|
180
|
-
|
|
181
|
-
## Contributing
|
|
182
|
-
|
|
183
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, coding standards, and how to submit pull requests.
|
|
184
|
-
|
|
185
|
-
## License
|
|
186
|
-
|
|
187
|
-
Apache License 2.0 -- see [LICENSE](./LICENSE) for details.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|