@arizeai/phoenix-evals 0.0.6 → 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.
Files changed (77) hide show
  1. package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts +6 -0
  2. package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts.map +1 -0
  3. package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js +25 -0
  4. package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js.map +1 -0
  5. package/dist/esm/default_templates/index.d.ts +1 -0
  6. package/dist/esm/default_templates/index.d.ts.map +1 -1
  7. package/dist/esm/default_templates/index.js +1 -0
  8. package/dist/esm/default_templates/index.js.map +1 -1
  9. package/dist/esm/index.d.ts +2 -0
  10. package/dist/esm/index.d.ts.map +1 -1
  11. package/dist/esm/index.js +2 -0
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/llm/createClassifier.d.ts +1 -1
  14. package/dist/esm/llm/createClassifier.d.ts.map +1 -1
  15. package/dist/esm/llm/createClassifier.js.map +1 -1
  16. package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts +40 -0
  17. package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts.map +1 -0
  18. package/dist/esm/llm/createDocumentRelevancyEvaluator.js +39 -0
  19. package/dist/esm/llm/createDocumentRelevancyEvaluator.js.map +1 -0
  20. package/dist/esm/llm/createHallucinationEvaluator.d.ts +11 -3
  21. package/dist/esm/llm/createHallucinationEvaluator.d.ts.map +1 -1
  22. package/dist/esm/llm/createHallucinationEvaluator.js.map +1 -1
  23. package/dist/esm/llm/generateClassification.d.ts +1 -2
  24. package/dist/esm/llm/generateClassification.d.ts.map +1 -1
  25. package/dist/esm/llm/index.d.ts +1 -0
  26. package/dist/esm/llm/index.d.ts.map +1 -1
  27. package/dist/esm/llm/index.js +1 -0
  28. package/dist/esm/llm/index.js.map +1 -1
  29. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  30. package/dist/esm/types/evals.d.ts +4 -4
  31. package/dist/esm/types/evals.d.ts.map +1 -1
  32. package/dist/esm/types/prompts.d.ts +7 -6
  33. package/dist/esm/types/prompts.d.ts.map +1 -1
  34. package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts +6 -0
  35. package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts.map +1 -0
  36. package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js +28 -0
  37. package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js.map +1 -0
  38. package/dist/src/default_templates/index.d.ts +1 -0
  39. package/dist/src/default_templates/index.d.ts.map +1 -1
  40. package/dist/src/default_templates/index.js +1 -0
  41. package/dist/src/default_templates/index.js.map +1 -1
  42. package/dist/src/index.d.ts +2 -0
  43. package/dist/src/index.d.ts.map +1 -1
  44. package/dist/src/index.js +2 -0
  45. package/dist/src/index.js.map +1 -1
  46. package/dist/src/llm/createClassifier.d.ts +1 -1
  47. package/dist/src/llm/createClassifier.d.ts.map +1 -1
  48. package/dist/src/llm/createClassifier.js.map +1 -1
  49. package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts +40 -0
  50. package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts.map +1 -0
  51. package/dist/src/llm/createDocumentRelevancyEvaluator.js +49 -0
  52. package/dist/src/llm/createDocumentRelevancyEvaluator.js.map +1 -0
  53. package/dist/src/llm/createHallucinationEvaluator.d.ts +11 -3
  54. package/dist/src/llm/createHallucinationEvaluator.d.ts.map +1 -1
  55. package/dist/src/llm/createHallucinationEvaluator.js.map +1 -1
  56. package/dist/src/llm/generateClassification.d.ts +1 -2
  57. package/dist/src/llm/generateClassification.d.ts.map +1 -1
  58. package/dist/src/llm/index.d.ts +1 -0
  59. package/dist/src/llm/index.d.ts.map +1 -1
  60. package/dist/src/llm/index.js +1 -0
  61. package/dist/src/llm/index.js.map +1 -1
  62. package/dist/src/types/evals.d.ts +4 -4
  63. package/dist/src/types/evals.d.ts.map +1 -1
  64. package/dist/src/types/prompts.d.ts +7 -6
  65. package/dist/src/types/prompts.d.ts.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +5 -5
  68. package/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.ts +25 -0
  69. package/src/default_templates/index.ts +1 -0
  70. package/src/index.ts +2 -0
  71. package/src/llm/createClassifier.ts +3 -6
  72. package/src/llm/createDocumentRelevancyEvaluator.ts +64 -0
  73. package/src/llm/createHallucinationEvaluator.ts +13 -3
  74. package/src/llm/generateClassification.ts +1 -1
  75. package/src/llm/index.ts +1 -0
  76. package/src/types/evals.ts +5 -7
  77. package/src/types/prompts.ts +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
