Skip to content
getsentryPublic

About

Evals-as-Code and a CLI to run them

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

eac (evals-as-code)

eac is a command line tool & SDKs to write evals for AI systems. It handles fixtures, running and judging your AI system, all configurable through code.

📚 Full Documentation

Warning

eac is an early release, used internally at Sentry. There may be breaking changes in the future.

Get started

1. Install

curl -fsSL https://eac.sentry.dev/install | bash   # the CLI, on macOS or Linux
pip install eac-sdk                                # the SDK, needs Python 3.11+

To build the CLI from source instead, run make install in the repo (needs Rust 1.87+).

2. Write an eval

Add a dataset.yml and the code it points to, anywhere in your repo.

# evals/chat/dataset.yml
name: chat
runtime: python
offline:
  runner: ./dataset.py:ChatRunner
  cases: ./dataset.py:CASES
# evals/chat/dataset.py
from eac import Case, Judge, OfflineRunner, Score


def reply(query: str) -> str:
    return "hello there" if query == "hi" else "see you later"  # call your AI agent here


class ChatRunner(OfflineRunner):

    def run_case(
        self,
        case: Case,
        *,
        conversation_id: str,
    ) -> dict[str, Any]:
        return {"response": reply(case.input["query"])}


class Greets(Judge):
    name = "greets_judge"

    def judge(
        self,
        case: Case,
        *,
        agent_trace: Any = None,
    ) -> Score | None:
        response = case.run_results.get("response", "")
        if "hello" in response:
            return Score(name=self.name, score=1.0)

        return Score(
            name=self.name,
            score=0.0,
            explanation=f"no greeting in {response!r}",
        )


CASES = [
    Case(name="greeting", input={"query": "hi"}, judges=[Greets()]),
    Case(name="goodbye", input={"query": "bye"}, judges=[Greets()]),
]

3. Run it

eac seeds fixtures, runs each case, judges the output and prints the results.

eac offline run --dataset chat
RESULTS
  +------------------+----------------+----------+
  | Case             | Status / score | Duration |
  +==================+================+==========+
  | chat/greeting    | PASSED         | 0.00s    |
  |   └ greets_judge | 1              |          |
  | chat/goodbye     | FAILED         | 0.00s    |
  |   └ greets_judge | 0              |          |
  +------------------+----------------+----------+

  Below 1
    chat/goodbye › greets_judge: no greeting in 'see you later'

  2 cases  1 passed  1 failed  0 errored

greeting passes, goodbye fails.

Learn more

examples/ has full examples to start from. The docs cover everything about eac.

Contributors

License

Apache-2.0

About

Evals-as-Code and a CLI to run them

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages