Skip to content
Public template

About

LLM evals for a JavaScript or Node.js app, run in CI on every pull request: a support bot, its tinyeval suite and a GitHub Actions workflow. Use it as a template.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

LLM evals for JavaScript

A JavaScript support bot whose AI call is tested on every pull request with tinyeval.

Run it

Clone this repo or use it as a template. Then:

npm ci
export ANTHROPIC_API_KEY=sk-ant-...
npx tinyeval
support
  ✓ refund after the window 4.9s
  ✓ missing package 4.3s
  ✓ refund inside the window 4.5s

All 3 evals passed (eval-results.json)

What's here

  • src/support.js: the bot. answer(message) calls Claude with the official @anthropic-ai/sdk.
  • prompts/support.md: the system prompt.
  • evals/worker.js: loads the bot once and answers each test case, with the worker helper from tinyeval-cli.
  • evals/support.sh: three test cases, each checked by a regex, a judge or both.
  • .github/workflows/evals.yml: runs the evals on every pull request and push to main.

Plain ES modules on Node.js 22 or later, with no build step.

Use it for your app

  1. Replace answer with your AI call. Keep the worker, so your app starts once per worker and not once per test case.
  2. Write your test cases in evals/. The check lines cover regexes, JSON, your own graders and a model judge.

When the API call fails for a reason that isn't your code, such as a missing key, a rate limit or a timeout, the test case couldn't run. tinyeval counts it apart from the failures, and still exits 1. The helper knows the errors of @anthropic-ai/sdk and openai. For another client, throw CouldntRun. An error in your own code fails the eval.

In an Express or other Node.js app, import your server-side function in the worker and call it there, not a route handler that needs a request. Keep logs off stdout, since stdout carries the replies. Importing tinyeval-cli before your code sends console.log to stderr.

In CI

Add ANTHROPIC_API_KEY as a repository secret. The bot and tinyeval's judge both use it. The workflow installs the packages with npm ci, then runs each test case 3 times. A failing eval fails the job, so it can gate merges. The results upload as the eval-results artifact. Without the secret, the eval step is skipped with a notice.

Updating

.github/dependabot.yml checks weekly and opens a pull request for each new version of tinyeval-cli, the SDK or an action. Those pull requests get no repository secrets, so their eval step skips with the notice. The evals run on main once you merge. To update by hand, run npm install --save-dev tinyeval-cli@latest.

Compare pull requests with main

A fresh CI run has no earlier run to compare with. evalship reads eval-results.json, compares each pull request with main, tells flaky evals from real drops and comments on the pull request.

License

MIT

About

LLM evals for a JavaScript or Node.js app, run in CI on every pull request: a support bot, its tinyeval suite and a GitHub Actions workflow. Use it as a template.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages