@arizeai/phoenix-evals 0.2.0 → 0.2.2
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/README.md +30 -1
- package/dist/esm/llm/ClassificationEvaluator.d.ts +17 -0
- package/dist/esm/llm/ClassificationEvaluator.d.ts.map +1 -0
- package/dist/esm/llm/ClassificationEvaluator.js +33 -0
- package/dist/esm/llm/ClassificationEvaluator.js.map +1 -0
- package/dist/esm/llm/LLMEvaluator.d.ts +12 -0
- package/dist/esm/llm/LLMEvaluator.d.ts.map +1 -0
- package/dist/esm/llm/LLMEvaluator.js +13 -0
- package/dist/esm/llm/LLMEvaluator.js.map +1 -0
- package/dist/esm/llm/createClassificationEvaluator.d.ts +3 -2
- package/dist/esm/llm/createClassificationEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/createClassificationEvaluator.js +2 -7
- package/dist/esm/llm/createClassificationEvaluator.js.map +1 -1
- package/dist/esm/llm/createClassifierFn.d.ts +1 -1
- package/dist/esm/llm/createClassifierFn.d.ts.map +1 -1
- package/dist/esm/llm/createClassifierFn.js.map +1 -1
- package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts +5 -4
- package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/createDocumentRelevancyEvaluator.js.map +1 -1
- package/dist/esm/llm/createHallucinationEvaluator.d.ts +5 -4
- package/dist/esm/llm/createHallucinationEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/createHallucinationEvaluator.js.map +1 -1
- package/dist/esm/llm/generateClassification.d.ts +2 -2
- package/dist/esm/llm/generateClassification.d.ts.map +1 -1
- package/dist/esm/llm/generateClassification.js.map +1 -1
- package/dist/esm/template/getTemplateVariables.d.ts +12 -0
- package/dist/esm/template/getTemplateVariables.d.ts.map +1 -0
- package/dist/esm/template/getTemplateVariables.js +18 -0
- package/dist/esm/template/getTemplateVariables.js.map +1 -0
- package/dist/esm/template/index.d.ts +1 -0
- package/dist/esm/template/index.d.ts.map +1 -1
- package/dist/esm/template/index.js +1 -0
- package/dist/esm/template/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types/evals.d.ts +13 -6
- package/dist/esm/types/evals.d.ts.map +1 -1
- package/dist/esm/types/otel.d.ts +2 -2
- package/dist/esm/types/otel.d.ts.map +1 -1
- package/dist/esm/types/prompts.d.ts +2 -16
- package/dist/esm/types/prompts.d.ts.map +1 -1
- package/dist/src/llm/ClassificationEvaluator.d.ts +17 -0
- package/dist/src/llm/ClassificationEvaluator.d.ts.map +1 -0
- package/dist/src/llm/ClassificationEvaluator.js +34 -0
- package/dist/src/llm/ClassificationEvaluator.js.map +1 -0
- package/dist/src/llm/LLMEvaluator.d.ts +12 -0
- package/dist/src/llm/LLMEvaluator.d.ts.map +1 -0
- package/dist/src/llm/LLMEvaluator.js +15 -0
- package/dist/src/llm/LLMEvaluator.js.map +1 -0
- package/dist/src/llm/createClassificationEvaluator.d.ts +3 -2
- package/dist/src/llm/createClassificationEvaluator.d.ts.map +1 -1
- package/dist/src/llm/createClassificationEvaluator.js +2 -7
- package/dist/src/llm/createClassificationEvaluator.js.map +1 -1
- package/dist/src/llm/createClassifierFn.d.ts +1 -1
- package/dist/src/llm/createClassifierFn.d.ts.map +1 -1
- package/dist/src/llm/createClassifierFn.js.map +1 -1
- package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts +5 -4
- package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts.map +1 -1
- package/dist/src/llm/createDocumentRelevancyEvaluator.js.map +1 -1
- package/dist/src/llm/createHallucinationEvaluator.d.ts +5 -4
- package/dist/src/llm/createHallucinationEvaluator.d.ts.map +1 -1
- package/dist/src/llm/createHallucinationEvaluator.js.map +1 -1
- package/dist/src/llm/generateClassification.d.ts +2 -2
- package/dist/src/llm/generateClassification.d.ts.map +1 -1
- package/dist/src/llm/generateClassification.js.map +1 -1
- package/dist/src/template/getTemplateVariables.d.ts +12 -0
- package/dist/src/template/getTemplateVariables.d.ts.map +1 -0
- package/dist/src/template/getTemplateVariables.js +24 -0
- package/dist/src/template/getTemplateVariables.js.map +1 -0
- package/dist/src/template/index.d.ts +1 -0
- package/dist/src/template/index.d.ts.map +1 -1
- package/dist/src/template/index.js +1 -0
- package/dist/src/template/index.js.map +1 -1
- package/dist/src/types/evals.d.ts +13 -6
- package/dist/src/types/evals.d.ts.map +1 -1
- package/dist/src/types/otel.d.ts +2 -2
- package/dist/src/types/otel.d.ts.map +1 -1
- package/dist/src/types/prompts.d.ts +2 -16
- package/dist/src/types/prompts.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/llm/ClassificationEvaluator.ts +40 -0
- package/src/llm/LLMEvaluator.ts +22 -0
- package/src/llm/createClassificationEvaluator.ts +7 -10
- package/src/llm/createClassifierFn.ts +4 -4
- package/src/llm/createDocumentRelevancyEvaluator.ts +11 -7
- package/src/llm/createHallucinationEvaluator.ts +8 -7
- package/src/llm/generateClassification.ts +16 -14
- package/src/template/getTemplateVariables.ts +22 -0
- package/src/template/index.ts +1 -0
- package/src/types/evals.ts +18 -7
- package/src/types/otel.ts +2 -2
- package/src/types/prompts.ts +2 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evals.d.ts","sourceRoot":"","sources":["../../../src/types/evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,EAAE,SAAS;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"evals.d.ts","sourceRoot":"","sources":["../../../src/types/evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,EAAE,SAAS;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;AAGD,MAAM,WAAW,iBAAkB,SAAQ,OAAO;CAAG;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IAIzD,KAAK,EAAE,aAAa,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,wBAAwB,CAAC;IAClC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,MAAM,WAAW,iCACf,SAAQ,oBAAoB,EAC1B,mBAAmB;CAAG;AAE1B,MAAM,MAAM,WAAW,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CACrE,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D;;GAEG;AACH,UAAU,oBAAoB;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACpE,SAAQ,oBAAoB;IAC5B;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CACpC"}
|
package/dist/esm/types/otel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tracer } from "@opentelemetry/api";
|
|
2
|
-
export
|
|
2
|
+
export type WithTelemetry = {
|
|
3
3
|
telemetry?: {
|
|
4
4
|
/**
|
|
5
5
|
* Whether OpenTelemetry is enabled on the call.
|
|
@@ -13,5 +13,5 @@ export interface WithTelemetry {
|
|
|
13
13
|
*/
|
|
14
14
|
tracer?: Tracer;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
//# sourceMappingURL=otel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE;QACV;;;;WAIG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC"}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Prompt } from "ai";
|
|
2
2
|
/**
|
|
3
3
|
* Prompt part of the AI function options for model generation.
|
|
4
4
|
* It contains a system message, a simple text prompt, or a list of model messages.
|
|
5
5
|
* Uses ModelMessage format compatible with AI SDK v5 generateObject function.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
* System message to include in the prompt. Can be used with `prompt` or `messages`.
|
|
10
|
-
*/
|
|
11
|
-
system?: string;
|
|
12
|
-
/**
|
|
13
|
-
* A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
14
|
-
*/
|
|
15
|
-
prompt?: string;
|
|
16
|
-
/**
|
|
17
|
-
* A list of model messages. You can either use `prompt` or `messages` but not both.
|
|
18
|
-
* Uses ModelMessage format for compatibility with AI SDK v5.
|
|
19
|
-
*/
|
|
20
|
-
messages?: Array<ModelMessage>;
|
|
21
|
-
}
|
|
7
|
+
export type WithPrompt = Prompt;
|
|
22
8
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CreateClassificationEvaluatorArgs, EvaluatorFn, Template } from "../types";
|
|
2
|
+
import { LLMEvaluator } from "./LLMEvaluator";
|
|
3
|
+
/**
|
|
4
|
+
* An LLM evaluator that performs evaluation via classification
|
|
5
|
+
*/
|
|
6
|
+
export declare class ClassificationEvaluator<RecordType extends Record<string, unknown>> extends LLMEvaluator<RecordType> {
|
|
7
|
+
readonly evaluatorFn: EvaluatorFn<RecordType>;
|
|
8
|
+
readonly promptTemplate: Template;
|
|
9
|
+
private _promptTemplateVariables;
|
|
10
|
+
constructor(args: CreateClassificationEvaluatorArgs);
|
|
11
|
+
evaluate: (example: RecordType) => Promise<import("../types").EvaluationResult>;
|
|
12
|
+
/**
|
|
13
|
+
* List out the prompt template variables needed to perform evaluation
|
|
14
|
+
*/
|
|
15
|
+
get promptTemplateVariables(): string[];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ClassificationEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassificationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/ClassificationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,WAAW,EACX,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,qBAAa,uBAAuB,CAClC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC1C,SAAQ,YAAY,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAClC,OAAO,CAAC,wBAAwB,CAAuB;gBAC3C,IAAI,EAAE,iCAAiC;IAKnD,QAAQ,GAAI,SAAS,UAAU,kDAE7B;IACF;;OAEG;IACH,IAAI,uBAAuB,IAAI,MAAM,EAAE,CAStC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassificationEvaluator = void 0;
|
|
4
|
+
const createClassifierFn_1 = require("./createClassifierFn");
|
|
5
|
+
const LLMEvaluator_1 = require("./LLMEvaluator");
|
|
6
|
+
const template_1 = require("../template");
|
|
7
|
+
/**
|
|
8
|
+
* An LLM evaluator that performs evaluation via classification
|
|
9
|
+
*/
|
|
10
|
+
class ClassificationEvaluator extends LLMEvaluator_1.LLMEvaluator {
|
|
11
|
+
constructor(args) {
|
|
12
|
+
super(args);
|
|
13
|
+
this.evaluate = (example) => {
|
|
14
|
+
return this.evaluatorFn(example);
|
|
15
|
+
};
|
|
16
|
+
this.promptTemplate = args.promptTemplate;
|
|
17
|
+
this.evaluatorFn = (0, createClassifierFn_1.createClassifierFn)(args);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* List out the prompt template variables needed to perform evaluation
|
|
21
|
+
*/
|
|
22
|
+
get promptTemplateVariables() {
|
|
23
|
+
// Use dynamic programming to see if it's computed already
|
|
24
|
+
if (!Array.isArray(this._promptTemplateVariables)) {
|
|
25
|
+
this._promptTemplateVariables = (0, template_1.getTemplateVariables)({
|
|
26
|
+
template: this.promptTemplate,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Give a copy of the variables
|
|
30
|
+
return [...this._promptTemplateVariables];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ClassificationEvaluator = ClassificationEvaluator;
|
|
34
|
+
//# sourceMappingURL=ClassificationEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassificationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/ClassificationEvaluator.ts"],"names":[],"mappings":";;;AAKA,6DAA0D;AAC1D,iDAA8C;AAC9C,0CAAmD;AAEnD;;GAEG;AACH,MAAa,uBAEX,SAAQ,2BAAwB;IAIhC,YAAY,IAAuC;QACjD,KAAK,CAAC,IAAI,CAAC,CAAC;QAId,aAAQ,GAAG,CAAC,OAAmB,EAAE,EAAE;YACjC,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC;QALA,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAA,uCAAkB,EAAa,IAAI,CAAC,CAAC;IAC1D,CAAC;IAID;;OAEG;IACH,IAAI,uBAAuB;QACzB,0DAA0D;QAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,wBAAwB,GAAG,IAAA,+BAAoB,EAAC;gBACnD,QAAQ,EAAE,IAAI,CAAC,cAAc;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,+BAA+B;QAC/B,OAAO,CAAC,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;CACF;AA3BD,0DA2BC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EvaluationResult, Evaluator, OptimizationDirection, CreateEvaluatorArgs } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for llm evaluation metrics / scores
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class LLMEvaluator<RecordType extends Record<string, unknown>> implements Evaluator<RecordType> {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly source: "LLM";
|
|
8
|
+
readonly optimizationDirection?: OptimizationDirection;
|
|
9
|
+
constructor({ name, optimizationDirection }: CreateEvaluatorArgs);
|
|
10
|
+
abstract evaluate(_example: RecordType): Promise<EvaluationResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LLMEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/LLMEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,8BAAsB,YAAY,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3E,YAAW,SAAS,CAAC,UAAU,CAAC;IAEhC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAG,KAAK,CAAU;IACjC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;gBAC3C,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,mBAAmB;IAIhE,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;CACnE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LLMEvaluator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base class for llm evaluation metrics / scores
|
|
6
|
+
*/
|
|
7
|
+
class LLMEvaluator {
|
|
8
|
+
constructor({ name, optimizationDirection }) {
|
|
9
|
+
this.source = "LLM";
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.optimizationDirection = optimizationDirection;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LLMEvaluator = LLMEvaluator;
|
|
15
|
+
//# sourceMappingURL=LLMEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMEvaluator.js","sourceRoot":"","sources":["../../../src/llm/LLMEvaluator.ts"],"names":[],"mappings":";;;AAOA;;GAEG;AACH,MAAsB,YAAY;IAMhC,YAAY,EAAE,IAAI,EAAE,qBAAqB,EAAuB;QAFvD,WAAM,GAAG,KAAc,CAAC;QAG/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACrD,CAAC;CAEF;AAXD,oCAWC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { CreateClassificationEvaluatorArgs
|
|
2
|
-
|
|
1
|
+
import { CreateClassificationEvaluatorArgs } from "../types/evals";
|
|
2
|
+
import { ClassificationEvaluator } from "./ClassificationEvaluator";
|
|
3
|
+
export declare function createClassificationEvaluator<RecordType extends Record<string, unknown>>(args: CreateClassificationEvaluatorArgs): ClassificationEvaluator<RecordType>;
|
|
3
4
|
//# sourceMappingURL=createClassificationEvaluator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClassificationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassificationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,
|
|
1
|
+
{"version":3,"file":"createClassificationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassificationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,wBAAgB,6BAA6B,CAC3C,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE1C,IAAI,EAAE,iCAAiC,GACtC,uBAAuB,CAAC,UAAU,CAAC,CAErC"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createClassificationEvaluator = createClassificationEvaluator;
|
|
4
|
-
const
|
|
4
|
+
const ClassificationEvaluator_1 = require("./ClassificationEvaluator");
|
|
5
5
|
function createClassificationEvaluator(args) {
|
|
6
|
-
return
|
|
7
|
-
name: args.name,
|
|
8
|
-
source: "LLM",
|
|
9
|
-
optimizationDirection: args.optimizationDirection,
|
|
10
|
-
evaluate: (0, createClassifierFn_1.createClassifierFn)(args),
|
|
11
|
-
};
|
|
6
|
+
return new ClassificationEvaluator_1.ClassificationEvaluator(args);
|
|
12
7
|
}
|
|
13
8
|
//# sourceMappingURL=createClassificationEvaluator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClassificationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createClassificationEvaluator.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"createClassificationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createClassificationEvaluator.ts"],"names":[],"mappings":";;AAGA,sEAMC;AARD,uEAAoE;AAEpE,SAAgB,6BAA6B,CAG3C,IAAuC;IAEvC,OAAO,IAAI,iDAAuB,CAAa,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -2,5 +2,5 @@ import { CreateClassifierArgs, EvaluatorFn } from "../types/evals";
|
|
|
2
2
|
/**
|
|
3
3
|
* A function that serves as a factory that will output a classification evaluator function
|
|
4
4
|
*/
|
|
5
|
-
export declare function createClassifierFn<
|
|
5
|
+
export declare function createClassifierFn<RecordToEvaluate extends Record<string, unknown>>(args: CreateClassifierArgs): EvaluatorFn<RecordToEvaluate>;
|
|
6
6
|
//# sourceMappingURL=createClassifierFn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClassifierFn.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassifierFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EACpB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAkBxB;;GAEG;AACH,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"createClassifierFn.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassifierFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EACpB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAkBxB;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,gBAAgB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChD,IAAI,EAAE,oBAAoB,GAAG,WAAW,CAAC,gBAAgB,CAAC,CA4B3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClassifierFn.js","sourceRoot":"","sources":["../../../src/llm/createClassifierFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA0BA,gDA8BC;AAlDD,qEAAkE;AAClE,0CAA6C;AAE7C;;;GAGG;AACH,SAAS,eAAe,CACtB,OAAiC;IAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAA+B,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"createClassifierFn.js","sourceRoot":"","sources":["../../../src/llm/createClassifierFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA0BA,gDA8BC;AAlDD,qEAAkE;AAClE,0CAA6C;AAE7C;;;GAGG;AACH,SAAS,eAAe,CACtB,OAAiC;IAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAA+B,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAEhC,IAA0B;IAC1B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,KAAc,IAAI,EAAb,IAAI,UAAK,IAAI,EAAlD,sCAA2C,CAAO,CAAC;IAEzD,OAAO,KAAK,EAAE,IAAsB,EAA6B,EAAE;QACjE,MAAM,iBAAiB,qBAClB,IAAI,CACR,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,yBAAc,EAAC;YAC5B,QAAQ,EAAE,cAAc;YACxB,SAAS,EAAE,iBAAiB;SAC7B,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,MAAM,IAAA,+CAAsB,kBACjD,KAAK,EACL,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,EAChC,MAAM,IACH,IAAI,EACP,CAAC;QAEH,mEAAmE;QACnE,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAE5C,uBACE,KAAK,IACF,cAAc,EACjB;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -6,12 +6,13 @@ export interface DocumentRelevancyEvaluatorArgs extends Omit<CreateClassificatio
|
|
|
6
6
|
promptTemplate?: CreateClassificationEvaluatorArgs["promptTemplate"];
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* A record to be evaluated by the document relevancy evaluator.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export interface DocumentRelevancyEvaluationRecord {
|
|
12
12
|
input: string;
|
|
13
13
|
documentText: string;
|
|
14
|
-
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
15
16
|
/**
|
|
16
17
|
* Creates a document relevancy evaluator function.
|
|
17
18
|
*
|
|
@@ -38,5 +39,5 @@ export type DocumentRelevancyExample = {
|
|
|
38
39
|
* console.log(result.label); // "relevant" or "unrelated"
|
|
39
40
|
* ```
|
|
40
41
|
*/
|
|
41
|
-
export declare function createDocumentRelevancyEvaluator(args: DocumentRelevancyEvaluatorArgs): Evaluator<
|
|
42
|
+
export declare function createDocumentRelevancyEvaluator<RecordType extends Record<string, unknown> = DocumentRelevancyEvaluationRecord>(args: DocumentRelevancyEvaluatorArgs): Evaluator<RecordType>;
|
|
42
43
|
//# sourceMappingURL=createDocumentRelevancyEvaluator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDocumentRelevancyEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO9E,MAAM,WAAW,8BACf,SAAQ,IAAI,CACV,iCAAiC,EACjC,gBAAgB,GAAG,SAAS,GAAG,uBAAuB,GAAG,MAAM,CAChE;IACD,qBAAqB,CAAC,EAAE,iCAAiC,CAAC,uBAAuB,CAAC,CAAC;IACnF,IAAI,CAAC,EAAE,iCAAiC,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,iCAAiC,CAAC,SAAS,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,iCAAiC,CAAC,gBAAgB,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"createDocumentRelevancyEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO9E,MAAM,WAAW,8BACf,SAAQ,IAAI,CACV,iCAAiC,EACjC,gBAAgB,GAAG,SAAS,GAAG,uBAAuB,GAAG,MAAM,CAChE;IACD,qBAAqB,CAAC,EAAE,iCAAiC,CAAC,uBAAuB,CAAC,CAAC;IACnF,IAAI,CAAC,EAAE,iCAAiC,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,iCAAiC,CAAC,SAAS,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,iCAAiC,CAAC,gBAAgB,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,SAAS,MAAM,CACvB,MAAM,EACN,OAAO,CACR,GAAG,iCAAiC,EACrC,IAAI,EAAE,8BAA8B,GAAG,SAAS,CAAC,UAAU,CAAC,CAiB7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDocumentRelevancyEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createDocumentRelevancyEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAqDA,4EAsBC;AA1ED,kGAG0D;AAC1D,mFAAgF;AAsBhF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,gCAAgC,CAK9C,IAAoC;IACpC,MAAM,EACJ,OAAO,GAAG,wDAA0B,EACpC,cAAc,GAAG,yDAA2B,EAC5C,qBAAqB,GAAG,UAAU,EAClC,IAAI,GAAG,oBAAoB,KAEzB,IAAI,EADH,IAAI,UACL,IAAI,EANF,8DAML,CAAO,CAAC;IAET,OAAO,IAAA,6DAA6B,gDAC/B,IAAI,KACP,cAAc;QACd,OAAO;QACP,qBAAqB;QACrB,IAAI,KACD,IAAI,EACP,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CreateClassificationEvaluatorArgs
|
|
1
|
+
import { CreateClassificationEvaluatorArgs } from "../types/evals";
|
|
2
|
+
import { ClassificationEvaluator } from "./ClassificationEvaluator";
|
|
2
3
|
export interface HallucinationEvaluatorArgs extends Omit<CreateClassificationEvaluatorArgs, "promptTemplate" | "choices" | "optimizationDirection" | "name"> {
|
|
3
4
|
optimizationDirection?: CreateClassificationEvaluatorArgs["optimizationDirection"];
|
|
4
5
|
name?: CreateClassificationEvaluatorArgs["name"];
|
|
@@ -6,9 +7,9 @@ export interface HallucinationEvaluatorArgs extends Omit<CreateClassificationEva
|
|
|
6
7
|
promptTemplate?: CreateClassificationEvaluatorArgs["promptTemplate"];
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* A record to be evaluated by the hallucination evaluator.
|
|
10
11
|
*/
|
|
11
|
-
export type
|
|
12
|
+
export type HallucinationEvaluationRecord = {
|
|
12
13
|
input: string;
|
|
13
14
|
output: string;
|
|
14
15
|
reference?: string;
|
|
@@ -20,5 +21,5 @@ export type HallucinationExample = {
|
|
|
20
21
|
* @param args - The arguments for creating the hallucination evaluator.
|
|
21
22
|
* @returns A function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
|
|
22
23
|
*/
|
|
23
|
-
export declare function createHallucinationEvaluator(args: HallucinationEvaluatorArgs):
|
|
24
|
+
export declare function createHallucinationEvaluator<RecordType extends Record<string, unknown> = HallucinationEvaluationRecord>(args: HallucinationEvaluatorArgs): ClassificationEvaluator<RecordType>;
|
|
24
25
|
//# sourceMappingURL=createHallucinationEvaluator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,
|
|
1
|
+
{"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,WAAW,0BACf,SAAQ,IAAI,CACV,iCAAiC,EACjC,gBAAgB,GAAG,SAAS,GAAG,uBAAuB,GAAG,MAAM,CAChE;IACD,qBAAqB,CAAC,EAAE,iCAAiC,CAAC,uBAAuB,CAAC,CAAC;IACnF,IAAI,CAAC,EAAE,iCAAiC,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,iCAAiC,CAAC,SAAS,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,iCAAiC,CAAC,gBAAgB,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AACF;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,6BAA6B,EAC1E,IAAI,EAAE,0BAA0B,GAAG,uBAAuB,CAAC,UAAU,CAAC,CAgBvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHallucinationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createHallucinationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAkCA,oEAkBC;AAnDD,wFAGqD;AACrD,mFAAgF;AAuBhF;;;;;GAKG;AACH,SAAgB,4BAA4B,CAE1C,IAAgC;IAChC,MAAM,EACJ,OAAO,GAAG,8CAAqB,EAC/B,cAAc,GAAG,+CAAsB,EACvC,qBAAqB,GAAG,UAAU,EAClC,IAAI,GAAG,eAAe,KAEpB,IAAI,EADH,IAAI,UACL,IAAI,EANF,8DAML,CAAO,CAAC;IACT,OAAO,IAAA,6DAA6B,gDAC/B,IAAI,KACP,cAAc;QACd,OAAO;QACP,qBAAqB;QACrB,IAAI,KACD,IAAI,EACP,CAAC;AACL,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClassificationResult, WithLLM } from "../types/evals";
|
|
2
2
|
import { WithTelemetry } from "../types/otel";
|
|
3
3
|
import type { WithPrompt } from "../types/prompts";
|
|
4
|
-
export
|
|
4
|
+
export type ClassifyArgs = WithLLM & WithTelemetry & WithPrompt & {
|
|
5
5
|
/**
|
|
6
6
|
* The labels to classify the example into. E.x. ["correct", "incorrect"]
|
|
7
7
|
*/
|
|
@@ -14,7 +14,7 @@ export interface ClassifyArgs extends WithLLM, WithPrompt, WithTelemetry {
|
|
|
14
14
|
* The description of the schema for generating the label and explanation.
|
|
15
15
|
*/
|
|
16
16
|
schemaDescription?: string;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
/**
|
|
19
19
|
* A function that leverages an llm to perform a classification
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateClassification.d.ts","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,
|
|
1
|
+
{"version":3,"file":"generateClassification.d.ts","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,MAAM,YAAY,GAAG,OAAO,GAChC,aAAa,GACb,UAAU,GAAG;IACX;;OAEG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AACJ;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAyB/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateClassification.js","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"generateClassification.js","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAyBA,wDA2BC;AAjDD,2BAAoC;AACpC,6BAAwB;AACxB,4CAAsC;AAiBtC;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,IAAkB;;IAElB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,KAC7D,IAAI,EAD8D,MAAM,UACxE,IAAI,EADA,mEAAsE,CACtE,CAAC;IAEP,MAAM,sBAAsB,GAAG;QAC7B,SAAS,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,mCAAI,IAAI;QACvC,UAAU,EAAE,wBAAwB;QACpC,MAAM,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,mCAAI,kBAAM;KACpC,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAc,kBACjC,KAAK;QACL,UAAU;QACV,iBAAiB,EACjB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;YACf,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,4EAA4E;YACrG,KAAK,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SACtB,CAAC,EACF,sBAAsB,IACnB,MAAM,EACT,CAAC;IACH,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Template } from "../types/templating";
|
|
2
|
+
type GetTemplateVariableArgs = {
|
|
3
|
+
template: Template;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Parse out the template variables of a prompt
|
|
7
|
+
* @param {GetTemplateVariableArgs} args
|
|
8
|
+
* @returns {string[]} a list of prompt template variables
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTemplateVariables(args: GetTemplateVariableArgs): string[];
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=getTemplateVariables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTemplateVariables.d.ts","sourceRoot":"","sources":["../../../src/template/getTemplateVariables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AACF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,EAAE,CAU5E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTemplateVariables = getTemplateVariables;
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
/**
|
|
9
|
+
* Parse out the template variables of a prompt
|
|
10
|
+
* @param {GetTemplateVariableArgs} args
|
|
11
|
+
* @returns {string[]} a list of prompt template variables
|
|
12
|
+
*/
|
|
13
|
+
function getTemplateVariables(args) {
|
|
14
|
+
const { template } = args;
|
|
15
|
+
const templateSpans = mustache_1.default.parse(template);
|
|
16
|
+
return templateSpans.reduce((acc, templateSpan) => {
|
|
17
|
+
const [spanType, value] = templateSpan;
|
|
18
|
+
if (spanType === "name" && typeof value === "string") {
|
|
19
|
+
acc = [...acc, value];
|
|
20
|
+
}
|
|
21
|
+
return acc;
|
|
22
|
+
}, []);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=getTemplateVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTemplateVariables.js","sourceRoot":"","sources":["../../../src/template/getTemplateVariables.ts"],"names":[],"mappings":";;;;;AAWA,oDAUC;AApBD,wDAAgC;AAKhC;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,IAA6B;IAChE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC1B,MAAM,aAAa,GAAG,kBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE;QAChD,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,YAAY,CAAC;QACvC,IAAI,QAAQ,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrD,GAAG,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAc,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/template/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/template/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./applyTemplate"), exports);
|
|
18
|
+
__exportStar(require("./getTemplateVariables"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/template/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/template/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,yDAAuC"}
|
|
@@ -67,7 +67,7 @@ export interface CreateClassifierArgs extends WithTelemetry {
|
|
|
67
67
|
*/
|
|
68
68
|
promptTemplate: string;
|
|
69
69
|
}
|
|
70
|
-
export interface
|
|
70
|
+
export interface CreateEvaluatorArgs {
|
|
71
71
|
/**
|
|
72
72
|
* The name of the metric that the evaluator produces
|
|
73
73
|
* E.x. "correctness"
|
|
@@ -79,21 +79,22 @@ export interface CreateClassificationEvaluatorArgs extends CreateClassifierArgs
|
|
|
79
79
|
*/
|
|
80
80
|
optimizationDirection?: OptimizationDirection;
|
|
81
81
|
}
|
|
82
|
+
export interface CreateClassificationEvaluatorArgs extends CreateClassifierArgs, CreateEvaluatorArgs {
|
|
83
|
+
}
|
|
82
84
|
export type EvaluatorFn<ExampleType extends Record<string, unknown>> = (args: ExampleType) => Promise<EvaluationResult>;
|
|
83
85
|
/**
|
|
84
86
|
* The source of the evaluation
|
|
85
87
|
*/
|
|
86
|
-
type EvaluationSource = "LLM" | "CODE";
|
|
88
|
+
export type EvaluationSource = "LLM" | "CODE";
|
|
87
89
|
/**
|
|
88
90
|
* The direction to optimize the numeric evaluation score
|
|
89
91
|
* E.x. "MAXIMIZE" means that the higher the score, the better the evaluation
|
|
90
92
|
*/
|
|
91
|
-
type OptimizationDirection = "MAXIMIZE" | "MINIMIZE";
|
|
93
|
+
export type OptimizationDirection = "MAXIMIZE" | "MINIMIZE";
|
|
92
94
|
/**
|
|
93
|
-
* The
|
|
94
|
-
* This is the interface that all evaluators must implement
|
|
95
|
+
* The description of an evaluator
|
|
95
96
|
*/
|
|
96
|
-
|
|
97
|
+
interface EvaluatorDescription {
|
|
97
98
|
/**
|
|
98
99
|
* The name of the evaluator / the metric that it measures
|
|
99
100
|
*/
|
|
@@ -107,6 +108,12 @@ export interface Evaluator<ExampleType extends Record<string, unknown>> {
|
|
|
107
108
|
* E.x. "MAXIMIZE" means that the higher the score, the better the evaluation
|
|
108
109
|
*/
|
|
109
110
|
optimizationDirection?: OptimizationDirection;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The Base Evaluator interface
|
|
114
|
+
* This is the interface that all evaluators must implement
|
|
115
|
+
*/
|
|
116
|
+
export interface Evaluator<ExampleType extends Record<string, unknown>> extends EvaluatorDescription {
|
|
110
117
|
/**
|
|
111
118
|
* The function that evaluates the example
|
|
112
119
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evals.d.ts","sourceRoot":"","sources":["../../../src/types/evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,EAAE,SAAS;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"evals.d.ts","sourceRoot":"","sources":["../../../src/types/evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,EAAE,SAAS;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;AAGD,MAAM,WAAW,iBAAkB,SAAQ,OAAO;CAAG;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IAIzD,KAAK,EAAE,aAAa,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,wBAAwB,CAAC;IAClC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,MAAM,WAAW,iCACf,SAAQ,oBAAoB,EAC1B,mBAAmB;CAAG;AAE1B,MAAM,MAAM,WAAW,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CACrE,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D;;GAEG;AACH,UAAU,oBAAoB;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACpE,SAAQ,oBAAoB;IAC5B;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CACpC"}
|
package/dist/src/types/otel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tracer } from "@opentelemetry/api";
|
|
2
|
-
export
|
|
2
|
+
export type WithTelemetry = {
|
|
3
3
|
telemetry?: {
|
|
4
4
|
/**
|
|
5
5
|
* Whether OpenTelemetry is enabled on the call.
|
|
@@ -13,5 +13,5 @@ export interface WithTelemetry {
|
|
|
13
13
|
*/
|
|
14
14
|
tracer?: Tracer;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
//# sourceMappingURL=otel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE;QACV;;;;WAIG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC"}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Prompt } from "ai";
|
|
2
2
|
/**
|
|
3
3
|
* Prompt part of the AI function options for model generation.
|
|
4
4
|
* It contains a system message, a simple text prompt, or a list of model messages.
|
|
5
5
|
* Uses ModelMessage format compatible with AI SDK v5 generateObject function.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
* System message to include in the prompt. Can be used with `prompt` or `messages`.
|
|
10
|
-
*/
|
|
11
|
-
system?: string;
|
|
12
|
-
/**
|
|
13
|
-
* A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
14
|
-
*/
|
|
15
|
-
prompt?: string;
|
|
16
|
-
/**
|
|
17
|
-
* A list of model messages. You can either use `prompt` or `messages` but not both.
|
|
18
|
-
* Uses ModelMessage format for compatibility with AI SDK v5.
|
|
19
|
-
*/
|
|
20
|
-
messages?: Array<ModelMessage>;
|
|
21
|
-
}
|
|
7
|
+
export type WithPrompt = Prompt;
|
|
22
8
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC"}
|