feat: add export_traffic() to export observations as savings-report JSONL - #21
Merged
Conversation
Contributor
|
Please complete the rights checkbox |
…SONL
Implements RuleChef.export_traffic(path) that writes observed LLM
input-output pairs in the JSONL format expected by rulechef-savings:
- Classification: {"text": ..., "llm_label": ...}
- NER: {"text": ..., "llm_entities": [...]}
Also documents the observe -> export_traffic -> rulechef-savings loop
in benchmarks/INSPECTING_RULES.md, and adds tests including a round-trip
through the savings CLI.
Closes KRLabsOrg#20
Signed-off-by: Stefano Maffeis <lesbass@gmail.com>
lesbass
force-pushed
the
fix/export-traffic
branch
from
July 3, 2026 13:14
409e1c2 to
d034199
Compare
Contributor
Author
|
PR body updated with checked rights checkbox. Commit amended with DCO sign-off ( |
…penAI client creation The RuleChef constructor creates a real OpenAI() client when none is provided, which fails in CI without an OPENAI_API_KEY. Using a MagicMock avoids this, consistent with other test files (test_rule_loading.py, test_engine_observation.py). Also add the missing MagicMock import.
Contributor
Author
|
Fix pushed: added Could you approve the CI workflow run when you get a chance? (Fork PR needs workflow approval.) |
Contributor
|
Thanks for this, and sorry for the slow turnaround on the workflow approval — the run went through and everything is green. The observe → export → savings loop was exactly the missing piece, and the roundtrip test is appreciated. Merging. |
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
RuleChef.export_traffic(path)that writes observed LLM input-output pairs in the JSONL format expected byrulechef-savings:{"text": "...", "llm_label": "..."}{"text": "...", "llm_entities": [...]}Changes
rulechef/engine.py: Addedexport_traffic()method that iterates over buffered LLM observations and writes them as JSONLbenchmarks/INSPECTING_RULES.md: Documented the observe -> export_traffic -> rulechef-savings looptests/test_reports.py: Added 4 tests covering classification format, no-task auto-detection, round-trip through the savings CLI, and human-example exclusionVerification
Rights & sign-off (required)
distributed under the repository's Apache-2.0 license
(see CONTRIBUTING).
Closes #20.