package/dist/src/index.js CHANGED
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./llm"), exports);
18
+ __exportStar(require("./template"), exports);
19
+ __exportStar(require("./types"), exports);
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB"}
@@ -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
4
4
  */
5
- export declare function createClassifier<OutputType, InputType>(args: CreateClassifierArgs): EvaluatorFn<OutputType, InputType>;
5
+ export declare function createClassifier<ExampleType extends Record<string, unknown>>(args: CreateClassifierArgs): EvaluatorFn<ExampleType>;
6
6
  //# sourceMappingURL=createClassifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createClassifier.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,oBAAoB,EACpB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAkBxB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,SAAS,EACpD,IAAI,EAAE,oBAAoB,GACzB,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,CA8BpC"}
1
+ {"version":3,"file":"createClassifier.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EACpB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAkBxB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1E,IAAI,EAAE,oBAAoB,GACzB,WAAW,CAAC,WAAW,CAAC,CA4B1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"createClassifier.js","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA2BA,4CAgCC;AApDD,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;I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lD,sCAA2C,CAAO,CAAC;IAEzD,OAAO,KAAK,EAAE,IAAiB,EAA6B,EAAE;QAC5D,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"}
@@ -0,0 +1,40 @@
1
+ import { CreateClassifierArgs, EvaluatorFn } from "../types/evals";
2
+ export interface DocumentRelevancyEvaluatorArgs extends Omit<CreateClassifierArgs, "promptTemplate" | "choices"> {
3
+ choices?: CreateClassifierArgs["choices"];
4
+ promptTemplate?: CreateClassifierArgs["promptTemplate"];
5
+ }
6
+ /**
7
+ * An example to be evaluated by the document relevancy evaluator.
8
+ */
9
+ export type DocumentRelevancyExample = {
10
+ input: string;
11
+ documentText: string;
12
+ };
13
+ /**
14
+ * Creates a document relevancy evaluator function.
15
+ *
16
+ * This function returns an evaluator that determines whether a given document text
17
+ * is relevant to a provided input question. The evaluator uses a classification model
18
+ * and a prompt template to make its determination.
19
+ *
20
+ * @param args - The arguments for creating the document relevancy evaluator.
21
+ * @param args.model - The model to use for classification.
22
+ * @param args.choices - The possible classification choices (defaults to DOCUMENT_RELEVANCY_CHOICES).
23
+ * @param args.promptTemplate - The prompt template to use (defaults to DOCUMENT_RELEVANCY_TEMPLATE).
24
+ * @param args.telemetry - The telemetry to use for the evaluator.
25
+ *
26
+ * @returns An evaluator function that takes a {@link DocumentRelevancyExample} and returns a classification result
27
+ * indicating whether the document is relevant to the input question.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const evaluator = createDocumentRelevancyEvaluator({ model: openai("gpt-4o-mini") });
32
+ * const result = await evaluator({
33
+ * input: "What is the capital of France?",
34
+ * documentText: "Paris is the capital and most populous city of France.",
35
+ * });
36
+ * console.log(result.label); // "relevant" or "unrelated"
37
+ * ```
38
+ */
39
+ export declare function createDocumentRelevancyEvaluator(args: DocumentRelevancyEvaluatorArgs): EvaluatorFn<DocumentRelevancyExample>;
40
+ //# sourceMappingURL=createDocumentRelevancyEvaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDocumentRelevancyEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMnE,MAAM,WAAW,8BACf,SAAQ,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChE,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,8BAA8B,GACnC,WAAW,CAAC,wBAAwB,CAAC,CAcvC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createDocumentRelevancyEvaluator = createDocumentRelevancyEvaluator;
15
+ const createClassifier_1 = require("./createClassifier");
16
+ const DOCUMENT_RELEVANCY_TEMPLATE_1 = require("../default_templates/DOCUMENT_RELEVANCY_TEMPLATE");
17
+ /**
18
+ * Creates a document relevancy evaluator function.
19
+ *
20
+ * This function returns an evaluator that determines whether a given document text
21
+ * is relevant to a provided input question. The evaluator uses a classification model
22
+ * and a prompt template to make its determination.
23
+ *
24
+ * @param args - The arguments for creating the document relevancy evaluator.
25
+ * @param args.model - The model to use for classification.
26
+ * @param args.choices - The possible classification choices (defaults to DOCUMENT_RELEVANCY_CHOICES).
27
+ * @param args.promptTemplate - The prompt template to use (defaults to DOCUMENT_RELEVANCY_TEMPLATE).
28
+ * @param args.telemetry - The telemetry to use for the evaluator.
29
+ *
30
+ * @returns An evaluator function that takes a {@link DocumentRelevancyExample} and returns a classification result
31
+ * indicating whether the document is relevant to the input question.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const evaluator = createDocumentRelevancyEvaluator({ model: openai("gpt-4o-mini") });
36
+ * const result = await evaluator({
37
+ * input: "What is the capital of France?",
38
+ * documentText: "Paris is the capital and most populous city of France.",
39
+ * });
40
+ * console.log(result.label); // "relevant" or "unrelated"
41
+ * ```
42
+ */
43
+ function createDocumentRelevancyEvaluator(args) {
44
+ const { choices = DOCUMENT_RELEVANCY_TEMPLATE_1.DOCUMENT_RELEVANCY_CHOICES, promptTemplate = DOCUMENT_RELEVANCY_TEMPLATE_1.DOCUMENT_RELEVANCY_TEMPLATE } = args, rest = __rest(args, ["choices", "promptTemplate"]);
45
+ const documentRelevancyEvaluatorFn = (0, createClassifier_1.createClassifier)(Object.assign(Object.assign(Object.assign({}, args), { promptTemplate,
46
+ choices }), rest));
47
+ return documentRelevancyEvaluatorFn;
48
+ }
49
+ //# sourceMappingURL=createDocumentRelevancyEvaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDocumentRelevancyEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA+CA,4EAgBC;AA/DD,yDAAsD;AAEtD,kGAG0D;AAgB1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,gCAAgC,CAC9C,IAAoC;IAEpC,MAAM,EACJ,OAAO,GAAG,wDAA0B,EACpC,cAAc,GAAG,yDAA2B,KAE1C,IAAI,EADH,IAAI,UACL,IAAI,EAJF,6BAIL,CAAO,CAAC;IACT,MAAM,4BAA4B,GAChC,IAAA,mCAAgB,gDACX,IAAI,KACP,cAAc;QACd,OAAO,KACJ,IAAI,EACP,CAAC;IACL,OAAO,4BAA4B,CAAC;AACtC,CAAC"}
@@ -1,14 +1,22 @@
1
1
  import { CreateClassifierArgs, EvaluatorFn } from "../types/evals";
2
- interface HallucinationEvaluatorArgs extends Omit<CreateClassifierArgs, "promptTemplate" | "choices"> {
2
+ export interface HallucinationEvaluatorArgs extends Omit<CreateClassifierArgs, "promptTemplate" | "choices"> {
3
3
  choices?: CreateClassifierArgs["choices"];
4
4
  promptTemplate?: CreateClassifierArgs["promptTemplate"];
5
5
  }
6
+ /**
7
+ * An example to be evaluated by the hallucination evaluator.
8
+ */
9
+ export type HallucinationExample = {
10
+ input: string;
11
+ output: string;
12
+ reference?: string;
13
+ context?: string;
14
+ };
6
15
  /**
7
16
  * Creates a function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
8
17
  *
9
18
  * @param args - The arguments for creating the hallucination evaluator.
10
19
  * @returns A function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
11
20
  */
12
- export declare function createHallucinationEvaluator(args: HallucinationEvaluatorArgs): EvaluatorFn<string, string>;
13
- export {};
21
+ export declare function createHallucinationEvaluator(args: HallucinationEvaluatorArgs): EvaluatorFn<HallucinationExample>;
14
22
  //# sourceMappingURL=createHallucinationEvaluator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMnE,UAAU,0BACR,SAAQ,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChE,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;CACzD;AACD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAa7B"}
1
+ {"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMnE,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChE,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,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,IAAI,EAAE,0BAA0B,GAC/B,WAAW,CAAC,oBAAoB,CAAC,CAanC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createHallucinationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAkBA,oEAeC;AAjCD,yDAAsD;AAEtD,wFAGqD;AAOrD;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,IAAgC;IAEhC,MAAM,EACJ,OAAO,GAAG,8CAAqB,EAC/B,cAAc,GAAG,+CAAsB,KAErC,IAAI,EADH,IAAI,UACL,IAAI,EAJF,6BAIL,CAAO,CAAC;IACT,MAAM,wBAAwB,GAAG,IAAA,mCAAgB,gDAC5C,IAAI,KACP,cAAc;QACd,OAAO,KACJ,IAAI,EACP,CAAC;IACH,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"createHallucinationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA4BA,oEAeC;AA3CD,yDAAsD;AAEtD,wFAGqD;AAiBrD;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,IAAgC;IAEhC,MAAM,EACJ,OAAO,GAAG,8CAAqB,EAC/B,cAAc,GAAG,+CAAsB,KAErC,IAAI,EADH,IAAI,UACL,IAAI,EAJF,6BAIL,CAAO,CAAC;IACT,MAAM,wBAAwB,GAAG,IAAA,mCAAgB,gDAC5C,IAAI,KACP,cAAc;QACd,OAAO,KACJ,IAAI,EACP,CAAC;IACH,OAAO,wBAAwB,CAAC;AAClC,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
- interface ClassifyArgs extends WithLLM, WithPrompt, WithTelemetry {
4
+ export interface ClassifyArgs extends WithLLM, WithPrompt, WithTelemetry {
5
5
  /**
6
6
  * The labels to classify the example into. E.x. ["correct", "incorrect"]
7
7
  */
@@ -19,5 +19,4 @@ interface ClassifyArgs extends WithLLM, WithPrompt, WithTelemetry {
19
19
  * A function that leverages an llm to perform a classification
20
20
  */
21
21
  export declare function generateClassification(args: ClassifyArgs): Promise<ClassificationResult>;
22
- export {};
23
22
  //# sourceMappingURL=generateClassification.d.ts.map
@@ -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,UAAU,YAAa,SAAQ,OAAO,EAAE,UAAU,EAAE,aAAa;IAC/D;;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;AACD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAyB/B"}
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,WAAW,YAAa,SAAQ,OAAO,EAAE,UAAU,EAAE,aAAa;IACtE;;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;AACD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAyB/B"}
@@ -1,4 +1,5 @@
1
1
  export * from "./generateClassification";
2
2
  export * from "./createClassifier";
3
3
  export * from "./createHallucinationEvaluator";
4
+ export * from "./createDocumentRelevancyEvaluator";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC"}
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./generateClassification"), exports);
18
18
  __exportStar(require("./createClassifier"), exports);
19
19
  __exportStar(require("./createHallucinationEvaluator"), exports);
20
+ __exportStar(require("./createDocumentRelevancyEvaluator"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,qDAAmC;AACnC,iEAA+C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,qDAAmC;AACnC,iEAA+C;AAC/C,qEAAmD"}
@@ -1,9 +1,9 @@
1
1
  import { LanguageModel } from "ai";
2
2
  import { WithTelemetry } from "./otel";
3
3
  /**
4
- * The arguments for an evaluation
4
+ * A specific AI example that is under evaluation
5
5
  */
6
- export interface EvaluationArgs<OutputType, InputType> {
6
+ export interface ExampleRecord<OutputType, InputType> {
7
7
  output: OutputType;
8
8
  expected?: OutputType;
9
9
  input?: InputType;
@@ -12,7 +12,7 @@ export interface EvaluationArgs<OutputType, InputType> {
12
12
  export interface WithLLM {
13
13
  model: LanguageModel;
14
14
  }
15
- export interface LLMEvaluationArgs<OutputType, InputType> extends EvaluationArgs<OutputType, InputType>, WithLLM {
15
+ export interface LLMEvaluationArgs extends WithLLM {
16
16
  }
17
17
  /**
18
18
  * The result of an evaluation
@@ -67,5 +67,5 @@ export interface CreateClassifierArgs extends WithTelemetry {
67
67
  */
68
68
  promptTemplate: string;
69
69
  }
70
- export type EvaluatorFn<OutputType, InputType> = (args: EvaluationArgs<OutputType, InputType>) => Promise<EvaluationResult>;
70
+ export type EvaluatorFn<ExampleType extends Record<string, unknown>> = (args: ExampleType) => Promise<EvaluationResult>;
71
71
  //# sourceMappingURL=evals.d.ts.map
@@ -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,cAAc,CAAC,UAAU,EAAE,SAAS;IACnD,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;AAED,MAAM,WAAW,iBAAiB,CAAC,UAAU,EAAE,SAAS,CACtD,SAAQ,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,EAC3C,O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AO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,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,MAAM,WAAW,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CACrE,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
- import { CoreMessage, Message } from "ai";
1
+ import { ModelMessage } from "ai";
2
2
  /**
3
- * Prompt part of the AI function options.
4
- * It contains a system message, a simple text prompt, or a list of messages.
5
- * Note: this is pulled from the `ai` package and is used as a compatibility type.
3
+ * Prompt part of the AI function options for model generation.
4
+ * It contains a system message, a simple text prompt, or a list of model messages.
5
+ * Uses ModelMessage format compatible with AI SDK v5 generateObject function.
6
6
  */
7
7
  export interface WithPrompt {
8
8
  /**
@@ -14,8 +14,9 @@ export interface WithPrompt {
14
14
  */
15
15
  prompt?: string;
16
16
  /**
17
- * A list of messages. You can either use `prompt` or `messages` but not both.
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.
18
19
  */
19
- messages?: Array<CoreMessage> | Array<Omit<Message, "id">>;
20
+ messages?: Array<ModelMessage>;
20
21
  }
21
22
  //# 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,WAAW,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;CAC5D"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAChC"}