fasteval-core 1.2.1__tar.gz → 1.2.2__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.1 → fasteval_core-1.2.2}/PKG-INFO +75 -5
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/README.md +73 -4
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/__init__.py +15 -0
- fasteval_core-1.2.2/fasteval/__main__.py +7 -0
- fasteval_core-1.2.2/fasteval/cli/__init__.py +5 -0
- fasteval_core-1.2.2/fasteval/cli/config.py +296 -0
- fasteval_core-1.2.2/fasteval/cli/main.py +999 -0
- fasteval_core-1.2.2/fasteval/cli/ui.py +51 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/collector.py +5 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/core/__init__.py +6 -0
- fasteval_core-1.2.2/fasteval/core/api.py +198 -0
- fasteval_core-1.2.2/fasteval/core/datasets.py +240 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/core/decorators.py +151 -27
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/core/evaluator.py +53 -13
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/core/scoring.py +44 -2
- fasteval_core-1.2.2/fasteval/judges.py +393 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/deterministic.py +3 -1
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/llm.py +2 -1
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/vision.py +2 -1
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/models/__init__.py +2 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/providers/base.py +1 -1
- fasteval_core-1.2.2/fasteval/testing/events.py +78 -0
- fasteval_core-1.2.2/fasteval/testing/plugin.py +693 -0
- fasteval_core-1.2.2/fasteval/ui/__init__.py +1 -0
- fasteval_core-1.2.2/fasteval/ui/export.py +148 -0
- fasteval_core-1.2.2/fasteval/ui/runs.py +372 -0
- fasteval_core-1.2.2/fasteval/ui/server.py +675 -0
- fasteval_core-1.2.2/fasteval/ui/static/dist/app.css +1 -0
- fasteval_core-1.2.2/fasteval/ui/static/dist/app.js +54 -0
- fasteval_core-1.2.2/fasteval/ui/static/dist/index.html +14 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/audio.py +7 -1
- fasteval_core-1.2.2/fasteval/utils/judge_trace.py +132 -0
- fasteval_core-1.2.2/pyproject.toml +163 -0
- fasteval_core-1.2.1/pyproject.toml → fasteval_core-1.2.2/pyproject.toml.orig +5 -1
- fasteval_core-1.2.1/fasteval/testing/plugin.py +0 -121
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/cache/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/cache/memory.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/reporters/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/reporters/base.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/reporters/html_reporter.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/reporters/json_reporter.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/collectors/summary.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/audio.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/base.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/code_judge.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/conversation.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/metrics/multimodal.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/models/config.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/models/evaluation.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/models/multimodal.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/providers/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/providers/anthropic.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/providers/openai.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/providers/registry.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/py.typed +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/testing/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/__init__.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/async_helpers.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/formatting.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/image.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/json_parsing.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/fasteval/utils/terminal_ui.py +0 -0
- {fasteval_core-1.2.1 → fasteval_core-1.2.2}/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.2
|
|
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
|
|
@@ -20,6 +20,7 @@ Requires-Dist: openai>=1.0
|
|
|
20
20
|
Requires-Dist: pydantic>=2.0
|
|
21
21
|
Requires-Dist: rouge-score>=0.1
|
|
22
22
|
Requires-Dist: pytest>=8.0
|
|
23
|
+
Requires-Dist: tomli>=1.1 ; python_full_version < '3.11'
|
|
23
24
|
Requires-Dist: anthropic>=0.30 ; extra == 'anthropic'
|
|
24
25
|
Requires-Dist: jiwer>=3.0 ; extra == 'audio'
|
|
25
26
|
Requires-Dist: pydub>=0.25 ; extra == 'audio'
|
|
@@ -59,7 +60,7 @@ Description-Content-Type: text/markdown
|
|
|
59
60
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
60
61
|
[](https://fasteval.io)
|
|
61
62
|
|
|
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
|
+
A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Stack decorators to define evaluation criteria, run them with the `fasteval` CLI or plain pytest. [Read the docs](https://fasteval.io/docs).
|
|
63
64
|
|
|
64
65
|
<p align="center">
|
|
65
66
|
<img src="hero-evaluation-journey.png" alt="The Evaluation Journey -- from non-deterministic LLM outputs to reliable engineering metrics" width="800">
|
|
@@ -69,6 +70,9 @@ A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Sta
|
|
|
69
70
|
|
|
70
71
|
- **50+ built-in metrics** -- stack `@fe.correctness`, `@fe.relevance`, `@fe.hallucination`, and more
|
|
71
72
|
- **pytest native** -- run evaluations with `pytest`, get familiar pass/fail output
|
|
73
|
+
- **`fasteval` CLI** -- `fasteval run` runs only your evals, with named profiles, tag selection, quality gates and run history
|
|
74
|
+
- **Local UI** -- watch runs live, inspect every case and judge prompt, re-run failures and compare runs; headless CI runs write a self-contained HTML report
|
|
75
|
+
- **Prompt judges and playground** -- tune an LLM judge's prompt against real cases, save it as `judges/<name>.toml`, use it with `@fe.prompt_judge()` or swap it in with `fasteval run --judge`
|
|
72
76
|
- **LLM-as-judge + deterministic** -- semantic LLM metrics alongside ROUGE, exact match, JSON schema, regex
|
|
73
77
|
- **Custom criteria** -- `@fe.criteria("Is the response empathetic?")` for any evaluation you can describe in plain English
|
|
74
78
|
- **Multi-modal** -- evaluate vision, audio, and image generation models
|
|
@@ -77,7 +81,8 @@ A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Sta
|
|
|
77
81
|
- **Tool trajectory** -- verify agent tool calls, argument matching, call sequences
|
|
78
82
|
- **Reusable metric stacks** -- `@fe.stack()` to compose and reuse metric sets across tests
|
|
79
83
|
- **Human-in-the-loop** -- `@fe.human_review()` for manual review alongside automated metrics
|
|
80
|
-
- **Data-driven testing** -- `@fe.csv(
|
|
84
|
+
- **Data-driven testing** -- `@fe.dataset`, `@fe.csv()` and `@fe.jsonl()` turn every row or record into its own test case
|
|
85
|
+
- **Tags** -- `@fe.tag("smoke")` to label evals and select them with `fasteval run -t smoke` or `pytest -m smoke`
|
|
81
86
|
- **Pluggable providers** -- OpenAI (default), Anthropic, or bring your own `LLMClient`
|
|
82
87
|
|
|
83
88
|
## How It Works
|
|
@@ -112,10 +117,50 @@ def test_qa_agent():
|
|
|
112
117
|
|
|
113
118
|
Run it:
|
|
114
119
|
|
|
120
|
+
```bash
|
|
121
|
+
fasteval run test_qa_agent.py
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
From a terminal, the run opens live in your browser; in CI it runs headless and writes `.fasteval/report.html`. It's plain pytest underneath, so this works too:
|
|
125
|
+
|
|
115
126
|
```bash
|
|
116
127
|
pytest test_qa_agent.py -v
|
|
117
128
|
```
|
|
118
129
|
|
|
130
|
+
## Running Evals
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
fasteval # project status: config, profiles, last run
|
|
134
|
+
fasteval list # every eval with its tags, metrics and data source
|
|
135
|
+
fasteval run -t smoke # select by tag; unknown flags pass through to pytest
|
|
136
|
+
fasteval run -p ci # a named profile from [tool.fasteval.profiles]
|
|
137
|
+
fasteval run --lf -n auto # re-run failures, in parallel (pytest-xdist)
|
|
138
|
+
fasteval run --min-pass-rate 0.9 --min-score 0.75 # quality gates
|
|
139
|
+
fasteval run --judge correctness=my_judge # swap in a saved prompt judge
|
|
140
|
+
fasteval report --html --open # export the latest run as one HTML file
|
|
141
|
+
fasteval ui # run history, eval catalog, judges, playground
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Profiles keep run settings in `pyproject.toml`:
|
|
145
|
+
|
|
146
|
+
```toml
|
|
147
|
+
[tool.fasteval]
|
|
148
|
+
default_profile = "dev"
|
|
149
|
+
|
|
150
|
+
[tool.fasteval.profiles.dev]
|
|
151
|
+
paths = ["evals"]
|
|
152
|
+
tags = "not slow"
|
|
153
|
+
|
|
154
|
+
[tool.fasteval.profiles.ci]
|
|
155
|
+
extends = "dev"
|
|
156
|
+
tags = ""
|
|
157
|
+
review_prompts = false
|
|
158
|
+
headless = true
|
|
159
|
+
min_pass_rate = 0.9
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
See [The fasteval CLI](https://fasteval.io/docs/cli/overview) for details.
|
|
163
|
+
|
|
119
164
|
## Installation
|
|
120
165
|
|
|
121
166
|
```bash
|
|
@@ -208,6 +253,27 @@ def test_agent_tools():
|
|
|
208
253
|
)
|
|
209
254
|
```
|
|
210
255
|
|
|
256
|
+
### Data-Driven Evals
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
@fe.dataset
|
|
260
|
+
def support_questions():
|
|
261
|
+
yield {"id": "refund", "question": "How long do refunds take?", "expected": "Within 30 days"}
|
|
262
|
+
yield fe.case(id="hours", tags=["slow"], question="When is support open?", expected="9am to 6pm PT")
|
|
263
|
+
|
|
264
|
+
@support_questions
|
|
265
|
+
@fe.tag("rag")
|
|
266
|
+
@fe.correctness(threshold=0.7)
|
|
267
|
+
def test_support_answers(question, expected):
|
|
268
|
+
fe.score(agent(question), expected, input=question)
|
|
269
|
+
|
|
270
|
+
# One test case per CSV row: test_faq[<question>]
|
|
271
|
+
@fe.contains()
|
|
272
|
+
@fe.csv("evals/data/faq.csv", id_field="question")
|
|
273
|
+
def test_faq(question, expected):
|
|
274
|
+
fe.score(agent(question), expected, input=question)
|
|
275
|
+
```
|
|
276
|
+
|
|
211
277
|
### Multi-Turn Conversations
|
|
212
278
|
|
|
213
279
|
```python
|
|
@@ -278,6 +344,9 @@ uv run isort .
|
|
|
278
344
|
|
|
279
345
|
# Type checking
|
|
280
346
|
uv run mypy .
|
|
347
|
+
|
|
348
|
+
# Build the local UI bundle (needed for `fasteval ui` and HTML reports from a source checkout)
|
|
349
|
+
cd ui && npm ci && npm run build
|
|
281
350
|
```
|
|
282
351
|
|
|
283
352
|
## Documentation
|
|
@@ -287,18 +356,19 @@ Full documentation is available at **[fasteval.io](https://fasteval.io)**.
|
|
|
287
356
|
- [Getting Started](https://fasteval.io/docs/getting-started/quickstart) -- installation and quickstart guide
|
|
288
357
|
- [Why FastEval](https://fasteval.io/docs/getting-started/introduction/why-fasteval) -- motivation and design philosophy
|
|
289
358
|
- [Core Concepts](https://fasteval.io/docs/core-concepts/decorators) -- decorators, metrics, scoring, data sources
|
|
359
|
+
- [CLI & UI](https://fasteval.io/docs/cli/overview) -- `fasteval run`, profiles, tags, the local UI, prompt judges
|
|
290
360
|
- [Concepts](https://fasteval.io/docs/concepts/llm-as-judge) -- LLM-as-judge, scoring thresholds, evaluation strategies
|
|
291
361
|
- [LLM Metrics](https://fasteval.io/docs/llm-metrics/correctness) -- correctness, relevance, hallucination, and more
|
|
292
362
|
- [Deterministic Metrics](https://fasteval.io/docs/deterministic-metrics/exact-match) -- ROUGE, exact match, regex, JSON schema
|
|
293
363
|
- [RAG Metrics](https://fasteval.io/docs/rag-metrics/faithfulness) -- faithfulness, contextual precision/recall
|
|
294
|
-
- [Tool Trajectory](https://fasteval.io/docs/tool-
|
|
364
|
+
- [Tool Trajectory](https://fasteval.io/docs/tool-trajectory-metrics/tool-call-accuracy) -- tool call accuracy, sequence, argument matching
|
|
295
365
|
- [Conversation Metrics](https://fasteval.io/docs/conversation-metrics/context-retention) -- context retention, consistency, topic drift
|
|
296
366
|
- [Multi-Modal](https://fasteval.io/docs/multimodal/overview) -- vision, audio, image generation evaluation
|
|
297
367
|
- [Human Review](https://fasteval.io/docs/human-review/overview) -- human-in-the-loop evaluation
|
|
298
368
|
- [Cookbooks](https://fasteval.io/docs/cookbooks/rag-pipeline) -- RAG pipelines, CI/CD setup, prompt regression, production monitoring
|
|
299
369
|
- [Plugins](https://fasteval.io/docs/plugins/langfuse/overview) -- Langfuse, LangGraph, Observe
|
|
300
370
|
- [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
|
|
371
|
+
- [API Reference](https://fasteval.io/docs/api-reference/decorators) -- decorators, evaluator, models, score, [CLI and pytest options](https://fasteval.io/docs/api-reference/cli)
|
|
302
372
|
|
|
303
373
|
## Contributing
|
|
304
374
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
10
10
|
[](https://fasteval.io)
|
|
11
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).
|
|
12
|
+
A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Stack decorators to define evaluation criteria, run them with the `fasteval` CLI or plain pytest. [Read the docs](https://fasteval.io/docs).
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
15
15
|
<img src="hero-evaluation-journey.png" alt="The Evaluation Journey -- from non-deterministic LLM outputs to reliable engineering metrics" width="800">
|
|
@@ -19,6 +19,9 @@ A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Sta
|
|
|
19
19
|
|
|
20
20
|
- **50+ built-in metrics** -- stack `@fe.correctness`, `@fe.relevance`, `@fe.hallucination`, and more
|
|
21
21
|
- **pytest native** -- run evaluations with `pytest`, get familiar pass/fail output
|
|
22
|
+
- **`fasteval` CLI** -- `fasteval run` runs only your evals, with named profiles, tag selection, quality gates and run history
|
|
23
|
+
- **Local UI** -- watch runs live, inspect every case and judge prompt, re-run failures and compare runs; headless CI runs write a self-contained HTML report
|
|
24
|
+
- **Prompt judges and playground** -- tune an LLM judge's prompt against real cases, save it as `judges/<name>.toml`, use it with `@fe.prompt_judge()` or swap it in with `fasteval run --judge`
|
|
22
25
|
- **LLM-as-judge + deterministic** -- semantic LLM metrics alongside ROUGE, exact match, JSON schema, regex
|
|
23
26
|
- **Custom criteria** -- `@fe.criteria("Is the response empathetic?")` for any evaluation you can describe in plain English
|
|
24
27
|
- **Multi-modal** -- evaluate vision, audio, and image generation models
|
|
@@ -27,7 +30,8 @@ A **decorator-first LLM evaluation library** for testing AI agents and LLMs. Sta
|
|
|
27
30
|
- **Tool trajectory** -- verify agent tool calls, argument matching, call sequences
|
|
28
31
|
- **Reusable metric stacks** -- `@fe.stack()` to compose and reuse metric sets across tests
|
|
29
32
|
- **Human-in-the-loop** -- `@fe.human_review()` for manual review alongside automated metrics
|
|
30
|
-
- **Data-driven testing** -- `@fe.csv(
|
|
33
|
+
- **Data-driven testing** -- `@fe.dataset`, `@fe.csv()` and `@fe.jsonl()` turn every row or record into its own test case
|
|
34
|
+
- **Tags** -- `@fe.tag("smoke")` to label evals and select them with `fasteval run -t smoke` or `pytest -m smoke`
|
|
31
35
|
- **Pluggable providers** -- OpenAI (default), Anthropic, or bring your own `LLMClient`
|
|
32
36
|
|
|
33
37
|
## How It Works
|
|
@@ -62,10 +66,50 @@ def test_qa_agent():
|
|
|
62
66
|
|
|
63
67
|
Run it:
|
|
64
68
|
|
|
69
|
+
```bash
|
|
70
|
+
fasteval run test_qa_agent.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
From a terminal, the run opens live in your browser; in CI it runs headless and writes `.fasteval/report.html`. It's plain pytest underneath, so this works too:
|
|
74
|
+
|
|
65
75
|
```bash
|
|
66
76
|
pytest test_qa_agent.py -v
|
|
67
77
|
```
|
|
68
78
|
|
|
79
|
+
## Running Evals
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
fasteval # project status: config, profiles, last run
|
|
83
|
+
fasteval list # every eval with its tags, metrics and data source
|
|
84
|
+
fasteval run -t smoke # select by tag; unknown flags pass through to pytest
|
|
85
|
+
fasteval run -p ci # a named profile from [tool.fasteval.profiles]
|
|
86
|
+
fasteval run --lf -n auto # re-run failures, in parallel (pytest-xdist)
|
|
87
|
+
fasteval run --min-pass-rate 0.9 --min-score 0.75 # quality gates
|
|
88
|
+
fasteval run --judge correctness=my_judge # swap in a saved prompt judge
|
|
89
|
+
fasteval report --html --open # export the latest run as one HTML file
|
|
90
|
+
fasteval ui # run history, eval catalog, judges, playground
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Profiles keep run settings in `pyproject.toml`:
|
|
94
|
+
|
|
95
|
+
```toml
|
|
96
|
+
[tool.fasteval]
|
|
97
|
+
default_profile = "dev"
|
|
98
|
+
|
|
99
|
+
[tool.fasteval.profiles.dev]
|
|
100
|
+
paths = ["evals"]
|
|
101
|
+
tags = "not slow"
|
|
102
|
+
|
|
103
|
+
[tool.fasteval.profiles.ci]
|
|
104
|
+
extends = "dev"
|
|
105
|
+
tags = ""
|
|
106
|
+
review_prompts = false
|
|
107
|
+
headless = true
|
|
108
|
+
min_pass_rate = 0.9
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
See [The fasteval CLI](https://fasteval.io/docs/cli/overview) for details.
|
|
112
|
+
|
|
69
113
|
## Installation
|
|
70
114
|
|
|
71
115
|
```bash
|
|
@@ -158,6 +202,27 @@ def test_agent_tools():
|
|
|
158
202
|
)
|
|
159
203
|
```
|
|
160
204
|
|
|
205
|
+
### Data-Driven Evals
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
@fe.dataset
|
|
209
|
+
def support_questions():
|
|
210
|
+
yield {"id": "refund", "question": "How long do refunds take?", "expected": "Within 30 days"}
|
|
211
|
+
yield fe.case(id="hours", tags=["slow"], question="When is support open?", expected="9am to 6pm PT")
|
|
212
|
+
|
|
213
|
+
@support_questions
|
|
214
|
+
@fe.tag("rag")
|
|
215
|
+
@fe.correctness(threshold=0.7)
|
|
216
|
+
def test_support_answers(question, expected):
|
|
217
|
+
fe.score(agent(question), expected, input=question)
|
|
218
|
+
|
|
219
|
+
# One test case per CSV row: test_faq[<question>]
|
|
220
|
+
@fe.contains()
|
|
221
|
+
@fe.csv("evals/data/faq.csv", id_field="question")
|
|
222
|
+
def test_faq(question, expected):
|
|
223
|
+
fe.score(agent(question), expected, input=question)
|
|
224
|
+
```
|
|
225
|
+
|
|
161
226
|
### Multi-Turn Conversations
|
|
162
227
|
|
|
163
228
|
```python
|
|
@@ -228,6 +293,9 @@ uv run isort .
|
|
|
228
293
|
|
|
229
294
|
# Type checking
|
|
230
295
|
uv run mypy .
|
|
296
|
+
|
|
297
|
+
# Build the local UI bundle (needed for `fasteval ui` and HTML reports from a source checkout)
|
|
298
|
+
cd ui && npm ci && npm run build
|
|
231
299
|
```
|
|
232
300
|
|
|
233
301
|
## Documentation
|
|
@@ -237,18 +305,19 @@ Full documentation is available at **[fasteval.io](https://fasteval.io)**.
|
|
|
237
305
|
- [Getting Started](https://fasteval.io/docs/getting-started/quickstart) -- installation and quickstart guide
|
|
238
306
|
- [Why FastEval](https://fasteval.io/docs/getting-started/introduction/why-fasteval) -- motivation and design philosophy
|
|
239
307
|
- [Core Concepts](https://fasteval.io/docs/core-concepts/decorators) -- decorators, metrics, scoring, data sources
|
|
308
|
+
- [CLI & UI](https://fasteval.io/docs/cli/overview) -- `fasteval run`, profiles, tags, the local UI, prompt judges
|
|
240
309
|
- [Concepts](https://fasteval.io/docs/concepts/llm-as-judge) -- LLM-as-judge, scoring thresholds, evaluation strategies
|
|
241
310
|
- [LLM Metrics](https://fasteval.io/docs/llm-metrics/correctness) -- correctness, relevance, hallucination, and more
|
|
242
311
|
- [Deterministic Metrics](https://fasteval.io/docs/deterministic-metrics/exact-match) -- ROUGE, exact match, regex, JSON schema
|
|
243
312
|
- [RAG Metrics](https://fasteval.io/docs/rag-metrics/faithfulness) -- faithfulness, contextual precision/recall
|
|
244
|
-
- [Tool Trajectory](https://fasteval.io/docs/tool-
|
|
313
|
+
- [Tool Trajectory](https://fasteval.io/docs/tool-trajectory-metrics/tool-call-accuracy) -- tool call accuracy, sequence, argument matching
|
|
245
314
|
- [Conversation Metrics](https://fasteval.io/docs/conversation-metrics/context-retention) -- context retention, consistency, topic drift
|
|
246
315
|
- [Multi-Modal](https://fasteval.io/docs/multimodal/overview) -- vision, audio, image generation evaluation
|
|
247
316
|
- [Human Review](https://fasteval.io/docs/human-review/overview) -- human-in-the-loop evaluation
|
|
248
317
|
- [Cookbooks](https://fasteval.io/docs/cookbooks/rag-pipeline) -- RAG pipelines, CI/CD setup, prompt regression, production monitoring
|
|
249
318
|
- [Plugins](https://fasteval.io/docs/plugins/langfuse/overview) -- Langfuse, LangGraph, Observe
|
|
250
319
|
- [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
|
|
320
|
+
- [API Reference](https://fasteval.io/docs/api-reference/decorators) -- decorators, evaluator, models, score, [CLI and pytest options](https://fasteval.io/docs/api-reference/cli)
|
|
252
321
|
|
|
253
322
|
## Contributing
|
|
254
323
|
|
|
@@ -36,6 +36,8 @@ from fasteval.collectors import (
|
|
|
36
36
|
get_collector,
|
|
37
37
|
reset_collector,
|
|
38
38
|
)
|
|
39
|
+
from fasteval.core.api import evaluate, evaluate_async, register_metric
|
|
40
|
+
from fasteval.core.datasets import Case, Dataset, case, dataset
|
|
39
41
|
from fasteval.core.decorators import ( # LLM Metrics; Quality Metrics; RAG Metrics; Deterministic Metrics; Tool Trajectory; Conversation Metrics; Generic; Data Decorators; Human Review; Stack; Vision; Audio; Multi-Modal; Vision metrics; Audio metrics; Multi-modal metrics
|
|
40
42
|
aesthetic_score,
|
|
41
43
|
answer_correctness,
|
|
@@ -71,12 +73,14 @@ from fasteval.core.decorators import ( # LLM Metrics; Quality Metrics; RAG Metr
|
|
|
71
73
|
image_understanding,
|
|
72
74
|
instruction_following,
|
|
73
75
|
json,
|
|
76
|
+
jsonl,
|
|
74
77
|
judge,
|
|
75
78
|
match_error_rate,
|
|
76
79
|
metric,
|
|
77
80
|
multimodal_faithfulness,
|
|
78
81
|
ocr_accuracy,
|
|
79
82
|
prompt_adherence,
|
|
83
|
+
prompt_judge,
|
|
80
84
|
regex,
|
|
81
85
|
relevance,
|
|
82
86
|
rouge,
|
|
@@ -84,6 +88,7 @@ from fasteval.core.decorators import ( # LLM Metrics; Quality Metrics; RAG Metr
|
|
|
84
88
|
speaker_diarization,
|
|
85
89
|
stack,
|
|
86
90
|
table_extraction,
|
|
91
|
+
tag,
|
|
87
92
|
tool_args_match,
|
|
88
93
|
tool_call_accuracy,
|
|
89
94
|
tool_sequence,
|
|
@@ -224,7 +229,17 @@ __all__ = [
|
|
|
224
229
|
# Human Review
|
|
225
230
|
"human_review",
|
|
226
231
|
# Metric Stack
|
|
232
|
+
"prompt_judge",
|
|
233
|
+
"jsonl",
|
|
227
234
|
"stack",
|
|
235
|
+
"dataset",
|
|
236
|
+
"evaluate",
|
|
237
|
+
"evaluate_async",
|
|
238
|
+
"register_metric",
|
|
239
|
+
"case",
|
|
240
|
+
"Dataset",
|
|
241
|
+
"Case",
|
|
242
|
+
"tag",
|
|
228
243
|
# Vision Metric Decorators
|
|
229
244
|
"image_understanding",
|
|
230
245
|
"ocr_accuracy",
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Project configuration and profiles for the fasteval CLI.
|
|
3
|
+
|
|
4
|
+
Configuration lives in ``pyproject.toml`` under ``[tool.fasteval]`` or in a
|
|
5
|
+
standalone ``fasteval.toml`` (same keys, no ``tool.fasteval`` prefix)::
|
|
6
|
+
|
|
7
|
+
[tool.fasteval]
|
|
8
|
+
default_profile = "dev"
|
|
9
|
+
|
|
10
|
+
# Tag registry. Tags are plain pytest markers; registering them here
|
|
11
|
+
# documents them and silences PytestUnknownMarkWarning.
|
|
12
|
+
[tool.fasteval.tags]
|
|
13
|
+
smoke = "Fast sanity evals, run on every change"
|
|
14
|
+
rag = "Retrieval quality"
|
|
15
|
+
slow = "Long-running or expensive evals"
|
|
16
|
+
|
|
17
|
+
[tool.fasteval.profiles.dev]
|
|
18
|
+
paths = ["evals"]
|
|
19
|
+
tags = "not slow"
|
|
20
|
+
|
|
21
|
+
[tool.fasteval.profiles.ci]
|
|
22
|
+
extends = "dev"
|
|
23
|
+
tags = "" # clear the inherited selection
|
|
24
|
+
review_prompts = false # never stop for human-review input
|
|
25
|
+
headless = true # no UI server; write a static report
|
|
26
|
+
workers = "auto"
|
|
27
|
+
outputs = ["json:.fasteval/results.json"] # headless runs also write .fasteval/report.html
|
|
28
|
+
min_pass_rate = 0.9
|
|
29
|
+
min_score = 0.75
|
|
30
|
+
env = { OPENAI_MODEL = "gpt-4o-mini" }
|
|
31
|
+
|
|
32
|
+
Inheritance via ``extends``: scalar and list values from the child replace
|
|
33
|
+
the parent's; ``env`` tables are merged.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
from __future__ import annotations
|
|
37
|
+
|
|
38
|
+
import difflib
|
|
39
|
+
import sys
|
|
40
|
+
from dataclasses import dataclass, field, fields
|
|
41
|
+
from pathlib import Path
|
|
42
|
+
from typing import Any, Dict, List, Optional, Union
|
|
43
|
+
|
|
44
|
+
if sys.version_info >= (3, 11):
|
|
45
|
+
import tomllib
|
|
46
|
+
else: # pragma: no cover - exercised only on 3.10
|
|
47
|
+
import tomli as tomllib
|
|
48
|
+
|
|
49
|
+
PYPROJECT = "pyproject.toml"
|
|
50
|
+
FASTEVAL_TOML = "fasteval.toml"
|
|
51
|
+
DEFAULT_PROFILE = "default"
|
|
52
|
+
|
|
53
|
+
_TOP_LEVEL_KEYS = {"default_profile", "tags", "profiles", "judges_dir", "judge_client"}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ConfigError(Exception):
|
|
57
|
+
"""Raised for invalid fasteval configuration."""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass
|
|
61
|
+
class Profile:
|
|
62
|
+
"""A named, fully-resolved set of run settings."""
|
|
63
|
+
|
|
64
|
+
name: str
|
|
65
|
+
description: str = ""
|
|
66
|
+
paths: List[str] = field(default_factory=list)
|
|
67
|
+
tags: Optional[str] = None
|
|
68
|
+
keyword: Optional[str] = None
|
|
69
|
+
workers: Optional[Union[int, str]] = None
|
|
70
|
+
outputs: List[str] = field(default_factory=list)
|
|
71
|
+
review_prompts: Optional[bool] = None
|
|
72
|
+
headless: Optional[bool] = None
|
|
73
|
+
min_score: Optional[float] = None
|
|
74
|
+
min_pass_rate: Optional[float] = None
|
|
75
|
+
env: Dict[str, str] = field(default_factory=dict)
|
|
76
|
+
pytest_args: List[str] = field(default_factory=list)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# Keys a profile table may contain (``extends`` is resolved, not stored).
|
|
80
|
+
PROFILE_KEYS = {f.name for f in fields(Profile)} - {"name"} | {"extends"}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class ProjectConfig:
|
|
85
|
+
"""Parsed ``[tool.fasteval]`` configuration for a project."""
|
|
86
|
+
|
|
87
|
+
root: Path
|
|
88
|
+
source: Optional[Path] = None
|
|
89
|
+
default_profile: Optional[str] = None
|
|
90
|
+
tags: Dict[str, str] = field(default_factory=dict)
|
|
91
|
+
profiles: Dict[str, Dict[str, Any]] = field(default_factory=dict)
|
|
92
|
+
judges_dir: Optional[str] = None
|
|
93
|
+
judge_client: Optional[str] = None
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def source_label(self) -> str:
|
|
97
|
+
return self.source.name if self.source else "built-in defaults"
|
|
98
|
+
|
|
99
|
+
def profile_names(self) -> List[str]:
|
|
100
|
+
names = list(self.profiles)
|
|
101
|
+
if DEFAULT_PROFILE not in names:
|
|
102
|
+
names.insert(0, DEFAULT_PROFILE)
|
|
103
|
+
return names
|
|
104
|
+
|
|
105
|
+
def default_profile_name(self) -> str:
|
|
106
|
+
return self.default_profile or DEFAULT_PROFILE
|
|
107
|
+
|
|
108
|
+
def resolve(self, name: Optional[str] = None) -> Profile:
|
|
109
|
+
"""Resolve a profile by name, applying ``extends`` inheritance."""
|
|
110
|
+
name = name or self.default_profile_name()
|
|
111
|
+
merged = self._merge_chain(name, [])
|
|
112
|
+
merged.pop("extends", None)
|
|
113
|
+
profile = Profile(name=name, **merged)
|
|
114
|
+
profile.paths = [self._resolve_path(p) for p in profile.paths]
|
|
115
|
+
return profile
|
|
116
|
+
|
|
117
|
+
def _merge_chain(self, name: str, seen: List[str]) -> Dict[str, Any]:
|
|
118
|
+
if name in seen:
|
|
119
|
+
chain = " -> ".join(seen + [name])
|
|
120
|
+
raise ConfigError(f"Profile inheritance cycle: {chain}")
|
|
121
|
+
if name not in self.profiles:
|
|
122
|
+
if name == DEFAULT_PROFILE:
|
|
123
|
+
return {}
|
|
124
|
+
raise ConfigError(
|
|
125
|
+
f"Unknown profile {name!r}."
|
|
126
|
+
+ _did_you_mean(name, self.profile_names())
|
|
127
|
+
+ f" Available: {', '.join(self.profile_names())}"
|
|
128
|
+
)
|
|
129
|
+
raw = dict(self.profiles[name])
|
|
130
|
+
parent_name = raw.get("extends")
|
|
131
|
+
if not parent_name:
|
|
132
|
+
return raw
|
|
133
|
+
parent = self._merge_chain(parent_name, seen + [name])
|
|
134
|
+
env = {**parent.get("env", {}), **raw.get("env", {})}
|
|
135
|
+
merged = {**parent, **raw}
|
|
136
|
+
if env:
|
|
137
|
+
merged["env"] = env
|
|
138
|
+
return merged
|
|
139
|
+
|
|
140
|
+
def _resolve_path(self, path: str) -> str:
|
|
141
|
+
p = Path(path)
|
|
142
|
+
if p.is_absolute():
|
|
143
|
+
return path
|
|
144
|
+
# Keep pytest node ids (path::test) intact while anchoring at root.
|
|
145
|
+
return str(self.root / path)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def find_config(start: Optional[Path] = None) -> ProjectConfig:
|
|
149
|
+
"""
|
|
150
|
+
Locate and load configuration, walking up from ``start`` (default: cwd).
|
|
151
|
+
|
|
152
|
+
The first directory containing ``fasteval.toml`` or ``pyproject.toml``
|
|
153
|
+
is the project root. If none is found, ``start`` is the root and
|
|
154
|
+
built-in defaults apply.
|
|
155
|
+
"""
|
|
156
|
+
start = (start or Path.cwd()).resolve()
|
|
157
|
+
for directory in [start, *start.parents]:
|
|
158
|
+
fe_toml = directory / FASTEVAL_TOML
|
|
159
|
+
if fe_toml.is_file():
|
|
160
|
+
return _from_table(directory, fe_toml, _read_toml(fe_toml))
|
|
161
|
+
pyproject = directory / PYPROJECT
|
|
162
|
+
if pyproject.is_file():
|
|
163
|
+
table = _read_toml(pyproject).get("tool", {}).get("fasteval")
|
|
164
|
+
if table is None:
|
|
165
|
+
return ProjectConfig(root=directory)
|
|
166
|
+
return _from_table(directory, pyproject, table)
|
|
167
|
+
return ProjectConfig(root=start)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def load_tag_registry(root: Path) -> Dict[str, str]:
|
|
171
|
+
"""
|
|
172
|
+
Read only the tag registry for ``root``. Used by the pytest plugin, so it
|
|
173
|
+
never raises for problems unrelated to tags.
|
|
174
|
+
"""
|
|
175
|
+
try:
|
|
176
|
+
config = find_config(root)
|
|
177
|
+
except ConfigError:
|
|
178
|
+
return {}
|
|
179
|
+
return config.tags
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _read_toml(path: Path) -> Dict[str, Any]:
|
|
183
|
+
try:
|
|
184
|
+
with path.open("rb") as f:
|
|
185
|
+
return tomllib.load(f)
|
|
186
|
+
except tomllib.TOMLDecodeError as e:
|
|
187
|
+
raise ConfigError(f"Invalid TOML in {path}: {e}") from e
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _from_table(root: Path, source: Path, table: Dict[str, Any]) -> ProjectConfig:
|
|
191
|
+
where = (
|
|
192
|
+
f"{source.name} [tool.fasteval]" if source.name == PYPROJECT else source.name
|
|
193
|
+
)
|
|
194
|
+
_check_keys(table, _TOP_LEVEL_KEYS, where)
|
|
195
|
+
|
|
196
|
+
tags = table.get("tags", {})
|
|
197
|
+
if not isinstance(tags, dict) or not all(isinstance(v, str) for v in tags.values()):
|
|
198
|
+
raise ConfigError(f"{where}: 'tags' must be a table of name = \"description\"")
|
|
199
|
+
|
|
200
|
+
profiles = table.get("profiles", {})
|
|
201
|
+
if not isinstance(profiles, dict):
|
|
202
|
+
raise ConfigError(f"{where}: 'profiles' must be a table")
|
|
203
|
+
for name, body in profiles.items():
|
|
204
|
+
if not isinstance(body, dict):
|
|
205
|
+
raise ConfigError(f"{where}: profile {name!r} must be a table")
|
|
206
|
+
_validate_profile(name, body, f"{where} profiles.{name}")
|
|
207
|
+
|
|
208
|
+
default = table.get("default_profile")
|
|
209
|
+
if default is not None and default != DEFAULT_PROFILE and default not in profiles:
|
|
210
|
+
raise ConfigError(
|
|
211
|
+
f"{where}: default_profile {default!r} is not defined."
|
|
212
|
+
+ _did_you_mean(default, list(profiles))
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
for key in ("judges_dir", "judge_client"):
|
|
216
|
+
if key in table and not isinstance(table[key], str):
|
|
217
|
+
raise ConfigError(f"{where}: '{key}' must be a string")
|
|
218
|
+
judge_client = table.get("judge_client")
|
|
219
|
+
if judge_client is not None and ":" not in judge_client:
|
|
220
|
+
raise ConfigError(
|
|
221
|
+
f"{where}: 'judge_client' must look like 'package.module:attribute'"
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
return ProjectConfig(
|
|
225
|
+
root=root,
|
|
226
|
+
source=source,
|
|
227
|
+
default_profile=default,
|
|
228
|
+
tags=dict(tags),
|
|
229
|
+
profiles={k: dict(v) for k, v in profiles.items()},
|
|
230
|
+
judges_dir=table.get("judges_dir"),
|
|
231
|
+
judge_client=judge_client,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def _validate_profile(name: str, body: Dict[str, Any], where: str) -> None:
|
|
236
|
+
_check_keys(body, PROFILE_KEYS, where)
|
|
237
|
+
|
|
238
|
+
def expect(key: str, types: tuple, label: str) -> None:
|
|
239
|
+
if key in body and not isinstance(body[key], types):
|
|
240
|
+
raise ConfigError(f"{where}: '{key}' must be {label}")
|
|
241
|
+
|
|
242
|
+
def expect_str_list(key: str) -> None:
|
|
243
|
+
value = body.get(key)
|
|
244
|
+
if value is not None and (
|
|
245
|
+
not isinstance(value, list) or not all(isinstance(v, str) for v in value)
|
|
246
|
+
):
|
|
247
|
+
raise ConfigError(f"{where}: '{key}' must be a list of strings")
|
|
248
|
+
|
|
249
|
+
for key in ("description", "tags", "keyword", "extends"):
|
|
250
|
+
expect(key, (str,), "a string")
|
|
251
|
+
expect("review_prompts", (bool,), "true or false")
|
|
252
|
+
expect("headless", (bool,), "true or false")
|
|
253
|
+
for key in ("paths", "outputs", "pytest_args"):
|
|
254
|
+
expect_str_list(key)
|
|
255
|
+
|
|
256
|
+
workers = body.get("workers")
|
|
257
|
+
if workers is not None and not (
|
|
258
|
+
(isinstance(workers, int) and not isinstance(workers, bool) and workers >= 0)
|
|
259
|
+
or workers in ("auto", "logical")
|
|
260
|
+
):
|
|
261
|
+
raise ConfigError(f"{where}: 'workers' must be a non-negative int or \"auto\"")
|
|
262
|
+
|
|
263
|
+
for key in ("min_score", "min_pass_rate"):
|
|
264
|
+
value = body.get(key)
|
|
265
|
+
if value is not None and (
|
|
266
|
+
isinstance(value, bool)
|
|
267
|
+
or not isinstance(value, (int, float))
|
|
268
|
+
or not 0.0 <= value <= 1.0
|
|
269
|
+
):
|
|
270
|
+
raise ConfigError(f"{where}: '{key}' must be a number between 0 and 1")
|
|
271
|
+
|
|
272
|
+
env = body.get("env")
|
|
273
|
+
if env is not None and (
|
|
274
|
+
not isinstance(env, dict) or not all(isinstance(v, str) for v in env.values())
|
|
275
|
+
):
|
|
276
|
+
raise ConfigError(f"{where}: 'env' must be a table of string values")
|
|
277
|
+
|
|
278
|
+
for spec in body.get("outputs", []):
|
|
279
|
+
fmt, _, path = spec.partition(":")
|
|
280
|
+
if not fmt or not path:
|
|
281
|
+
raise ConfigError(
|
|
282
|
+
f"{where}: output {spec!r} must look like 'json:path' or 'html:path'"
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def _check_keys(table: Dict[str, Any], allowed: set, where: str) -> None:
|
|
287
|
+
for key in table:
|
|
288
|
+
if key not in allowed:
|
|
289
|
+
raise ConfigError(
|
|
290
|
+
f"{where}: unknown key {key!r}." + _did_you_mean(key, sorted(allowed))
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def _did_you_mean(word: str, options: List[str]) -> str:
|
|
295
|
+
match = difflib.get_close_matches(word, options, n=1)
|
|
296
|
+
return f" Did you mean {match[0]!r}?" if match else ""
|