peerbench 0.0.7 → 0.0.8
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.
- package/dist/aggregators/abstract.d.ts +10 -0
- package/dist/aggregators/index.d.ts +2 -67
- package/dist/aggregators/llm/avg.d.ts +26 -0
- package/dist/benchmarks/examples/echo-basic/index.d.ts +4 -0
- package/dist/benchmarks/examples/echo-basic/runner.d.ts +273 -0
- package/dist/benchmarks/examples/echo-basic/schema-sets/echo.v1.d.ts +241 -0
- package/dist/benchmarks/examples/echo-basic/storages/json.d.ts +14 -0
- package/dist/benchmarks/examples/echo-basic/storages/text.d.ts +24 -0
- package/dist/benchmarks/examples/exact-match-scorer/index.d.ts +4 -0
- package/dist/benchmarks/examples/exact-match-scorer/runner.d.ts +428 -0
- package/dist/benchmarks/examples/exact-match-scorer/schema-sets/exact-match.v1.d.ts +287 -0
- package/dist/benchmarks/examples/exact-match-scorer/scorer.d.ts +30 -0
- package/dist/benchmarks/examples/exact-match-scorer/storages/json.d.ts +8 -0
- package/dist/benchmarks/examples/text-transform/index.d.ts +4 -0
- package/dist/benchmarks/examples/text-transform/runner.d.ts +524 -0
- package/dist/benchmarks/examples/text-transform/schema-sets/echo.v1.d.ts +211 -0
- package/dist/benchmarks/examples/text-transform/schema-sets/namespace.d.ts +1 -0
- package/dist/benchmarks/examples/text-transform/schema-sets/reverse.v1.d.ts +216 -0
- package/dist/benchmarks/examples/text-transform/storages/json.d.ts +9 -0
- package/dist/benchmarks/index.d.ts +1 -1667
- package/dist/benchmarks/index.js +16 -16
- package/dist/benchmarks/peerbench/index.d.ts +5 -0
- package/dist/benchmarks/peerbench/runner.d.ts +754 -0
- package/dist/benchmarks/peerbench/schema-sets/mcq.v1.d.ts +261 -0
- package/dist/benchmarks/peerbench/schema-sets/multi-turn.v1.d.ts +351 -0
- package/dist/benchmarks/peerbench/schema-sets/qa.v1.d.ts +256 -0
- package/dist/benchmarks/peerbench/storages/json.d.ts +10 -0
- package/dist/{chunk-ZXTQJFGL.js → chunk-Q6GSOHOP.js} +4 -4
- package/dist/constants.d.ts +4 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/peerbench.d.ts +6 -0
- package/dist/errors/polyfill.d.ts +1 -0
- package/dist/examples/basic.d.ts +1 -0
- package/dist/helpers/define-runner.d.ts +45 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/index.d.ts +6 -101
- package/dist/index.js +3 -3
- package/dist/providers/abstract/llm.d.ts +20 -0
- package/dist/{provider-DnEBdl1n.d.ts → providers/abstract/provider.d.ts} +2 -4
- package/dist/providers/example/echo.d.ts +12 -0
- package/dist/providers/example/restapi.d.ts +37 -0
- package/dist/providers/index.d.ts +5 -96
- package/dist/providers/mastra.d.ts +40 -0
- package/dist/providers/openai.d.ts +29 -0
- package/dist/providers/openrouter.d.ts +27 -0
- package/dist/schemas/extensions/index.d.ts +18 -22
- package/dist/schemas/extensions/response/llm.d.ts +14 -0
- package/dist/schemas/extensions/score/llm-as-a-judge-scorer.d.ts +15 -0
- package/dist/schemas/id.d.ts +2 -0
- package/dist/schemas/index.d.ts +4 -200
- package/dist/schemas/llm/index.d.ts +2 -116
- package/dist/schemas/llm/index.js +2 -2
- package/dist/schemas/llm/simple-system-prompt.d.ts +51 -0
- package/dist/schemas/llm/system-prompt.d.ts +59 -0
- package/dist/schemas/response.d.ts +63 -0
- package/dist/schemas/schema-definer.d.ts +47 -0
- package/dist/schemas/score.d.ts +73 -0
- package/dist/schemas/test-case.d.ts +57 -0
- package/dist/{abstract-BdgLjkNC.d.ts → scorers/abstract.d.ts} +2 -4
- package/dist/scorers/index.d.ts +4 -68
- package/dist/scorers/llm-judge.d.ts +55 -0
- package/dist/scorers/mcq.d.ts +19 -0
- package/dist/scorers/mcq.test.d.ts +1 -0
- package/dist/scorers/regex.d.ts +58 -0
- package/dist/scorers/regex.test.d.ts +1 -0
- package/dist/storages/abstract.d.ts +7 -0
- package/dist/storages/examples/http.d.ts +1 -0
- package/dist/storages/examples/sqlite.d.ts +1 -0
- package/dist/storages/file.d.ts +43 -0
- package/dist/storages/http.d.ts +22 -0
- package/dist/storages/index.d.ts +5 -69
- package/dist/storages/json-file.d.ts +21 -0
- package/dist/storages/sqlite.d.ts +41 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/runner.d.ts +18 -0
- package/dist/utilities.d.ts +9 -0
- package/dist/utils/id-generator.d.ts +2 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/json.d.ts +17 -0
- package/dist/utils/llm.d.ts +7 -0
- package/dist/{rate-limiter-CSmVIRsM.d.ts → utils/rate-limiter.d.ts} +3 -5
- package/dist/utils/sleep.d.ts +1 -0
- package/dist/utils/string.d.ts +8 -0
- package/package.json +3 -3
- package/dist/index-Cn20kPrz.d.ts +0 -27
- package/dist/json-file-Bgv9TLcX.d.ts +0 -74
- package/dist/llm-8ecJmwKJ.d.ts +0 -23
- package/dist/llm-judge-BuF80-5-.d.ts +0 -75
- /package/dist/{chunk-ZXTQJFGL.js.map → chunk-Q6GSOHOP.js.map} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AbstractStorage } from "../storages/abstract";
|
|
2
|
+
export declare class HttpStorage<TObject> extends AbstractStorage<TObject> {
|
|
3
|
+
protected readonly url: string;
|
|
4
|
+
protected readonly codec: AbstractHttpStorageCodec<TObject>;
|
|
5
|
+
protected readonly fetchFn: typeof fetch;
|
|
6
|
+
constructor(config: {
|
|
7
|
+
url: string;
|
|
8
|
+
codec: AbstractHttpStorageCodec<TObject>;
|
|
9
|
+
fetchFn?: typeof fetch;
|
|
10
|
+
});
|
|
11
|
+
init(_params?: unknown): Promise<void>;
|
|
12
|
+
read(_key: string, _params?: unknown): Promise<TObject | null>;
|
|
13
|
+
readAll(params?: unknown): Promise<TObject[]>;
|
|
14
|
+
write(_key: string, _value: TObject, _params?: unknown): Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class AbstractHttpStorageCodec<TObject> {
|
|
17
|
+
abstract readAll(params: {
|
|
18
|
+
url: string;
|
|
19
|
+
response: Response;
|
|
20
|
+
params?: unknown;
|
|
21
|
+
}): Promise<TObject[]>;
|
|
22
|
+
}
|
package/dist/storages/index.d.ts
CHANGED
|
@@ -1,69 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare class HttpStorage<TObject> extends AbstractStorage<TObject> {
|
|
8
|
-
protected readonly url: string;
|
|
9
|
-
protected readonly codec: AbstractHttpStorageCodec<TObject>;
|
|
10
|
-
protected readonly fetchFn: typeof fetch;
|
|
11
|
-
constructor(config: {
|
|
12
|
-
url: string;
|
|
13
|
-
codec: AbstractHttpStorageCodec<TObject>;
|
|
14
|
-
fetchFn?: typeof fetch;
|
|
15
|
-
});
|
|
16
|
-
init(_params?: unknown): Promise<void>;
|
|
17
|
-
read(_key: string, _params?: unknown): Promise<TObject | null>;
|
|
18
|
-
readAll(params?: unknown): Promise<TObject[]>;
|
|
19
|
-
write(_key: string, _value: TObject, _params?: unknown): Promise<unknown>;
|
|
20
|
-
}
|
|
21
|
-
declare abstract class AbstractHttpStorageCodec<TObject> {
|
|
22
|
-
abstract readAll(params: {
|
|
23
|
-
url: string;
|
|
24
|
-
response: Response;
|
|
25
|
-
params?: unknown;
|
|
26
|
-
}): Promise<TObject[]>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare class SQLiteStorage<TObject> extends AbstractStorage<TObject> {
|
|
30
|
-
protected readonly path: string;
|
|
31
|
-
protected readonly codec: AbstractSQLiteStorageCodec<TObject>;
|
|
32
|
-
protected db: SQLiteDatabase | undefined;
|
|
33
|
-
constructor(config: {
|
|
34
|
-
path: string;
|
|
35
|
-
codec: AbstractSQLiteStorageCodec<TObject>;
|
|
36
|
-
});
|
|
37
|
-
init(params?: unknown): Promise<void>;
|
|
38
|
-
read(key: string, params?: unknown): Promise<TObject | null>;
|
|
39
|
-
readAll(params?: unknown): Promise<TObject[]>;
|
|
40
|
-
write(key: string, value: TObject, params?: unknown): Promise<unknown>;
|
|
41
|
-
close(): void;
|
|
42
|
-
protected assertInitialized(): asserts this is this & {
|
|
43
|
-
db: SQLiteDatabase;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
declare abstract class AbstractSQLiteStorageCodec<TObject> {
|
|
47
|
-
init?(params: {
|
|
48
|
-
db: SQLiteDatabase;
|
|
49
|
-
params?: unknown;
|
|
50
|
-
}): Promise<void> | void;
|
|
51
|
-
abstract read(params: {
|
|
52
|
-
db: SQLiteDatabase;
|
|
53
|
-
key: string;
|
|
54
|
-
params?: unknown;
|
|
55
|
-
}): Promise<TObject | null>;
|
|
56
|
-
abstract readAll(params: {
|
|
57
|
-
db: SQLiteDatabase;
|
|
58
|
-
params?: unknown;
|
|
59
|
-
}): Promise<TObject[]>;
|
|
60
|
-
abstract write(params: {
|
|
61
|
-
db: SQLiteDatabase;
|
|
62
|
-
key: string;
|
|
63
|
-
value: TObject;
|
|
64
|
-
params?: unknown;
|
|
65
|
-
}): Promise<unknown>;
|
|
66
|
-
}
|
|
67
|
-
type SQLiteDatabase = better_sqlite3.Database;
|
|
68
|
-
|
|
69
|
-
export { AbstractHttpStorageCodec, AbstractSQLiteStorageCodec, AbstractStorage, HttpStorage, SQLiteStorage };
|
|
1
|
+
export * from "./abstract";
|
|
2
|
+
export * from "./http";
|
|
3
|
+
export * from "./json-file";
|
|
4
|
+
export * from "./file";
|
|
5
|
+
export * from "./sqlite";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AbstractFileStorageCodec, FileStorage, FileStorageFileHandle } from "./file";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
export declare class JSONFileStorage<TObject> extends FileStorage<TObject> {
|
|
4
|
+
codec: JSONFileStorageCodec<TObject>;
|
|
5
|
+
constructor(config: {
|
|
6
|
+
path: string;
|
|
7
|
+
chunkSize?: number;
|
|
8
|
+
schema: z.ZodType<TObject>;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export declare class JSONFileStorageCodec<TObject> extends AbstractFileStorageCodec<TObject> {
|
|
12
|
+
private chunkSize;
|
|
13
|
+
private schema;
|
|
14
|
+
constructor(config: {
|
|
15
|
+
chunkSize?: number;
|
|
16
|
+
schema: z.ZodType<TObject>;
|
|
17
|
+
});
|
|
18
|
+
readAll(params: {
|
|
19
|
+
fileHandle: FileStorageFileHandle;
|
|
20
|
+
}): Promise<TObject[]>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AbstractStorage } from "../storages/abstract";
|
|
2
|
+
export declare class SQLiteStorage<TObject> extends AbstractStorage<TObject> {
|
|
3
|
+
protected readonly path: string;
|
|
4
|
+
protected readonly codec: AbstractSQLiteStorageCodec<TObject>;
|
|
5
|
+
protected db: SQLiteDatabase | undefined;
|
|
6
|
+
constructor(config: {
|
|
7
|
+
path: string;
|
|
8
|
+
codec: AbstractSQLiteStorageCodec<TObject>;
|
|
9
|
+
});
|
|
10
|
+
init(params?: unknown): Promise<void>;
|
|
11
|
+
read(key: string, params?: unknown): Promise<TObject | null>;
|
|
12
|
+
readAll(params?: unknown): Promise<TObject[]>;
|
|
13
|
+
write(key: string, value: TObject, params?: unknown): Promise<unknown>;
|
|
14
|
+
close(): void;
|
|
15
|
+
protected assertInitialized(): asserts this is this & {
|
|
16
|
+
db: SQLiteDatabase;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class AbstractSQLiteStorageCodec<TObject> {
|
|
20
|
+
init?(params: {
|
|
21
|
+
db: SQLiteDatabase;
|
|
22
|
+
params?: unknown;
|
|
23
|
+
}): Promise<void> | void;
|
|
24
|
+
abstract read(params: {
|
|
25
|
+
db: SQLiteDatabase;
|
|
26
|
+
key: string;
|
|
27
|
+
params?: unknown;
|
|
28
|
+
}): Promise<TObject | null>;
|
|
29
|
+
abstract readAll(params: {
|
|
30
|
+
db: SQLiteDatabase;
|
|
31
|
+
params?: unknown;
|
|
32
|
+
}): Promise<TObject[]>;
|
|
33
|
+
abstract write(params: {
|
|
34
|
+
db: SQLiteDatabase;
|
|
35
|
+
key: string;
|
|
36
|
+
value: TObject;
|
|
37
|
+
params?: unknown;
|
|
38
|
+
}): Promise<unknown>;
|
|
39
|
+
}
|
|
40
|
+
type SQLiteDatabase = import("better-sqlite3").Database;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./runner";
|
|
2
|
+
import { AbstractProvider } from "../providers/index.js";
|
|
3
|
+
import { IdSchema } from "../schemas/id";
|
|
4
|
+
import { AbstractScorer } from "../scorers/abstract";
|
|
5
|
+
import { AbstractClassConstructor, ClassConstructor } from "../utilities";
|
|
6
|
+
import z from "zod";
|
|
7
|
+
export type Id = z.infer<typeof IdSchema>;
|
|
8
|
+
export type IdGenerator<TInput = unknown> = (input: TInput) => MaybePromise<Id>;
|
|
9
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
10
|
+
export declare const ScoringMethod: {
|
|
11
|
+
readonly ai: "ai";
|
|
12
|
+
readonly human: "human";
|
|
13
|
+
readonly algo: "algo";
|
|
14
|
+
};
|
|
15
|
+
export type ScoringMethod = (typeof ScoringMethod)[keyof typeof ScoringMethod];
|
|
16
|
+
export type ScorerCtor = ClassConstructor<AbstractScorer> | AbstractClassConstructor<AbstractScorer>;
|
|
17
|
+
export type ProviderCtor = ClassConstructor<AbstractProvider> | AbstractClassConstructor<AbstractProvider>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AbstractProvider } from "../providers/index.js";
|
|
2
|
+
import { AbstractScorer } from "../scorers/index.js";
|
|
3
|
+
import { IdGenerator } from ".";
|
|
4
|
+
import z from "zod";
|
|
5
|
+
export type Runner<TTestCase extends z.ZodObject, TResponse extends z.ZodObject, TScore extends z.ZodObject, TProvider extends AbstractProvider, TScorer extends AbstractScorer, TRunConfig extends Record<string, unknown>> = (params: {
|
|
6
|
+
testCase: z.infer<TTestCase>;
|
|
7
|
+
provider: TProvider;
|
|
8
|
+
scorer?: TScorer;
|
|
9
|
+
runConfig: TRunConfig;
|
|
10
|
+
idGenerators?: {
|
|
11
|
+
response?: IdGenerator;
|
|
12
|
+
score?: IdGenerator;
|
|
13
|
+
};
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
response: z.infer<TResponse>;
|
|
16
|
+
score?: z.infer<TScore>;
|
|
17
|
+
}>;
|
|
18
|
+
export type InferRunConfig<TRunConfigSchema extends z.ZodRawShape> = z.infer<z.ZodObject<TRunConfigSchema>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export type ClassConstructor<T> = new (...args: any[]) => T;
|
|
3
|
+
export type AbstractClassConstructor<T> = abstract new (...args: any[]) => T;
|
|
4
|
+
export type InferExtension<TExtension extends z.ZodRawShape, TBase = unknown> = z.infer<z.ZodObject<TExtension>> & TBase;
|
|
5
|
+
type WidenLiteralSchema<S> = S extends z.ZodString ? z.ZodString | z.ZodLiteral<string> : S extends z.ZodNumber ? z.ZodNumber | z.ZodLiteral<number> : S extends z.ZodBoolean ? z.ZodBoolean | z.ZodLiteral<boolean> : S extends z.ZodLiteral<infer L> ? L extends string ? z.ZodString | z.ZodLiteral<L> : L extends number ? z.ZodNumber | z.ZodLiteral<L> : L extends boolean ? z.ZodBoolean | z.ZodLiteral<L> : S : S extends z.ZodOptional<infer O> ? z.ZodOptional<WidenLiteralSchema<O>> : S extends z.ZodType ? S : never;
|
|
6
|
+
export type WidenZodObject<T extends z.ZodObject> = z.ZodObject<{
|
|
7
|
+
[K in keyof T["shape"]]: WidenLiteralSchema<T["shape"][K]>;
|
|
8
|
+
}>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses JSONL formatted string into an array
|
|
3
|
+
* @returns An array of parsed JSON lines
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseJSONL<T>(str: string, options?: {
|
|
6
|
+
errorOnInvalid?: boolean;
|
|
7
|
+
}): T[];
|
|
8
|
+
/**
|
|
9
|
+
* Tries to parse the given string as JSON.
|
|
10
|
+
* Returns `undefined` if it is not a valid JSON entity.
|
|
11
|
+
*/
|
|
12
|
+
export declare function tryParseJson<T = any>(content: string): T | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Stringifies the given JSON value using `safe-stable-stringify` in a stable manner.
|
|
15
|
+
* This stable method generates the same string output for the same input value (including objects).
|
|
16
|
+
*/
|
|
17
|
+
export declare function stableStringify(value: any): string | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tries to repair and parse LLM response as a JSON object. LLM must
|
|
3
|
+
* be configured to return a JSON object. This function only helps to
|
|
4
|
+
* get rid out of some additional formatting (e.g. ```json) and repair
|
|
5
|
+
* the JSON syntax (e.g missing comma, single quotes instead double).
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseResponseAsJSON<T>(response: string): T | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface RateLimiterOptions {
|
|
1
|
+
export interface RateLimiterOptions {
|
|
2
2
|
/**
|
|
3
3
|
* Maximum weight of calls allowed within a time window. Each call has a weight of 1 by default.
|
|
4
4
|
* Rate limiting is disabled when this is 0 or negative.
|
|
@@ -11,7 +11,7 @@ interface RateLimiterOptions {
|
|
|
11
11
|
*/
|
|
12
12
|
timeWindow?: number;
|
|
13
13
|
}
|
|
14
|
-
interface RateLimiterCallOptions {
|
|
14
|
+
export interface RateLimiterCallOptions {
|
|
15
15
|
/**
|
|
16
16
|
* Weight of the call. Rate limiting is applied based on the total weight of the calls.
|
|
17
17
|
* @default 1
|
|
@@ -26,7 +26,7 @@ interface RateLimiterCallOptions {
|
|
|
26
26
|
* Generic rate limiter. It can be used to limit async function calls
|
|
27
27
|
* by a given number of calls within a time window.
|
|
28
28
|
*/
|
|
29
|
-
declare class RateLimiter {
|
|
29
|
+
export declare class RateLimiter {
|
|
30
30
|
maxWeight: number;
|
|
31
31
|
timeWindow: number;
|
|
32
32
|
private timestamps;
|
|
@@ -56,5 +56,3 @@ declare class RateLimiter {
|
|
|
56
56
|
*/
|
|
57
57
|
reset(): void;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
export { RateLimiter as R, type RateLimiterOptions as a, type RateLimiterCallOptions as b };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts the given byte array to a string
|
|
3
|
+
*/
|
|
4
|
+
export declare function bufferToString(buffer: Uint8Array, encoding?: BufferEncoding): string;
|
|
5
|
+
/**
|
|
6
|
+
* Converts the given string to a byte array
|
|
7
|
+
*/
|
|
8
|
+
export declare function stringToBuffer(str: string): Uint8Array;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peerbench",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Tooling help work with AI benchmarking data and create trustworthy AI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"lint": "tsc && eslint",
|
|
81
|
-
"dev": "tsup --silent --watch --onSuccess 'tsc-alias -p tsconfig.json -f'",
|
|
82
|
-
"build": "tsup
|
|
81
|
+
"dev": "tsup --silent --watch --onSuccess 'tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json -f'",
|
|
82
|
+
"build": "tsup && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json -f",
|
|
83
83
|
"test": "vitest run",
|
|
84
84
|
"clean": "rm -rf dist"
|
|
85
85
|
},
|
package/dist/index-Cn20kPrz.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { A as AbstractProvider } from './provider-DnEBdl1n.js';
|
|
2
|
-
import z__default, { z } from 'zod';
|
|
3
|
-
import { A as AbstractScorer } from './abstract-BdgLjkNC.js';
|
|
4
|
-
|
|
5
|
-
declare const IdSchema: z__default.ZodString;
|
|
6
|
-
|
|
7
|
-
type ClassConstructor<T> = new (...args: any[]) => T;
|
|
8
|
-
type AbstractClassConstructor<T> = abstract new (...args: any[]) => T;
|
|
9
|
-
type InferExtension<TExtension extends z.ZodRawShape, TBase = unknown> = z.infer<z.ZodObject<TExtension>> & TBase;
|
|
10
|
-
type WidenLiteralSchema<S> = S extends z.ZodString ? z.ZodString | z.ZodLiteral<string> : S extends z.ZodNumber ? z.ZodNumber | z.ZodLiteral<number> : S extends z.ZodBoolean ? z.ZodBoolean | z.ZodLiteral<boolean> : S extends z.ZodLiteral<infer L> ? L extends string ? z.ZodString | z.ZodLiteral<L> : L extends number ? z.ZodNumber | z.ZodLiteral<L> : L extends boolean ? z.ZodBoolean | z.ZodLiteral<L> : S : S extends z.ZodOptional<infer O> ? z.ZodOptional<WidenLiteralSchema<O>> : S extends z.ZodType ? S : never;
|
|
11
|
-
type WidenZodObject<T extends z.ZodObject> = z.ZodObject<{
|
|
12
|
-
[K in keyof T["shape"]]: WidenLiteralSchema<T["shape"][K]>;
|
|
13
|
-
}>;
|
|
14
|
-
|
|
15
|
-
type Id = z__default.infer<typeof IdSchema>;
|
|
16
|
-
type IdGenerator<TInput = unknown> = (input: TInput) => MaybePromise<Id>;
|
|
17
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
18
|
-
declare const ScoringMethod: {
|
|
19
|
-
readonly ai: "ai";
|
|
20
|
-
readonly human: "human";
|
|
21
|
-
readonly algo: "algo";
|
|
22
|
-
};
|
|
23
|
-
type ScoringMethod = (typeof ScoringMethod)[keyof typeof ScoringMethod];
|
|
24
|
-
type ScorerCtor = ClassConstructor<AbstractScorer> | AbstractClassConstructor<AbstractScorer>;
|
|
25
|
-
type ProviderCtor = ClassConstructor<AbstractProvider> | AbstractClassConstructor<AbstractProvider>;
|
|
26
|
-
|
|
27
|
-
export { type AbstractClassConstructor as A, type ClassConstructor as C, type IdGenerator as I, type MaybePromise as M, type ProviderCtor as P, type ScorerCtor as S, type WidenZodObject as W, type InferExtension as a, type Id as b, ScoringMethod as c, IdSchema as d };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { FileHandle } from 'node:fs/promises';
|
|
2
|
-
import z__default from 'zod';
|
|
3
|
-
|
|
4
|
-
declare abstract class AbstractStorage<TObject> {
|
|
5
|
-
abstract init(params?: unknown): Promise<void>;
|
|
6
|
-
abstract read(key: string, params?: unknown): Promise<TObject | null>;
|
|
7
|
-
abstract readAll(params?: unknown): Promise<TObject[]>;
|
|
8
|
-
abstract write(key: string, value: TObject, params?: unknown): Promise<unknown>;
|
|
9
|
-
count(): Promise<number>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare class FileStorage<TObject> extends AbstractStorage<TObject> {
|
|
13
|
-
protected path: string;
|
|
14
|
-
protected codec: AbstractFileStorageCodec<TObject>;
|
|
15
|
-
protected fileHandle: FileHandle | undefined;
|
|
16
|
-
constructor(config: {
|
|
17
|
-
path: string;
|
|
18
|
-
codec: AbstractFileStorageCodec<TObject>;
|
|
19
|
-
});
|
|
20
|
-
init(): Promise<void>;
|
|
21
|
-
read(_key: string, _params?: unknown): Promise<TObject | null>;
|
|
22
|
-
readAll(_params?: unknown): Promise<TObject[]>;
|
|
23
|
-
write(_key: string, _value: TObject, _params?: unknown): Promise<unknown>;
|
|
24
|
-
protected readChunks(params: {
|
|
25
|
-
startOffset?: number;
|
|
26
|
-
chunkSize: number;
|
|
27
|
-
}): AsyncIterable<{
|
|
28
|
-
offset: number;
|
|
29
|
-
bytes: Uint8Array;
|
|
30
|
-
}>;
|
|
31
|
-
protected size(): Promise<number>;
|
|
32
|
-
protected readAt(offset: number, length: number): Promise<Uint8Array>;
|
|
33
|
-
protected assertInitialized(): asserts this is this & {
|
|
34
|
-
fileHandle: FileHandle;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
type FileStorageFileHandle = {
|
|
38
|
-
size(): Promise<number>;
|
|
39
|
-
readAt(offset: number, length: number): Promise<Uint8Array>;
|
|
40
|
-
readChunks(params: {
|
|
41
|
-
startOffset?: number;
|
|
42
|
-
chunkSize: number;
|
|
43
|
-
}): AsyncIterable<{
|
|
44
|
-
offset: number;
|
|
45
|
-
bytes: Uint8Array;
|
|
46
|
-
}>;
|
|
47
|
-
};
|
|
48
|
-
declare abstract class AbstractFileStorageCodec<TObject> {
|
|
49
|
-
abstract readAll(params: {
|
|
50
|
-
fileHandle: FileStorageFileHandle;
|
|
51
|
-
}): Promise<TObject[]>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare class JSONFileStorage<TObject> extends FileStorage<TObject> {
|
|
55
|
-
codec: JSONFileStorageCodec<TObject>;
|
|
56
|
-
constructor(config: {
|
|
57
|
-
path: string;
|
|
58
|
-
chunkSize?: number;
|
|
59
|
-
schema: z__default.ZodType<TObject>;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
declare class JSONFileStorageCodec<TObject> extends AbstractFileStorageCodec<TObject> {
|
|
63
|
-
private chunkSize;
|
|
64
|
-
private schema;
|
|
65
|
-
constructor(config: {
|
|
66
|
-
chunkSize?: number;
|
|
67
|
-
schema: z__default.ZodType<TObject>;
|
|
68
|
-
});
|
|
69
|
-
readAll(params: {
|
|
70
|
-
fileHandle: FileStorageFileHandle;
|
|
71
|
-
}): Promise<TObject[]>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export { AbstractStorage as A, FileStorage as F, JSONFileStorage as J, JSONFileStorageCodec as a, type FileStorageFileHandle as b, AbstractFileStorageCodec as c };
|
package/dist/llm-8ecJmwKJ.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { A as AbstractProvider, P as ProviderResponse } from './provider-DnEBdl1n.js';
|
|
2
|
-
import { ResponseFormatText, ResponseFormatJSONSchema, ResponseFormatJSONObject } from 'openai/resources/shared';
|
|
3
|
-
import { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
|
|
4
|
-
|
|
5
|
-
declare abstract class AbstractLLMProvider extends AbstractProvider {
|
|
6
|
-
abstract forward(args: LLMProviderForwardArgs): Promise<ChatResponse>;
|
|
7
|
-
}
|
|
8
|
-
type LLMProviderForwardArgs = {
|
|
9
|
-
messages: ChatCompletionMessageParam[];
|
|
10
|
-
model: string;
|
|
11
|
-
abortSignal?: AbortSignal;
|
|
12
|
-
temperature?: number;
|
|
13
|
-
responseFormat?: ResponseFormatText | ResponseFormatJSONSchema | ResponseFormatJSONObject;
|
|
14
|
-
};
|
|
15
|
-
type ChatResponse = ProviderResponse<string> & {
|
|
16
|
-
inputTokensUsed?: number;
|
|
17
|
-
outputTokensUsed?: number;
|
|
18
|
-
inputCost?: string;
|
|
19
|
-
outputCost?: string;
|
|
20
|
-
metadata?: Record<string, unknown>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { AbstractLLMProvider as A, type ChatResponse as C, type LLMProviderForwardArgs as L };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { A as AbstractScorer, B as BaseScorerResult } from './abstract-BdgLjkNC.js';
|
|
2
|
-
import { A as AbstractLLMProvider } from './llm-8ecJmwKJ.js';
|
|
3
|
-
import { R as RateLimiter } from './rate-limiter-CSmVIRsM.js';
|
|
4
|
-
import z__default from 'zod';
|
|
5
|
-
|
|
6
|
-
type MCQScorerParams = {
|
|
7
|
-
response: string;
|
|
8
|
-
choices: Record<string, string>;
|
|
9
|
-
correctAnswers: string[];
|
|
10
|
-
};
|
|
11
|
-
declare const MCQScorer_base: (new () => AbstractScorer & {
|
|
12
|
-
readonly kind: "peerbench.ai/mcq";
|
|
13
|
-
}) & {
|
|
14
|
-
readonly kind: "peerbench.ai/mcq";
|
|
15
|
-
};
|
|
16
|
-
declare class MCQScorer extends MCQScorer_base {
|
|
17
|
-
private regexScorer;
|
|
18
|
-
score(params: MCQScorerParams): Promise<BaseScorerResult & {
|
|
19
|
-
extractedAnswers: string[];
|
|
20
|
-
}>;
|
|
21
|
-
private buildPatternsForAnswer;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const LLMAsAJudgeScorer_base: (new () => AbstractScorer & {
|
|
25
|
-
readonly kind: "peerbench.ai/llm-as-a-judge";
|
|
26
|
-
}) & {
|
|
27
|
-
readonly kind: "peerbench.ai/llm-as-a-judge";
|
|
28
|
-
};
|
|
29
|
-
declare class LLMAsAJudgeScorer extends LLMAsAJudgeScorer_base {
|
|
30
|
-
private provider;
|
|
31
|
-
constructor(config: {
|
|
32
|
-
provider: AbstractLLMProvider;
|
|
33
|
-
rateLimiter?: RateLimiter;
|
|
34
|
-
});
|
|
35
|
-
score<T extends z__default.ZodRawShape>(params: LLMAsAJudgeScoreParams & {
|
|
36
|
-
fieldsToExtract: T;
|
|
37
|
-
}): Promise<ScorerResultWithExtractedFields<T> | null>;
|
|
38
|
-
score(params: LLMAsAJudgeScoreParams & {
|
|
39
|
-
fieldsToExtract?: never;
|
|
40
|
-
}): Promise<ScorerResultWithoutExtractedFields | null>;
|
|
41
|
-
}
|
|
42
|
-
type LLMAsAJudgeCriterion = {
|
|
43
|
-
id: string;
|
|
44
|
-
description: string;
|
|
45
|
-
weight: number;
|
|
46
|
-
scale?: {
|
|
47
|
-
min: number;
|
|
48
|
-
max: number;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
type LLMAsAJudgeScoreParams = {
|
|
52
|
-
model: string;
|
|
53
|
-
response: string;
|
|
54
|
-
rubric: string;
|
|
55
|
-
criteria: LLMAsAJudgeCriterion[];
|
|
56
|
-
systemPrompt?: string;
|
|
57
|
-
maxExplanationLength?: number;
|
|
58
|
-
};
|
|
59
|
-
type ScorerResultWithoutExtractedFields = BaseScorerResult & {
|
|
60
|
-
results: {
|
|
61
|
-
id: string;
|
|
62
|
-
score: number;
|
|
63
|
-
explanation: string;
|
|
64
|
-
}[];
|
|
65
|
-
provider: string;
|
|
66
|
-
inputTokensUsed?: number;
|
|
67
|
-
outputTokensUsed?: number;
|
|
68
|
-
inputCost?: string;
|
|
69
|
-
outputCost?: string;
|
|
70
|
-
};
|
|
71
|
-
type ScorerResultWithExtractedFields<T extends z__default.ZodRawShape> = ScorerResultWithoutExtractedFields & {
|
|
72
|
-
extractedFields: z__default.infer<z__default.ZodObject<T>>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export { LLMAsAJudgeScorer as L, type MCQScorerParams as M, MCQScorer as a, type LLMAsAJudgeCriterion as b, type LLMAsAJudgeScoreParams as c };
|
|
File without changes
|