mistralai-workflows-plugins-evaluations 0.5.0__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.
Files changed (43) hide show
  1. mistralai_workflows_plugins_evaluations-0.5.0/.gitignore +32 -0
  2. mistralai_workflows_plugins_evaluations-0.5.0/CHANGELOG.md +167 -0
  3. mistralai_workflows_plugins_evaluations-0.5.0/LICENSE +190 -0
  4. mistralai_workflows_plugins_evaluations-0.5.0/Makefile +18 -0
  5. mistralai_workflows_plugins_evaluations-0.5.0/PKG-INFO +21 -0
  6. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/getting-started/_category_.json +8 -0
  7. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/getting-started/installation.mdx +82 -0
  8. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/getting-started/introduction.mdx +140 -0
  9. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/_category_.json +8 -0
  10. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/basic-evaluation.mdx +221 -0
  11. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/building-blocks.mdx +124 -0
  12. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/context-objects.mdx +96 -0
  13. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/goals.mdx +80 -0
  14. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/local-mode.mdx +56 -0
  15. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/migrating.mdx +206 -0
  16. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/optimization.mdx +310 -0
  17. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/run-evaluators.mdx +77 -0
  18. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/guides/task-modes.mdx +77 -0
  19. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/reference/_category_.json +8 -0
  20. mistralai_workflows_plugins_evaluations-0.5.0/docs/docs/reference/api-reference.mdx +272 -0
  21. mistralai_workflows_plugins_evaluations-0.5.0/docs/sidebars.js +24 -0
  22. mistralai_workflows_plugins_evaluations-0.5.0/docs/test_doc_examples.py +323 -0
  23. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/__init__.py +136 -0
  24. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_activities.py +705 -0
  25. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_decorators.py +259 -0
  26. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_interceptor.py +81 -0
  27. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_models.py +21 -0
  28. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_optimize.py +545 -0
  29. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_orchestrator.py +976 -0
  30. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_record_workflow.py +432 -0
  31. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/_score_normalization.py +25 -0
  32. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/py.typed +0 -0
  33. mistralai_workflows_plugins_evaluations-0.5.0/mistralai/workflows/plugins/evaluations/types.py +44 -0
  34. mistralai_workflows_plugins_evaluations-0.5.0/pyproject.toml +110 -0
  35. mistralai_workflows_plugins_evaluations-0.5.0/tasks.py +69 -0
  36. mistralai_workflows_plugins_evaluations-0.5.0/tests/__init__.py +0 -0
  37. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_decorators.py +202 -0
  38. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_normalize_score.py +41 -0
  39. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_optimization_activities.py +202 -0
  40. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_orchestrator_record_concurrency.py +45 -0
  41. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_record_workflow_uploads.py +296 -0
  42. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_setup_run_activity.py +145 -0
  43. mistralai_workflows_plugins_evaluations-0.5.0/tests/test_temporal_detection.py +24 -0
