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>
35 lines
1.5 KiB
YAML
35 lines
1.5 KiB
YAML
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"
|