@botpress/vai 0.0.3 → 0.0.5

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.
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { z } from "@bpinternal/zui";
3
2
  import { Context } from "../context";
4
3
  import { asyncExpect } from "../utils/asyncAssertion";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import json5 from "json5";
3
2
  import { expect } from "vitest";
4
3
  import { getCurrentTest } from "vitest/suite";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { Context } from "../context";
3
2
  import { asyncExpect } from "../utils/asyncAssertion";
4
3
  import { predictJson } from "../utils/predictJson";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { z } from "@bpinternal/zui";
3
2
  import { Context } from "../context";
4
3
  import { asyncExpect } from "../utils/asyncAssertion";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { z } from "@bpinternal/zui";
3
2
  import { Context } from "../context";
4
3
  import { asyncExpect } from "../utils/asyncAssertion";
package/dist/context.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { onTestFinished } from "vitest";
3
2
  import { getCurrentTest } from "vitest/suite";
4
3
  const getTestMetadata = () => {
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { getCurrentTest } from "vitest/suite";
3
2
  export const setEvaluator = (model) => {
4
3
  const test = getCurrentTest();
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { Context } from "../context";
3
2
  export const setupClient = (client) => {
4
3
  Context.setClient(client);
package/dist/index.d.ts CHANGED
@@ -30,10 +30,10 @@ declare const Output: _bpinternal_zui.ZodObject<{
30
30
  reason: _bpinternal_zui.ZodString;
31
31
  result: _bpinternal_zui.ZodAny;
32
32
  }, "strip", _bpinternal_zui.ZodTypeAny, {
33
- reason: string;
33
+ reason?: string;
34
34
  result?: any;
35
35
  }, {
36
- reason: string;
36
+ reason?: string;
37
37
  result?: any;
38
38
  }>;
39
39
 
@@ -52,7 +52,7 @@ type CheckOptions<T> = {
52
52
  declare function check<T extends Input>(value: T, condition: string, options?: CheckOptions<T>): {
53
53
  toBe: (expected: boolean) => Promise<Output<boolean> | AsyncExpectError<boolean>>;
54
54
  toMatchInlineSnapshot: (expected?: string) => Promise<void | Output<boolean> | AsyncExpectError<boolean>>;
55
- then<TResult1 = Output<boolean>, TResult2 = never>(onfulfilled?: ((value: Output<boolean>) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
55
+ then<TResult1 = Output<boolean>, TResult2 = never>(onfulfilled?: (value: Output<boolean>) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
56
56
  value: PromiseLike<boolean>;
57
57
  };
58
58
 
@@ -68,7 +68,7 @@ declare function extract<T extends Input, S extends AnyZodObject>(value: T, shap
68
68
  toBe: (expected: z.infer<S>) => Promise<Output<z.infer<S>> | AsyncExpectError<z.infer<S>>>;
69
69
  toMatchObject: (expected: Partial<z.infer<S>>) => Promise<Output<z.infer<S>> | AsyncExpectError<z.infer<S>>>;
70
70
  toMatchInlineSnapshot: (expected?: string) => Promise<void | Output<z.infer<S>> | AsyncExpectError<z.infer<S>>>;
71
- then<TResult1 = Output<z.infer<S>>, TResult2 = never>(onfulfilled?: ((value: Output<z.infer<S>>) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
71
+ then<TResult1 = Output<z.infer<S>>, TResult2 = never>(onfulfilled?: (value: Output<z.infer<S>>) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
72
72
  value: PromiseLike<z.infer<S>>;
73
73
  };
74
74
 
@@ -91,7 +91,7 @@ declare function filter<U>(values: U[], condition: string, options?: FilterOptio
91
91
  toBeLessThanOrEqual: (expected: number) => Promise<Output<U[]> | AsyncExpectError<U[]>>;
92
92
  toBeBetween: (min: number, max: number) => Promise<Output<U[]> | AsyncExpectError<U[]>>;
93
93
  };
94
- then<TResult1 = Output<U[]>, TResult2 = never>(onfulfilled?: ((value: Output<U[]>) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
94
+ then<TResult1 = Output<U[]>, TResult2 = never>(onfulfilled?: (value: Output<U[]>) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
95
95
  value: PromiseLike<U[]>;
96
96
  };
97
97
 
@@ -108,7 +108,7 @@ declare function rate<T extends Input>(value: T, condition: string, options?: Ra
108
108
  toMatchInlineSnapshot: (expected?: string) => Promise<void | Output<number> | AsyncExpectError<number>>;
109
109
  toBeGreaterThanOrEqual: (expected: RatingScore) => Promise<Output<number> | AsyncExpectError<number>>;
110
110
  toBeLessThanOrEqual: (expected: RatingScore) => Promise<Output<number> | AsyncExpectError<number>>;
111
- then<TResult1 = Output<number>, TResult2 = never>(onfulfilled?: ((value: Output<number>) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
111
+ then<TResult1 = Output<number>, TResult2 = never>(onfulfilled?: (value: Output<number>) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
112
112
  value: PromiseLike<number>;
113
113
  };
114
114
 
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  export { compare } from "./task/compare";
3
2
  export { check } from "./assertions/check";
4
3
  export { extract } from "./assertions/extract";
package/dist/models.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  export const Models = [
3
2
  {
4
3
  "id": "anthropic__claude-3-haiku-20240307",
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { Client } from "@botpress/client";
3
2
  import _ from "lodash";
4
3
  import fs from "node:fs";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { Client } from "@botpress/client";
3
2
  import { z } from "@bpinternal/zui";
4
3
  import _ from "lodash";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { z } from "@bpinternal/zui";
3
2
  import { createTaskCollector, getCurrentSuite } from "vitest/suite";
4
3
  import { Deferred } from "../utils/deferred";
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { expect } from "vitest";
3
2
  import { getCurrentTest } from "vitest/suite";
4
3
  import { Context } from "../context";
@@ -31,7 +30,10 @@ export const asyncExpect = (output, assertion) => {
31
30
  }
32
31
  return x;
33
32
  });
34
- getCurrentTest().promises ??= [];
35
- getCurrentTest().promises.push(promise);
33
+ const currentTest = getCurrentTest();
34
+ if (currentTest) {
35
+ currentTest.promises ??= [];
36
+ currentTest.promises.push(promise);
37
+ }
36
38
  return promise;
37
39
  };
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  export class Deferred {
3
2
  constructor() {
4
3
  this.promise = new Promise((resolve, reject) => {
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { z } from "@bpinternal/zui";
3
2
  import JSON5 from "json5";
4
3
  import { Context } from "../context";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/vai",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Vitest AI (vai) – a vitest extension for testing with LLMs",
5
5
  "exports": {
6
6
  ".": {
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "Node",
6
6
  "target": "ES2017",
7
- "strict": true,
7
+ "strict": false,
8
8
  "jsx": "preserve",
9
9
  "noUnusedLocals": true,
10
10
  "noUnusedParameters": true,
package/vitest.config.ts CHANGED
@@ -3,6 +3,8 @@ import { defineConfig } from 'vitest/config'
3
3
 
4
4
  export default defineConfig({
5
5
  test: {
6
+ retry: 2, // because LLMs can fail
7
+ testTimeout: 60_000, // because LLMs can be slow
6
8
  include: ['./src/**/*.test.ts'],
7
9
  setupFiles: './vitest.setup.ts'
8
10
  }