Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657"""Generate context.json without an upstream: one warm-up cell and a 300-cell turn."""
import base64import jsonfrom pathlib import Path
CONTEXT_STEPS = 300
def response(index, code=None): delta = {"role": "assistant"} if code is None: delta["content"] = "done" finish = "stop" else: delta["tool_calls"] = [ { "index": 0, "id": f"context-{index}", "type": "function", "function": {"name": "python", "arguments": json.dumps({"code": code})}, } ] finish = "tool_calls" chunks = [ {"choices": [{"index": 0, "delta": delta, "finish_reason": None}]}, {"choices": [{"index": 0, "delta": {}, "finish_reason": finish}]}, ] body = "".join("data: " + json.dumps(chunk) + "\n\n" for chunk in chunks) body += "data: [DONE]\n\n" return { "status": 200, "headers": [["Content-Type", "text/event-stream"]], "body": base64.b64encode(body.encode()).decode(), }
def recording(): responses = [response(0, "print('ready')"), response(1)] for step in range(CONTEXT_STEPS): # 6144 printed characters plus a newline, below the result preview cap. code = f"print('{step:03d} ' + 'context ' * 767 + 'end!')" responses.append(response(step + 2, code)) responses.append(response(CONTEXT_STEPS + 2)) return { "recorded_at": "synthetic-context-v1", "synthetic": True, "model": "bonsai-2-27b", "responses": responses, }
if __name__ == "__main__": Path(__file__).with_name("context.json").write_text( json.dumps(recording(), indent=2) + "\n" )