Diffinery

homeflare/celldpublic

celld/examples/pi/README.md
43 lines · 1.6 KBRaw History
1# PiHarness
2
3This example runs the experimental `PiHarness` from Cloudflare Agents pull
4request 2197 in a celld Durable Object. The example calls Cloudflare Workers AI
5through the OpenAI-compatible endpoint, and it selects Llama 3.2 1B by default.
6
7Celld serves no Workers AI binding, so the example owns its credentials. It
8reads `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` from the Worker
9variables, and it builds the adapter that the pi provider needs. The example
10stops at startup when either variable is absent, because a stand-in model
11answers every prompt and therefore hides a broken configuration.
12
13The `agents` package on npm does not contain `PiHarness`, therefore this example
14depends on a preview build of pull request 2197. The preview build can change or
15expire, so an install can fail until that pull request is released.
16
17Install the dependencies, pass the credentials as Worker variables, then start
18the example from this directory:
19
20```sh
21npm ci
22
23CELLD_VAR_CLOUDFLARE_ACCOUNT_ID="your-account-id" \
24CELLD_VAR_CLOUDFLARE_API_TOKEN="your-token" \
25celld dev .
26```
27
28A `CELLD_VARS_FILE` entry works too, and it keeps the token out of the shell
29history.
30
31Run a prompt and inspect the persisted transcript:
32
33```sh
34curl http://127.0.0.1:9876/
35curl http://127.0.0.1:9876/messages
36```
37
38The prompt route answers 200 for a completed run, and 502 with the reported
39errors for a failed one.
40
41The Durable Object storage holds the transcript, so the state survives a
42restart. A model change does not migrate that state, therefore start again with
43`celld dev --clean .` after you edit `PI_MODEL`.