A function check
Length
A check looks at the answer and says yes or no. Yes keeps the answer. No sends back a short reason.
This page runs the check on a sentence you can see. Passed means yes. The next line is the sentence that was kept.
Example
class Result:
raw = "An agent takes a role, then a task."
def short_enough(output):
text = output.raw
if len(text) <= 400:
return (True, output)
return (False, "Too long")
passed, value = short_enough(Result())
print("Passed:", passed)
print(value.raw)Example explained
- (True, output) — The check passed. Keep the result.
- (False, message) — The check failed. The message says why.
Reference: documentation