@assay-ai/vitest 0.1.0-beta → 0.2.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +108 -0
  2. package/package.json +3 -4
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # @assay-ai/vitest
2
+
3
+ Vitest integration for [Assay](https://github.com/assay-ai/assay) -- the TypeScript-native LLM evaluation framework.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@assay-ai/vitest?color=blue)](https://www.npmjs.com/package/@assay-ai/vitest)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install -D @assay-ai/core @assay-ai/vitest
12
+ # or
13
+ pnpm add -D @assay-ai/core @assay-ai/vitest
14
+ ```
15
+
16
+ ## Quick Start
17
+
18
+ ### Custom Matchers
19
+
20
+ Register the Assay matchers once, then use them in any test file:
21
+
22
+ ```typescript
23
+ // setup.ts or at the top of your test file
24
+ import { setupAssayMatchers } from "@assay-ai/vitest";
25
+ import { beforeAll, describe, expect, test } from "vitest";
26
+
27
+ beforeAll(() => {
28
+ setupAssayMatchers();
29
+ });
30
+
31
+ describe("Customer Support Chatbot", () => {
32
+ test("answers product questions accurately", async () => {
33
+ await expect({
34
+ input: "What is your return policy?",
35
+ actualOutput: "You can return items within 30 days of purchase.",
36
+ retrievalContext: [
37
+ "Our return policy allows returns within 30 days of purchase.",
38
+ ],
39
+ }).toBeRelevant({ threshold: 0.8 });
40
+ });
41
+
42
+ test("does not hallucinate", async () => {
43
+ await expect({
44
+ input: "What is your return policy?",
45
+ actualOutput: "You can return items within 30 days of purchase.",
46
+ context: [
47
+ "Our return policy allows returns within 30 days of purchase.",
48
+ ],
49
+ }).toNotHallucinate();
50
+ });
51
+ });
52
+ ```
53
+
54
+ ### Available Matchers
55
+
56
+ | Matcher | Description |
57
+ |---------|-------------|
58
+ | `toBeRelevant(options?)` | Asserts the output is relevant to the input (Answer Relevancy) |
59
+ | `toBeFaithful(options?)` | Asserts the output is grounded in context (Faithfulness) |
60
+ | `toNotHallucinate(options?)` | Asserts the output doesn't contain hallucinations |
61
+ | `toPassMetric(metric)` | Asserts the test case passes a specific metric |
62
+ | `toPassAllMetrics(metrics)` | Asserts the test case passes all given metrics |
63
+
64
+ All matchers accept an optional `{ threshold?: number }` options object.
65
+
66
+ ### Custom Metric Matcher
67
+
68
+ Use `toPassMetric` with any built-in or custom metric:
69
+
70
+ ```typescript
71
+ import { GEval } from "@assay-ai/core";
72
+
73
+ const politeness = new GEval({
74
+ name: "Politeness",
75
+ criteria: "The response should be polite and professional.",
76
+ });
77
+
78
+ test("response is polite", async () => {
79
+ await expect({
80
+ input: "Help me with my order",
81
+ actualOutput: "I'd be happy to help! Could you share your order number?",
82
+ }).toPassMetric(politeness);
83
+ });
84
+ ```
85
+
86
+ ### Reporter
87
+
88
+ Assay includes a custom Vitest reporter that formats evaluation results:
89
+
90
+ ```typescript
91
+ // vitest.config.ts
92
+ import { defineConfig } from "vitest/config";
93
+
94
+ export default defineConfig({
95
+ test: {
96
+ reporters: ["default", "@assay-ai/vitest/reporter"],
97
+ },
98
+ });
99
+ ```
100
+
101
+ ## Peer Dependencies
102
+
103
+ - `@assay-ai/core` >= 0.1.0
104
+ - `vitest` >= 2.0.0
105
+
106
+ ## License
107
+
108
+ [MIT](https://github.com/assay-ai/assay/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assay-ai/vitest",
3
- "version": "0.1.0-beta",
3
+ "version": "0.2.0-beta",
4
4
  "description": "Vitest integration for the Assay LLM evaluation framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,13 +24,13 @@
24
24
  ],
25
25
  "peerDependencies": {
26
26
  "vitest": ">=2.0.0",
27
- "@assay-ai/core": "0.1.0-beta"
27
+ "@assay-ai/core": "0.2.0-beta"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "^8.3.0",
31
31
  "typescript": "^5.7.0",
32
32
  "vitest": "^3.0.0",
33
- "@assay-ai/core": "0.1.0-beta",
33
+ "@assay-ai/core": "0.2.0-beta",
34
34
  "@assay-ai/tsconfig": "0.0.0"
35
35
  },
36
36
  "repository": {
@@ -42,7 +42,6 @@
42
42
  "build": "tsup",
43
43
  "dev": "tsup --watch",
44
44
  "typecheck": "tsc --noEmit",
45
- "test": "vitest run",
46
45
  "clean": "rm -rf dist .turbo"
47
46
  }
48
47
  }