labs: AICharts demo Worker (NL -> validated chart spec, D1, workers.dev) (#35)
Library (aicharts.js): spec validator, fixed ops (filter/group/sort/bin/limit), Chart.js config, attach() for existing charts, <ai-chart> element. Worker: sample orders in D1, schema/sample/aggregates to Workers AI with structured output + one repair round, saved_charts, per-IP and daily caps. deploy.py: workers.dev only, no DNS. For teahub matcha/teahub#93. Claude-Session: https://claude.ai/code/session_01VDkN7ukK1kXkqov8FaZxva Co-authored-by: Claude <noreply@anthropic.com>
This commit was merged in pull request #35.
This commit is contained in:
1 parent
88f9d509ed
commit
ba4174326a
6 files changed
+790
No files matched your search
@@ -0,0 +1,34 @@
|
||||
name: labs-aicharts
|
||||
# Deploy the AICharts demo Worker (workers.dev, one D1, Workers AI), then smoke-test it. Manual only.
|
||||
on: workflow_dispatch
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
sparse-checkout: .github/time
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- run: node .github/time/labs/aicharts/test_aicharts.mjs
|
||||
- id: deploy
|
||||
run: |
|
||||
python3 .github/time/labs/aicharts/deploy.py | tee out.json
|
||||
echo "url=$(python3 -c 'import json; print(json.load(open("out.json"))["url"])')" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
- name: smoke
|
||||
run: |
|
||||
u="${{ steps.deploy.outputs.url }}"
|
||||
for i in 1 2 3 4 5 6; do curl -fsS "${u}api/health" && break; sleep 10; done
|
||||
curl -fsS "${u}api/schema?dataset=orders" | python3 -c 'import json,sys; d=json.load(sys.stdin); assert len(d["sample"])==5, d; print("schema ok")'
|
||||
curl -fsS -X POST "${u}api/spec" -H 'content-type: application/json' \
|
||||
-d '{"dataset":"orders","prompt":"total revenue by region"}' | tee spec.json
|
||||
echo
|
||||
echo "### AICharts: ${u}" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo '```json' >> "$GITHUB_STEP_SUMMARY"; cat spec.json >> "$GITHUB_STEP_SUMMARY"; echo '```' >> "$GITHUB_STEP_SUMMARY"
|
||||
Reference in new issue
Block a user