Python
Official Python SDK for Baton.
Installation
Code
pip install b4tonUsage
Code
from b4ton import Baton
import os
baton = Baton(os.environ["BATON_KEY"])
# Pass
handoff = baton.pass_context(
task="Summarize this document",
output={"text": "The quarterly results show..."},
constraints="Keep it under 100 words"
)
print(handoff.pickup_url)
# Catch
job = baton.catch(handoff.pickup_url)
print(job.task) # "Summarize this document"
print(job.output) # {"text": "The quarterly results show..."}
# Done
baton.done(job.baton_id, output={
"summary": "Revenue grew 15% YoY..."
})