mloda-plugin-jev 0.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.
- mloda_plugin_jev-0.2.1/LICENSE +201 -0
- mloda_plugin_jev-0.2.1/PKG-INFO +80 -0
- mloda_plugin_jev-0.2.1/README.md +243 -0
- mloda_plugin_jev-0.2.1/README_PYPI.md +30 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/__init__.py +0 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/__main__.py +4 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/cli.py +714 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/feature_groups/__init__.py +1 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/feature_groups/decision/__init__.py +5 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/feature_groups/decision/frames.py +79 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/feature_groups/decision/jev_feature_group.py +483 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/feature_groups/manifest.py +8 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/mcp_server.py +314 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev/row_failure.py +17 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev.egg-info/PKG-INFO +80 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev.egg-info/SOURCES.txt +24 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev.egg-info/dependency_links.txt +1 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev.egg-info/entry_points.txt +6 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev.egg-info/requires.txt +31 -0
- mloda_plugin_jev-0.2.1/mloda_plugin_jev.egg-info/top_level.txt +1 -0
- mloda_plugin_jev-0.2.1/pyproject.toml +113 -0
- mloda_plugin_jev-0.2.1/setup.cfg +4 -0
- mloda_plugin_jev-0.2.1/tests/test_demo_notebooks.py +98 -0
- mloda_plugin_jev-0.2.1/tests/test_entry_points.py +72 -0
- mloda_plugin_jev-0.2.1/tests/test_package_config.py +118 -0
- mloda_plugin_jev-0.2.1/tests/test_reserved_namespace.py +103 -0
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mloda-plugin-jev
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: mloda plugin that runs Jev: typed answers about a text column as feature columns
|
|
5
|
+
Author-email: Tom Kaltofen <tomkaltofen@mloda.ai>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/mloda-ai/mloda-plugin-jev
|
|
8
|
+
Project-URL: Documentation, https://github.com/mloda-ai/mloda-plugin-jev#readme
|
|
9
|
+
Project-URL: Issues, https://github.com/mloda-ai/mloda-plugin-jev/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/mloda-ai/mloda-plugin-jev/releases
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: mloda<0.14.0,>=0.13.0
|
|
25
|
+
Requires-Dist: typesafe-sdk>=0.7.0
|
|
26
|
+
Requires-Dist: httpx2>=2.0.0
|
|
27
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11"
|
|
28
|
+
Provides-Extra: observability
|
|
29
|
+
Requires-Dist: mloda-community-otel>=0.4.7; extra == "observability"
|
|
30
|
+
Requires-Dist: mloda-community-openlineage>=0.4.7; extra == "observability"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: tox; extra == "dev"
|
|
33
|
+
Requires-Dist: tox-uv; extra == "dev"
|
|
34
|
+
Requires-Dist: uv>=0.11.6; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy; extra == "dev"
|
|
38
|
+
Requires-Dist: bandit; extra == "dev"
|
|
39
|
+
Requires-Dist: mloda-testing[openlineage,otel]>=0.4.7; extra == "dev"
|
|
40
|
+
Requires-Dist: pandas; extra == "dev"
|
|
41
|
+
Requires-Dist: polars; extra == "dev"
|
|
42
|
+
Requires-Dist: pyarrow; extra == "dev"
|
|
43
|
+
Provides-Extra: demo
|
|
44
|
+
Requires-Dist: marimo>=0.24.2; extra == "demo"
|
|
45
|
+
Provides-Extra: mcp
|
|
46
|
+
Requires-Dist: fastmcp>=4.0.3; extra == "mcp"
|
|
47
|
+
Requires-Dist: fastapi>=0.141.1; extra == "mcp"
|
|
48
|
+
Requires-Dist: uvicorn>=0.52.4; extra == "mcp"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# mloda-plugin-jev
|
|
52
|
+
|
|
53
|
+
An [mloda](https://github.com/mloda-ai/mloda) plugin that runs [Jev](https://docs.typesafe.ai) as a FeatureGroup: ask typed questions about a text column and get the answers back as feature columns.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install mloda-plugin-jev
|
|
59
|
+
export TYPESAFE_API_KEY=...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Example
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from mloda.user import Feature, Options, PluginLoader, mloda
|
|
66
|
+
from mloda_plugins.compute_framework.base_implementations.python_dict.python_dict_framework import PythonDictFramework
|
|
67
|
+
|
|
68
|
+
PluginLoader.all()
|
|
69
|
+
|
|
70
|
+
urgent = {"type": "noul", "instructions": "The message conveys urgency"}
|
|
71
|
+
|
|
72
|
+
result = mloda.run_all(
|
|
73
|
+
[Feature("ticket__jev_urgent", Options(context={"jev_question": urgent}))],
|
|
74
|
+
compute_frameworks={PythonDictFramework},
|
|
75
|
+
api_data={"Tickets": {"ticket": ["I was charged twice, please fix ASAP", "The login page is broken"]}},
|
|
76
|
+
)
|
|
77
|
+
print(result[0]["ticket__jev_urgent"]) # for example [0.97, 0.12]: the probability of yes per row
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The full documentation, including the `mloda` command line, is in the [README on GitHub](https://github.com/mloda-ai/mloda-plugin-jev#readme).
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
[](LICENSE)
|
|
2
|
+
[](https://github.com/mloda-ai/mloda)
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](https://github.com/mloda-ai/mloda-plugin-jev/actions/workflows/test.yml?query=branch%3Amain)
|
|
5
|
+
|
|
6
|
+
# mloda-plugin-jev
|
|
7
|
+
|
|
8
|
+
> An [mloda](https://github.com/mloda-ai/mloda) plugin that runs [Jev](https://docs.typesafe.ai) as a FeatureGroup: ask typed questions about a text column and get the answers back as feature columns.
|
|
9
|
+
|
|
10
|
+
Jev is TypeSafe AI's non-generative decision model. You give it text and typed questions, and it returns typed answers with probabilities instead of generated text. This plugin sends each row of a text column to Jev and turns every question into a result column.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Python 3.10 or newer.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install mloda-plugin-jev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The `observability` extra adds the [Observability](#observability) extenders: `pip install "mloda-plugin-jev[observability]"`. For the development version, use `pip install git+https://github.com/mloda-ai/mloda-plugin-jev`. To work on the code, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
21
|
+
|
|
22
|
+
Set your TypeSafe API key:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
export TYPESAFE_API_KEY=...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from mloda.user import Feature, Options, PluginLoader, mloda
|
|
32
|
+
from mloda_plugins.compute_framework.base_implementations.python_dict.python_dict_framework import PythonDictFramework
|
|
33
|
+
|
|
34
|
+
PluginLoader.all() # discover this plugin through its entry points
|
|
35
|
+
|
|
36
|
+
department = {
|
|
37
|
+
"type": "choice",
|
|
38
|
+
"instructions": "Which team should handle this?",
|
|
39
|
+
"criteria": {"billing": "Payments and invoices", "technical": "Bugs and outages"},
|
|
40
|
+
}
|
|
41
|
+
urgent = {"type": "noul", "instructions": "The message conveys urgency"}
|
|
42
|
+
|
|
43
|
+
result = mloda.run_all(
|
|
44
|
+
[
|
|
45
|
+
Feature("ticket__jev_department", Options(context={"jev_question": department})),
|
|
46
|
+
Feature("ticket__jev_urgent", Options(context={"jev_question": urgent})),
|
|
47
|
+
],
|
|
48
|
+
compute_frameworks={PythonDictFramework},
|
|
49
|
+
api_data={"Tickets": {"ticket": ["I was charged twice, please fix ASAP", "The login page is broken"]}},
|
|
50
|
+
column_ordering="request_order",
|
|
51
|
+
)
|
|
52
|
+
for name, values in result[0].items():
|
|
53
|
+
print(name, values)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For example, this prints one column per requested feature (the values come from Jev):
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
ticket__jev_department ['billing', 'technical']
|
|
60
|
+
ticket__jev_urgent [0.97, 0.12]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
A feature is named `<text_column>__jev_<question_name>`. The text column is the input feature, and the question goes in the `jev_question` context option in Jev's own shape. Null, empty and whitespace-only text stays `None` and makes no call.
|
|
64
|
+
|
|
65
|
+
| Question `type` | `criteria` | Result column | With `jev_details=True`, also |
|
|
66
|
+
| --- | --- | --- | --- |
|
|
67
|
+
| `choice` | Labels mapped to descriptions | The chosen label (`str`) | `~confidence` (`float`, 0 to 1) and `~probabilities` (label to probability) |
|
|
68
|
+
| `score` | A list of rubric level descriptions | The expected score (`float`, can fall between levels) | `~confidence` and `~probabilities` (level `"0"`, `"1"`, ... to probability) |
|
|
69
|
+
| `noul` | Optional descriptions of the yes and no outcomes | The probability of yes, 0 to 1 (`float`) | nothing: the value is a probability already |
|
|
70
|
+
|
|
71
|
+
`jev_details=True` adds the columns `ticket__jev_department~confidence` and `ticket__jev_department~probabilities` next to `ticket__jev_department`, from the same call, so a low confidence can send a row to a human. mloda returns them with the feature; they cannot be requested on their own. The probabilities are a dict per row (a struct in PyArrow and Polars).
|
|
72
|
+
|
|
73
|
+
The feature group runs on `PythonDictFramework`, `PandasDataFrame`, `PolarsDataFrame` and `PyArrowTable`, and returns the frame it was given with the result columns added: strings for `choice`, floats (`NaN` in pandas) for `score` and `noul`. Name the framework in `compute_frameworks`: without it, mloda picks one of those that are installed, so the result type depends on the environment.
|
|
74
|
+
|
|
75
|
+
See the Jev docs for [choice](https://docs.typesafe.ai/primitives/choice), [score](https://docs.typesafe.ai/primitives/score) and [noul](https://docs.typesafe.ai/primitives/noul).
|
|
76
|
+
|
|
77
|
+
Several features can share one question book instead of carrying a question each. `jev_questions` maps question names to questions, and the name in the feature picks the entry, so `ticket__jev_department` asks the question called `department`. A name the book does not hold fails when mloda resolves the feature, before any call. A feature's own `jev_question` wins over the book.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
book = Options(context={"jev_questions": {"department": department, "urgent": urgent}})
|
|
81
|
+
features = [Feature("ticket__jev_department", book), Feature("ticket__jev_urgent", book)]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Command line
|
|
85
|
+
|
|
86
|
+
Installing the package also installs a `mloda` command, and `uvx --from mloda-plugin-jev mloda --help` runs it without installing. The feature name is the whole interface:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
mloda ticket ticket__jev_urgent --file tickets.csv -o jev_questions:=@questions.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
With the data and the questions in a `mloda.toml`, that becomes `mloda ticket__jev_urgent`. See [docs/cli.md](docs/cli.md).
|
|
93
|
+
|
|
94
|
+
**This package installs the `mloda` and `mloda-mcp` commands.** They are plugin-agnostic and ship from here until mloda core has its own ([mloda#1592](https://github.com/mloda-ai/mloda/issues/1592)). Commands do not merge: another package that declares `mloda` overwrites it without a warning, and uninstalling either package removes it.
|
|
95
|
+
|
|
96
|
+
## MCP server
|
|
97
|
+
|
|
98
|
+
The `mcp` extra adds `mloda-mcp`, the same command as an [MCP](https://modelcontextprotocol.io) server for agents, built with FastMCP and FastAPI:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install '.[mcp]'
|
|
102
|
+
mloda-mcp --allow-option jev_question # http://127.0.0.1:8000/mcp
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
An agent lists the feature groups, explains a request for free, and runs it. Callers cannot name files, and they can set only the options you allow. There is no authentication, so read [docs/mcp.md](docs/mcp.md) before you expose it.
|
|
106
|
+
|
|
107
|
+
## Options
|
|
108
|
+
|
|
109
|
+
Every setting of the [`typesafe-sdk`](https://github.com/typesafe-ai/typesafe-sdk-python) client is an optional context option. Leave one out to use the SDK default.
|
|
110
|
+
|
|
111
|
+
| Option | SDK argument | What it does |
|
|
112
|
+
| --- | --- | --- |
|
|
113
|
+
| `jev_api_key` | `TypeSafeClient(api_key=)` | API key. Prefer the `TYPESAFE_API_KEY` environment variable, because option values show up in logs and reprs. |
|
|
114
|
+
| `jev_base_url` | `TypeSafeClient(base_url=)` | API root (environment variable `TYPESAFE_BASE_URL`). |
|
|
115
|
+
| `jev_headers` | `TypeSafeClient(headers=)` | Extra headers on every request. |
|
|
116
|
+
| `jev_transport` | `TypeSafeClient(transport=)` | Custom `httpx2` transport. Mutually exclusive with `jev_http_client`. |
|
|
117
|
+
| `jev_http_client` | `TypeSafeClient(http_client=)` | Custom `httpx2.Client`. |
|
|
118
|
+
| `jev_model` | `system_one(model=)` | Model name. Defaults to `jev-latest` (environment variable `TYPESAFE_DEFAULT_MODEL`). |
|
|
119
|
+
| `jev_retry` | `system_one(retry=)` | A `RetryPolicy` or a dict of its fields, for example `{"max_retries": 0}`. The SDK retries twice by default. |
|
|
120
|
+
| `jev_timeout` | `system_one(timeout=)` | Timeout in seconds, or an `httpx2.Timeout`. |
|
|
121
|
+
| `jev_extra_headers` | `system_one(extra_headers=)` | Extra headers for the call. |
|
|
122
|
+
| `jev_extra_body` | `system_one(extra_body=)` | Extra top-level request body fields. |
|
|
123
|
+
| `jev_on_error` | none, a plugin setting | `raise` (default) fails the run when a Jev call fails. `skip` leaves that row `None`, keeps the other rows' answers and emits a `RowFailureWarning`. |
|
|
124
|
+
| `jev_concurrency` | none, a plugin setting | Calls in flight at a time, default `1`. Rows keep their order. With `raise`, no new call starts after a failed one. |
|
|
125
|
+
| `jev_deduplicate` | none, a plugin setting | `True` sends identical texts once and gives each of their rows the answer. Off by default: Jev does not promise the same answer for the same text. Features that differ in it get separate calls. |
|
|
126
|
+
| `jev_details` | none, a plugin setting | `True` adds `~confidence` and `~probabilities` columns to a `choice` or `score` feature, see [Usage](#usage). |
|
|
127
|
+
|
|
128
|
+
Features that share a text column **and** the same settings are answered in one Jev call per row. Features with different settings (for example different models) get separate calls. `jev_concurrency` and `jev_details` do not split calls: a batch runs at the highest `jev_concurrency` of its features. On the command line, pass numbers and flags as JSON, for example `-o jev_concurrency:=8 -o jev_details:=true`: with plain `=` the value is a string, and the error names the option and what it expects.
|
|
129
|
+
|
|
130
|
+
A run that skips rows still reports success to the extenders, and `python -W error` turns the warning into a failure of the whole run, so collect it explicitly:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
import warnings
|
|
134
|
+
|
|
135
|
+
from mloda_plugin_jev.row_failure import RowFailureWarning
|
|
136
|
+
|
|
137
|
+
with warnings.catch_warnings(record=True) as caught:
|
|
138
|
+
warnings.simplefilter("always")
|
|
139
|
+
result = mloda.run_all(...) # the features carry jev_on_error="skip" in their context options
|
|
140
|
+
failed = [w.message for w in caught if isinstance(w.message, RowFailureWarning)] # .column, .rows (0-based), .reason
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Pin the model for stable results.** `jev-latest` is an alias that moves when a new release ships. At the time of writing it resolves to `jev-1.13.0`, so `jev_model="jev-1.13.0"` keeps results from changing under you.
|
|
144
|
+
|
|
145
|
+
## Observability
|
|
146
|
+
|
|
147
|
+
Jev runs work with the OpenTelemetry and OpenLineage extenders from [mloda-registry](https://github.com/mloda-ai/mloda-registry). The `observability` extra installs them (`mloda-community-otel` and `mloda-community-openlineage`). Add them to the `run_all` call from Usage:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from mloda.community.extenders.openlineage import OpenLineageExtender
|
|
151
|
+
from mloda.community.extenders.otel import OtelExtender
|
|
152
|
+
|
|
153
|
+
result = mloda.run_all(
|
|
154
|
+
..., # the arguments from Usage
|
|
155
|
+
function_extender={OtelExtender(use_sdk_defaults=True), OpenLineageExtender(use_sdk_defaults=True)},
|
|
156
|
+
)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`use_sdk_defaults=True` uses the global OpenTelemetry tracer provider and OpenLineage's own configuration (for example `OPENLINEAGE_URL` or `OPENLINEAGE_CONFIG`). You can inject `tracer_provider=` or `client=` instead. With neither, the extender does nothing and logs a warning.
|
|
160
|
+
|
|
161
|
+
- **OpenTelemetry:** the extra installs the API only. Your application has to install and configure an OpenTelemetry SDK with an exporter. Without one, `use_sdk_defaults=True` emits no spans and logs no warning.
|
|
162
|
+
- **OpenLineage:** with no configuration the client falls back to its console transport and logs every event at INFO. `OPENLINEAGE_DISABLED=true` turns it off.
|
|
163
|
+
|
|
164
|
+
| Extender | What a Jev calculation emits |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| `OtelExtender` | One `mloda.calculate` span for the whole batch (not one per row) with the feature group name and version, rows in and out, and the run id, plus a `mloda.validate.input` and a `mloda.validate.output` span. A failed call sets the status to `ERROR` and `error.type`, except for a row skipped with `jev_on_error="skip"`. |
|
|
167
|
+
| `OpenLineageExtender` | A `START` and a `COMPLETE` (or `FAIL`, but not for a skipped row) event for the Jev job, with one output dataset and its type per question column. The events list no inputs: the text column is tied to the job through the shared parent run only. |
|
|
168
|
+
|
|
169
|
+
The feature group name in spans and the job name in events are the full path, `mloda_plugin_jev.feature_groups.decision.jev_feature_group.JevFeatureGroup`.
|
|
170
|
+
|
|
171
|
+
**A span per Jev call.** The plugin itself (not an extender) opens a `jev.system_one` span of kind `CLIENT` for every call actually made: none for a blank row, and one for texts that `jev_deduplicate` sends once. It carries `jev.question.count`, `jev.request.model` (only when `jev_model` is set), `jev.response.model` (the model that answered, so a `jev-latest` result can be reproduced) and, when the API reports them, `jev.usage.input_tokens` and `jev.usage.output_tokens`. A failed call sets the status to `ERROR` and `error.type`. SDK retries happen inside the span. A failure in the tracing code is logged at WARNING and never fails a call.
|
|
172
|
+
|
|
173
|
+
- These spans need the OpenTelemetry API from the `observability` extra (without it nothing is recorded) and are recorded whenever the application sets a global OpenTelemetry SDK tracer provider, with or without an extender. A `tracer_provider=` injected into the extender does not receive them. They nest under the current span, the extender's `mloda.calculate` when it is used, and are root traces otherwise.
|
|
174
|
+
- A large file makes many spans, so sample at the SDK.
|
|
175
|
+
- Spans and events carry metadata only, the `jev.system_one` spans included: no API key, question, text or error message. When a call fails, the extenders log the error message at WARNING, like mloda itself.
|
|
176
|
+
- Keep `capture_content` and `MLODA_OTEL_TRACE_CONTENT` off for sensitive text, or pass a `mask`: the content preview includes the text column.
|
|
177
|
+
- Both extenders default to `raise_on_error=False`, so a telemetry failure never fails a Jev run. Events are sent on the calculation thread, so a slow or unreachable endpoint still slows the run.
|
|
178
|
+
|
|
179
|
+
See the [extender guide](https://github.com/mloda-ai/mloda-registry/blob/main/docs/guides/11-create-extender.md) for sink resolution and multiprocessing.
|
|
180
|
+
|
|
181
|
+
## Demo notebooks
|
|
182
|
+
|
|
183
|
+
These [marimo](https://marimo.io) notebooks show Jev's typed columns:
|
|
184
|
+
|
|
185
|
+
| Notebook | Story |
|
|
186
|
+
| --- | --- |
|
|
187
|
+
| [`demo/support_triage.py`](demo/support_triage.py) | Seven support tickets and an empty row become team queues and an on-call page. Questions share one call per row, so a new question adds a column without adding calls. |
|
|
188
|
+
| [`demo/rag_context_gate.py`](demo/rag_context_gate.py) | Eight retrieved chunks get typed questions each, and plain Python decides which ones reach the LLM prompt. |
|
|
189
|
+
| [`demo/pre_send_gate.py`](demo/pre_send_gate.py) | Draft client messages get typed answers with the model pinned. Plain Python holds or sends each one, and every decision is recorded as a JSON line that a re-check can compare. |
|
|
190
|
+
| [`demo/churn_digest.py`](demo/churn_digest.py) | App reviews get typed answers, and plain Python turns them into a per-plan table with an alert line. An illustration of the pattern, not a churn metric. |
|
|
191
|
+
|
|
192
|
+
From a clone:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
uv sync --all-extras
|
|
196
|
+
marimo edit demo/support_triage.py
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The notebooks run offline by default: `demo/offline_jev.py` answers from keyword rules through the `jev_transport` option, so they show the pipeline, not model quality. Set `JEV_DEMO_LIVE=1` and `TYPESAFE_API_KEY` to call the real model; the synthetic notebook texts are then sent to the Jev API.
|
|
200
|
+
|
|
201
|
+
## Limits
|
|
202
|
+
|
|
203
|
+
- Runs on the python dict, pandas, Polars and PyArrow frameworks only (not Polars lazy frames, DuckDB, SQLite or Spark).
|
|
204
|
+
- One request per row with text, sent one after another unless `jev_concurrency` is set. Jev's documented rate limit is 1,200 requests per minute (20 per second): size `jev_concurrency` so that it holds. A failed call fails the run unless `jev_on_error` is `skip`.
|
|
205
|
+
- The text plus the longest question must fit in 32k tokens. Input is text only.
|
|
206
|
+
|
|
207
|
+
## Project layout
|
|
208
|
+
|
|
209
|
+
```text
|
|
210
|
+
mloda_plugin_jev/
|
|
211
|
+
├── cli.py # the mloda command, plugin-agnostic
|
|
212
|
+
├── mcp_server.py # the mloda-mcp server, built on cli.py
|
|
213
|
+
├── row_failure.py # RowFailureWarning, the report of rows that got no answer
|
|
214
|
+
└── feature_groups/
|
|
215
|
+
├── manifest.py # entry-point manifest: FEATURE_GROUPS
|
|
216
|
+
└── decision/ # JevFeatureGroup and its tests
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
`cli.py`, `mcp_server.py` and `row_failure.py` import nothing else from the package, so they can move to mloda core as they are. `pyproject.toml` wires `manifest.py` up under `[project.entry-points."mloda.feature_groups"]`, which is how `PluginLoader.all()` finds the plugin. To add a FeatureGroup, append it to `FEATURE_GROUPS`.
|
|
220
|
+
|
|
221
|
+
## Contributing
|
|
222
|
+
|
|
223
|
+
Contributions are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) for the workflow, and follow the [Code of Conduct](CODE_OF_CONDUCT.md). Report security issues privately as described in [SECURITY.md](SECURITY.md).
|
|
224
|
+
|
|
225
|
+
## Development
|
|
226
|
+
|
|
227
|
+
From a clone, set up the virtualenv as in [CONTRIBUTING.md](CONTRIBUTING.md#local-development-setup), then:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
source .venv/bin/activate
|
|
231
|
+
tox
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
`tox` is the gate: `pytest`, `ruff format --check`, `ruff check`, `mypy --strict` and `bandit`. Run `tox -e security` for a `pip-audit` CVE scan. Commits follow [Conventional Commits](https://www.conventionalcommits.org/), which drives the release versioning. See [AGENTS.md](AGENTS.md) for the project practices.
|
|
235
|
+
|
|
236
|
+
- [docs/github-workflows.md](docs/github-workflows.md): the CI and release workflows and their secrets.
|
|
237
|
+
- [docs/github-repository-settings.md](docs/github-repository-settings.md): branch protection and required checks.
|
|
238
|
+
|
|
239
|
+
## Related
|
|
240
|
+
|
|
241
|
+
- [mloda](https://github.com/mloda-ai/mloda): the core library.
|
|
242
|
+
- [mloda-registry plugin guides](https://github.com/mloda-ai/mloda-registry/tree/main/docs/guides/): how to write FeatureGroups, ComputeFrameworks and Extenders.
|
|
243
|
+
- [Jev docs](https://docs.typesafe.ai): the model, the primitives and the API.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# mloda-plugin-jev
|
|
2
|
+
|
|
3
|
+
An [mloda](https://github.com/mloda-ai/mloda) plugin that runs [Jev](https://docs.typesafe.ai) as a FeatureGroup: ask typed questions about a text column and get the answers back as feature columns.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install mloda-plugin-jev
|
|
9
|
+
export TYPESAFE_API_KEY=...
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from mloda.user import Feature, Options, PluginLoader, mloda
|
|
16
|
+
from mloda_plugins.compute_framework.base_implementations.python_dict.python_dict_framework import PythonDictFramework
|
|
17
|
+
|
|
18
|
+
PluginLoader.all()
|
|
19
|
+
|
|
20
|
+
urgent = {"type": "noul", "instructions": "The message conveys urgency"}
|
|
21
|
+
|
|
22
|
+
result = mloda.run_all(
|
|
23
|
+
[Feature("ticket__jev_urgent", Options(context={"jev_question": urgent}))],
|
|
24
|
+
compute_frameworks={PythonDictFramework},
|
|
25
|
+
api_data={"Tickets": {"ticket": ["I was charged twice, please fix ASAP", "The login page is broken"]}},
|
|
26
|
+
)
|
|
27
|
+
print(result[0]["ticket__jev_urgent"]) # for example [0.97, 0.12]: the probability of yes per row
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The full documentation, including the `mloda` command line, is in the [README on GitHub](https://github.com/mloda-ai/mloda-plugin-jev#readme).
|
|
File without changes
|