The platform for continuously improving AI agents.
"""What the Workshop agent reads before it writes a package or a presentation, and never
needs for a transform spec."""
from modal_shared.decisions import decision_line, decision_reference
from overbae.services.datasets import pipeline_packages
from overbae.services.datasets.context import CONSUMERS
from workshop_runtime.presentation import CATALOG
CONSUMER_KEYS = {
"decision_train": "decision_training",
"decision_eval": "decision_evaluation",
"chat_train": "sft",
"model_eval": "model_evaluation",
}
TOPICS = (*CONSUMER_KEYS, "presentation")
CHECKS = (
"Compare what the package wrote with the source, by source_row, in code that does not "
"call the package's own helpers: labels, option order, null and blank values, and every "
"row the package left out with the reason. Keep rows that describe one entity, document "
"or conversation in one partition. Native partitions land as new datasets and assign "
"their own source_row identities. Before partitioning, retain original_source_row, the "
"original source cell and its fingerprint as ordinary provenance fields when original "
"row identity is required; exclude them from model input. Compare partition rows by "
"that retained identity, not the new local source_row. A script that ran is not evidence "
"that its rows are right."
)
PRESENTATION = (
"Write a JSON document in the working directory and call present with its path. The "
'document has root, data and images. A node is {"component": name, "props": {...}}; the '
"root is a Stack and children are nodes. data maps a key to {path: a JSON array file in "
"the working directory, cells: the exact version ids the figures were computed from, "
"scope: the rows they cover}. images takes the same shape for PNG, JPEG or WebP files. "
"Compute every figure in Python. Question and Choices ids are unique; what the user picks "
"arrives as their next message. At most 64 components, 2,000 rows per table, 2 MiB."
)
def examples():
"""Rows in each decision wire format. The values are illustrations of the format only."""
request = {
"state": '{"observed_attribute": "example value"}',
"question": "Which observed outcome applies?\nA: outcome A\nB: outcome B",
"kind": "choice",
"options": ["A", "B"],
}
result = {
"decision_train": {
"source_row": 0,
"decision": {
**request,
"target_probabilities": [1.0, 0.0],
"target_semantics": "categorical_gold",
"target_provenance": {"source": "format illustration"},
},
},
"decision_eval": {
"source_row": 0,
"input": {"decision": request},
"expected_output": {"probabilities": [1.0, 0.0]},
},
"soft_target": {
"decision": {
**request,
"target_probabilities": [0.25, 0.75],
"target_semantics": "annotator_distribution",
}
},
}
for name in ("decision_train", "soft_target"):
decision_line(result[name])
decision_reference(
result["decision_eval"]["input"]["decision"], result["decision_eval"]["expected_output"]
)
return result
def contract(topic):
if topic == "presentation":
return {"instructions": PRESENTATION, "components": CATALOG}
package = pipeline_packages.authoring_contract()
for transport in ("upload", "download"):
package.pop(transport, None)
return {
"consumer": CONSUMERS[CONSUMER_KEYS[topic]],
"shared": CONSUMERS["shared"],
"package": package,
"script": (
"An entrypoint is run as: python <entrypoint> <input.jsonl> <output.jsonl> "
"<parameters.json>. It reads one JSON row per line, each with source_row, and writes "
"one JSON row per line that keeps the source_row of the row it came from. Declare "
f"consumer={topic} on the last step. Write the package as a ZIP with zipfile in the "
"working directory, preview it with publish_package(mode=preview), read the sample "
"it returns, then publish. To transform another published project cell, pass its "
"exact ID as publish_package(source_cell=...) for both preview and publication. "
"Do not add source selectors to the package manifest. The final consumer sets "
"the entire destination dataset's intent: intermediate chat-shaped cells in an "
"evaluation publication are not training inputs. Publish training and evaluation "
"consumers separately in this Workshop and verify the exact downstream inputs."
),
"checks": CHECKS,
**({"examples": examples()} if topic.startswith("decision") else {}),
}