@@ -0,0 +1,32 @@
1
+ # python sdk
2
+ build
3
+ *.egg-info
4
+ *.egg
5
+
6
+ # Env files
7
+ .env
8
+ .env.*
9
+ !.env.example
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+ .pytest_cache/
16
+ .coverage
17
+ htmlcov/
18
+
19
+ # IDEs
20
+ .idea/
21
+ .vscode/
22
+ *.swp
23
+ *.swo
24
+
25
+ # docs
26
+ docs/node_modules/**
27
+ docs/.docusaurus/**
28
+ docs/pnpm-lock.yaml
29
+ .docs.temporal.io/
30
+
31
+ #test
32
+ /.test_durations
@@ -0,0 +1,167 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ### Breaking
6
+
7
+ - **Direction moved from `Goal` to the evaluator.** `Goal.higher_is_better()` and `Goal.lower_is_better()` are removed, and `Goal` no longer carries a direction — it's a pure gate. Set `direction="maximize"` / `"minimize"` on the `Evaluator`/`RunEvaluator` instead (or rely on inference from a `gte`/`lte` goal). See [Migrating](docs/docs/guides/migrating.mdx).
8
+
9
+ ```python
10
+ # Before
11
+ Evaluator(name="latency", scorer=latency_scorer, goal=Goal.lower_is_better())
12
+ # After
13
+ Evaluator(name="latency", scorer=latency_scorer, direction="minimize")
14
+ ```
15
+
16
+ **Default direction is `maximize`.** An unset direction with no `lte` goal resolves to higher-is-better. Staying on an older plugin means evaluators are sent without a direction, so minimize-metrics (latency, cost…) are treated as maximize — upgrade and set `direction="minimize"`.
17
+
18
+ - **`MutatorProposal` fields renamed** (custom mutators only). `overrides` → `changed`, `reasoning` → `hypothesis`. If you write a `GEPA(mutator=...)`, return the new field names — an un-updated mutator fails silently.
19
+
20
+ ```python
21
+ # Before
22
+ return MutatorProposal(overrides={"temperature": 0.2}, reasoning="cooler decoding")
23
+ # After
24
+ return MutatorProposal(changed={"temperature": 0.2}, hypothesis="cooler decoding")
25
+ ```
26
+
27
+ - **`optimize()` return type redesigned.** `evaluation.optimize()` now returns the new `OptimizeResult` (was `OptimizationResult`): `optimized` → `winner` (plus `best_attempt`), `improved`/`improvement` → `verdict` + `winner.gain`, `candidates` → `trajectory`. Update code that reads the result; calling `optimize()` is unchanged.
28
+
29
+ ### Added
30
+
31
+ - **Optimizer v0 persistence & trials.** Optimizations and their trials are now persisted (create-first, with a detail link back to AI Studio); each run's objective and spec are persisted alongside. Includes weighted evaluators and score normalization.
32
+
33
+ - **Metadata callbacks** for runs and records, plus `beta.update_run` for post-hoc run metadata updates.
34
+
35
+ - **Metric semantics on evaluators.** `Evaluator` accepts `direction`, `weight`, `min_value`, `max_value`; `RunEvaluator` accepts `direction`, `min_value`, `max_value` (no `weight` — run evaluators aren't part of the optimizer objective). These are persisted per-evaluator and drive AI Studio's comparison colouring and score-graph bounds.
36
+
37
+ ### Fixed
38
+
39
+ - **Raise the `mistralai-evaluations` floor to `>=0.6.0`.** The plugin now imports SDK symbols introduced in 0.6.0 (metric-semantics on evaluators, optimization result models, run/record metadata contexts, create/patch optimization endpoints). Resolving this plugin against an older SDK raised `ImportError` on load.
40
+
41
+ - Raise the `mistralai-workflows` floor to `>=3.8.0`. Since 0.3.0 the plugin contributes the `eval-record` child workflow to the worker via the `get_worker_interceptors` hook, but forwarding plugin-contributed workflows to the registration payload only landed in core 3.8.0. Resolving this plugin against an older core produced a worker that *ran* `eval-record` without ever registering it, so every event it emitted was rejected by the API and its runs never appeared in run history.
42
+
43
+ ## 0.3.0
44
+
45
+ ### Breaking
46
+
47
+ - **Workflow-as-task param contract changed.** When using a workflow class as the task, the entrypoint now receives a serialized `TaskContext` (`{"input_record": ..., "system": ..., "metadata": ...}`) instead of `params = <input_record>` directly.
48
+
49
+ ```python
50
+ # Before
51
+ @workflow.define(name="my-task")
52
+ class MyTask:
53
+ @workflow.entrypoint
54
+ async def run(self, params: dict) -> str:
55
+ text = params["text"] # params WAS the input record
56
+ ...
57
+
58
+ # After
59
+ @workflow.define(name="my-task")
60
+ class MyTask:
61
+ @workflow.entrypoint
62
+ async def run(self, params: dict) -> str:
63
+ # params is a serialized TaskContext
64
+ input_record = params["input_record"]
65
+ system = params.get("system")
66
+ metadata = params.get("metadata")
67
+ text = input_record["text"]
68
+ ...
69
+
70
+ # Or, for typed access:
71
+ ctx = TaskContext.model_validate(params)
72
+ text = ctx.input_record["text"]
73
+ ```
74
+
75
+ ### Added
76
+
77
+ - **`TaskContext` and `ScorerContext` context objects.** New typed context objects that bundle all inputs for eval callbacks. Detected via type annotation — legacy positional-arg signatures still work unchanged.
78
+
79
+ ```python
80
+ from mistralai.workflows.plugins.evaluations.types import TaskContext, ScorerContext, Score
81
+
82
+ # New style — access to system, metadata, and more
83
+ @evaluation.task
84
+ async def my_task(context: TaskContext) -> str:
85
+ prompt = context.system.params["system_prompt"]
86
+ verbose = context.metadata.get("verbose", False)
87
+ return context.input_record["text"]
88
+
89
+ @evaluation.scorer
90
+ async def judge(context: ScorerContext) -> Score:
91
+ model = context.system.params["judge_model"]
92
+ return Score(value=score_output(context.output, model))
93
+
94
+ # Legacy style — still works, no changes needed
95
+ @evaluation.task
96
+ async def my_task(input_record: dict) -> str: ...
97
+
98
+ @evaluation.scorer
99
+ async def accuracy(input_record: dict, output: str) -> Score: ...
100
+ ```
101
+
102
+ - `TaskContext`, `ScorerContext` re-exported from `mistralai.workflows.plugins.evaluations.types`.
103
+
104
+ - **Goal support.** `Evaluator` and `RunEvaluator` `goal` / `aggregate_goal` fields are now forwarded to the backend when creating evaluation runs. Use `Goal.gte()`, `Goal.lte()`, `Goal.between()`, etc.
105
+
106
+ ```python
107
+ from mistralai.workflows.plugins.evaluations.types import Evaluator, Goal
108
+
109
+ Evaluator(name="accuracy", scorer=my_scorer, goal=Goal.gte(0.8))
110
+ Evaluator(name="quality", scorer=my_scorer, aggregate_goal=Goal.between(0.5, 1.0))
111
+ ```
112
+
113
+ - `Goal` and `GoalSpec` re-exported from `mistralai.workflows.plugins.evaluations.types`.
114
+
115
+ - **System & metadata passthrough.** `system` and `metadata` from `evaluation.run()` are now forwarded to tasks, scorers, and run evaluators:
116
+ - Activity tasks: via `TaskContext` (new) or as a second positional arg (legacy)
117
+ - Scorers: via `ScorerContext` (new) — legacy scorers don't receive them
118
+ - Workflow-as-task: via the serialized `TaskContext` params dict
119
+ - `RunEvaluatorContext.system` new field
120
+
121
+ - **Metadata forwarded to run evaluators in local mode.** `metadata` passed to `evaluation.run()` is now correctly forwarded to `RunEvaluatorContext.metadata` when `local=True`.
122
+
123
+ ## 0.2.0
124
+
125
+ ### Breaking
126
+
127
+ - **`start_to_close_timeout` removed** from `@evaluation.task`, `@evaluation.scorer`, and `@evaluation.run_scorer`. Use `execution_timeout` instead, which aligns with the `@workflow.define` convention.
128
+
129
+ ```python
130
+ # Before
131
+ @evaluation.task(start_to_close_timeout=timedelta(minutes=30))
132
+ @evaluation.scorer(start_to_close_timeout=timedelta(minutes=10))
133
+
134
+ # After
135
+ @evaluation.task(execution_timeout=timedelta(minutes=30))
136
+ @evaluation.scorer(execution_timeout=timedelta(minutes=10))
137
+ ```
138
+
139
+ - **Default timeouts and retries lowered.** Previous defaults were too generous for typical LLM evaluation workloads (a single API call rarely needs 10 minutes or 3 retries). If your tasks or scorers need more time, override explicitly.
140
+
141
+ | Decorator | `execution_timeout` | `retry_policy_max_attempts` |
142
+ |---|---|---|
143
+ | `@evaluation.task` | 10min → **2min** | 3 → **2** |
144
+ | `@evaluation.scorer` | 5min → **1min** | 3 → **2** |
145
+ | `@evaluation.run_scorer` | 5min → **1min** | 3 → **2** |
146
+
147
+ - **`max_concurrent_tasks` and `max_concurrent_scorers` removed** from `evaluation.run()` and `evaluation.score()`. Use `max_concurrency` on the decorators instead.
148
+
149
+ ```python
150
+ # Before
151
+ await evaluation.run(dataset=..., task=my_task, evaluators=..., max_concurrent_tasks=10, max_concurrent_scorers=3)
152
+
153
+ # After
154
+ @evaluation.task(max_concurrency=10)
155
+ async def my_task(input: dict) -> dict: ...
156
+
157
+ @evaluation.scorer(max_concurrency=3)
158
+ async def my_scorer(input: dict, output: Any) -> Score: ...
159
+
160
+ await evaluation.run(dataset=..., task=my_task, evaluators=...)
161
+ ```
162
+
163
+ ### Added
164
+
165
+ - `execution_timeout` on `eval-record` child workflows — auto-computed from task and scorer timeouts, retries, and a 60s buffer. Prevents a single hanging record from blocking the entire evaluation run.
166
+ - `execution_timeout` on task child workflows (workflow mode) — uses the task's declared `@workflow.define(execution_timeout=...)` instead of a hardcoded 600s.
167
+ - `max_concurrency` parameter on `@evaluation.task`, `@evaluation.scorer`, and `@evaluation.run_scorer` decorators (default: 5). Concurrency config now lives alongside timeouts and retries on the decorators, instead of being passed to `run()`.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Mistral AI
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,18 @@
1
+ .PHONY: lint format typecheck test installdeps
2
+
3
+ lint:
4
+ uv run ruff format --check .
5
+ uv run ruff check .
6
+
7
+ format:
8
+ uv run ruff check --fix .
9
+ uv run ruff format .
10
+
11
+ typecheck:
12
+ uv run mypy mistralai/
13
+
14
+ test:
15
+ uv run pytest tests/ -v
16
+
17
+ installdeps:
18
+ uv sync
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.5
2
+ Name: mistralai-workflows-plugins-evaluations
3
+ Version: 0.5.0
4
+ Summary: Evaluation plugin for Mistral Workflows - run evaluations as parallel Temporal activities
5
+ Project-URL: Homepage, https://mistral.ai
6
+ Project-URL: Documentation, https://docs.mistral.ai/workflows
7
+ Author-email: Mistral AI <support@mistral.ai>
8
+ License: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: ai,evaluation,mistral,observability,plugin,workflows
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: <3.15,>=3.12
19
+ Requires-Dist: mistralai-evaluations>=0.6.0
20
+ Requires-Dist: mistralai-workflows<4.0.0,>=3.8.0
21
+ Requires-Dist: structlog<26,>=24
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Getting Started",
3
+ "position": 1,
4
+ "link": {
5
+ "type": "generated-index",
6
+ "description": "Get up and running with the Workflow Evaluation Plugin"
7
+ }
8
+ }
@@ -0,0 +1,82 @@
1
+ ---
2
+ id: installation
3
+ sidebar_label: Installation
4
+ title: Installation
5
+ sidebar_position: 2
6
+ ---
7
+
8
+ ## Prerequisites
9
+
10
+ - Python 3.12+
11
+ - [uv](https://docs.astral.sh/uv/) for dependency management
12
+ - A Mistral API key
13
+ - A working [Mistral Workflows](/workflows/) setup
14
+ - Access to the Mistral private package registry (Gemfury)
15
+
16
+ ## Install
17
+
18
+ Create a new project:
19
+
20
+ ```bash
21
+ uv init my-eval-workflow
22
+ cd my-eval-workflow
23
+ ```
24
+
25
+ Add the plugin to your `pyproject.toml`:
26
+
27
+ ```toml
28
+ [project]
29
+ name = "my-eval-workflow"
30
+ version = "0.1.0"
31
+ dependencies = [
32
+ "mistralai",
33
+ "mistralai-workflows[mistralai]",
34
+ "mistralai-workflows-plugins-evaluations>=0.1.0",
35
+ ]
36
+
37
+ [[tool.uv.index]]
38
+ name = "gemfury"
39
+ url = "https://pypi.fury.io/mistralai/"
40
+
41
+ [tool.uv]
42
+ exclude-newer = "7 days"
43
+ exclude-newer-package = {
44
+ "mistralai-workflows-plugins-evaluations" = false,
45
+ "mistralai-evaluations" = false,
46
+ "mistralai" = false,
47
+ "mistralai-workflows" = false,
48
+ }
49
+
50
+ [tool.uv.sources]
51
+ mistralai-workflows-plugins-evaluations = { index = "gemfury" }
52
+ ```
53
+
54
+ Then install:
55
+
56
+ ```bash
57
+ uv sync
58
+ ```
59
+
60
+ :::tip Gemfury credentials
61
+ Make sure Gemfury credentials are set in your `.zshrc` / `.bashrc`. If you don't have them yet, see the internal Gemfury setup guide.
62
+ :::
63
+
64
+ ## Environment variables
65
+
66
+ | Variable | Required | Description |
67
+ |----------|----------|-------------|
68
+ | `MISTRAL_API_KEY` | Yes | Your Mistral API key for model calls and AI Studio uploads |
69
+ | `DEPLOYMENT_NAME` | Yes | Your workflow deployment name |
70
+
71
+ ```bash
72
+ export MISTRAL_API_KEY=<your-api-key>
73
+ export DEPLOYMENT_NAME=my-eval-workflow
74
+ ```
75
+
76
+ ## Verify installation
77
+
78
+ ```python
79
+ from mistralai.workflows.plugins.evaluations import evaluation
80
+ from mistralai.workflows.plugins.evaluations.types import Evaluator, Score
81
+ print("Plugin installed successfully!")
82
+ ```
@@ -0,0 +1,140 @@
1
+ ---
2
+ id: introduction
3
+ sidebar_label: Introduction
4
+ title: Workflow Evaluation Plugin
5
+ sidebar_position: 1
6
+ slug: /
7
+ ---
8
+
9
+ :::caution Internal Use Only
10
+ This plugin is available for Mistral teams but **not for external clients yet**. The product is under active development — share your feedback on [#eng-offline-evaluations](https://mistralai.slack.com/archives/C0AGP0NVA67).
11
+ :::
12
+
13
+ The Workflow Evaluation Plugin (`mistralai-workflows-plugins-evaluations`) lets you run evaluations inside [Mistral Workflows](/workflows/), with automatic parallel execution via Temporal. It provides the same `evaluation.run()` API as the [Evaluation SDK](/evaluation-sdk/), but splits task execution and scoring into parallel Temporal activities for scalable, production-grade evaluation pipelines.
14
+
15
+ ## Overview
16
+
17
+ The plugin follows the same mental model as the Evaluation SDK:
18
+
19
+ ```
20
+ Dataset --> Task --> Evaluators --> Results
21
+ ```
22
+
23
+ The key difference: instead of running everything in a single process, the plugin fans out each record as a **Temporal child workflow** that runs the task then the scorers in parallel. Results are uploaded to AI Studio automatically.
24
+
25
+ ## When to use this vs. the Evaluation SDK
26
+
27
+ | | Evaluation SDK | Workflow Evaluation Plugin |
28
+ |---|---|---|
29
+ | **Runs in** | Any Python script | A Mistral Workflow |
30
+ | **Parallelism** | `asyncio.gather` in one process | Temporal activities across workers |
31
+ | **Retries** | Manual | Automatic per-record via Temporal |
32
+ | **Failure isolation** | One failure can crash the run | Each record is isolated in a child workflow |
33
+ | **Best for** | Quick iteration, notebooks, CI scripts | Production pipelines, large datasets, complex tasks |
34
+
35
+ ## Quickstart
36
+
37
+ ### 1. Install
38
+
39
+ Add to your workflow project's `pyproject.toml`:
40
+
41
+ ```toml
42
+ [project]
43
+ dependencies = [
44
+ "mistralai",
45
+ "mistralai-workflows[mistralai]",
46
+ "mistralai-workflows-plugins-evaluations>=0.1.0",
47
+ ]
48
+
49
+ [[tool.uv.index]]
50
+ name = "gemfury"
51
+ url = "https://pypi.fury.io/mistralai/"
52
+
53
+ [tool.uv.sources]
54
+ mistralai-workflows-plugins-evaluations = { index = "gemfury" }
55
+ ```
56
+
57
+ Then install:
58
+
59
+ ```bash
60
+ uv sync
61
+ ```
62
+
63
+ ### 2. Write your first evaluation workflow
64
+
65
+ ```python
66
+ from mistralai.workflows import workflow
67
+ from mistralai.workflows.plugins.evaluations import evaluation
68
+ from mistralai.workflows.plugins.evaluations.types import (
69
+ Evaluator,
70
+ Goal,
71
+ Score,
72
+ ScorerContext,
73
+ System,
74
+ TaskContext,
75
+ )
76
+
77
+ dataset = [
78
+ {"prompt": "Say hello", "expected": "hello"},
79
+ {"prompt": "Say goodbye", "expected": "goodbye"},
80
+ ]
81
+
82
+ @evaluation.task
83
+ async def my_task(ctx: TaskContext) -> str:
84
+ from mistralai.client import Mistral
85
+ import os
86
+
87
+ client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
88
+ resp = await client.chat.complete_async(
89
+ model=ctx.system.params["model"],
90
+ messages=[
91
+ {"role": "system", "content": ctx.system.params["system_prompt"]},
92
+ {"role": "user", "content": ctx.input_record["prompt"]},
93
+ ],
94
+ )
95
+ return str(resp.choices[0].message.content)
96
+
97
+ @evaluation.scorer
98
+ async def accuracy(ctx: ScorerContext) -> Score:
99
+ expected = ctx.input_record["expected"]
100
+ return Score(value=1 if expected in ctx.output.lower() else 0)
101
+
102
+ @workflow.define(name="my-evaluation")
103
+ class MyEvaluationWorkflow:
104
+ @workflow.entrypoint
105
+ async def run(self, params: dict) -> dict:
106
+ result = await evaluation.run(
107
+ dataset=dataset,
108
+ task=my_task,
109
+ evaluators=[Evaluator(
110
+ name="accuracy",
111
+ description="Checks if the expected word appears in the model output.",
112
+ scorer=accuracy,
113
+ goal=Goal.gte(0.8),
114
+ )],
115
+ system=System(name="default", params={
116
+ "model": "mistral-small-latest",
117
+ "system_prompt": "Reply with only the last word of the user's sentence.",
118
+ }),
119
+ tags=["workflow"],
120
+ local=True,
121
+ )
122
+ return result.model_dump()
123
+ ```
124
+
125
+ ### 3. Run it
126
+
127
+ Deploy and execute the workflow as you would any Mistral Workflow. Results appear in your terminal and in AI Studio.
128
+
129
+ ## Key features
130
+
131
+ - **Parallel execution** -- tasks and scorers run as concurrent Temporal activities with configurable concurrency
132
+ - **Failure isolation** -- each record runs in its own child workflow; one failure doesn't crash the run
133
+ - **Automatic retries** -- configurable retry policies per task and scorer
134
+ - **Two task modes** -- `@evaluation.task` (activity) or workflow-as-task (child workflow)
135
+ - **Context objects** -- `TaskContext` and `ScorerContext` give typed access to input, system params, and metadata
136
+ - **Goals** -- set pass/fail thresholds with `Goal.gte()`, `Goal.lte()`, `Goal.between()`
137
+ - **Run evaluators** -- compute aggregate metrics (F1, global accuracy) after all records complete
138
+ - **[Optimization](/workflow-evaluation/guides/optimization/)** -- automatically search for better prompts and parameters, with the loop running as a workflow
139
+ - **Local mode** -- `local=True` skips AI Studio uploads for fast iteration
140
+ - **AI Studio integration** -- results auto-upload with workflow cross-linking
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Guides",
3
+ "position": 2,
4
+ "link": {
5
+ "type": "generated-index",
6
+ "description": "Step-by-step guides for the Workflow Evaluation Plugin"
7
+ }
8
+ }