@arizeai/phoenix-evals 0.0.7 → 0.1.0
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/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts +6 -0
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts.map +1 -0
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js +25 -0
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js.map +1 -0
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.d.ts +1 -1
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.js +2 -2
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.js.map +1 -1
- package/dist/esm/default_templates/index.d.ts +1 -0
- package/dist/esm/default_templates/index.d.ts.map +1 -1
- package/dist/esm/default_templates/index.js +1 -0
- package/dist/esm/default_templates/index.js.map +1 -1
- package/dist/esm/llm/createClassificationEvaluator.d.ts +3 -0
- package/dist/esm/llm/createClassificationEvaluator.d.ts.map +1 -0
- package/dist/esm/llm/createClassificationEvaluator.js +10 -0
- package/dist/esm/llm/createClassificationEvaluator.js.map +1 -0
- package/dist/esm/llm/createClassifierFn.d.ts +6 -0
- package/dist/esm/llm/createClassifierFn.d.ts.map +1 -0
- package/dist/esm/llm/{createClassifier.js → createClassifierFn.js} +3 -3
- package/dist/esm/llm/createClassifierFn.js.map +1 -0
- package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts +42 -0
- package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts.map +1 -0
- package/dist/esm/llm/createDocumentRelevancyEvaluator.js +40 -0
- package/dist/esm/llm/createDocumentRelevancyEvaluator.js.map +1 -0
- package/dist/esm/llm/createHallucinationEvaluator.d.ts +16 -5
- package/dist/esm/llm/createHallucinationEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/createHallucinationEvaluator.js +5 -4
- package/dist/esm/llm/createHallucinationEvaluator.js.map +1 -1
- package/dist/esm/llm/index.d.ts +3 -1
- package/dist/esm/llm/index.d.ts.map +1 -1
- package/dist/esm/llm/index.js +3 -1
- package/dist/esm/llm/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types/evals.d.ts +49 -4
- package/dist/esm/types/evals.d.ts.map +1 -1
- package/dist/esm/types/prompts.d.ts +7 -6
- package/dist/esm/types/prompts.d.ts.map +1 -1
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts +6 -0
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts.map +1 -0
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js +28 -0
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js.map +1 -0
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.d.ts +1 -1
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.js +2 -2
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.js.map +1 -1
- package/dist/src/default_templates/index.d.ts +1 -0
- package/dist/src/default_templates/index.d.ts.map +1 -1
- package/dist/src/default_templates/index.js +1 -0
- package/dist/src/default_templates/index.js.map +1 -1
- package/dist/src/llm/createClassificationEvaluator.d.ts +3 -0
- package/dist/src/llm/createClassificationEvaluator.d.ts.map +1 -0
- package/dist/src/llm/createClassificationEvaluator.js +13 -0
- package/dist/src/llm/createClassificationEvaluator.js.map +1 -0
- package/dist/src/llm/createClassifierFn.d.ts +6 -0
- package/dist/src/llm/createClassifierFn.d.ts.map +1 -0
- package/dist/src/llm/{createClassifier.js → createClassifierFn.js} +4 -4
- package/dist/src/llm/createClassifierFn.js.map +1 -0
- package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts +42 -0
- package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts.map +1 -0
- package/dist/src/llm/createDocumentRelevancyEvaluator.js +50 -0
- package/dist/src/llm/createDocumentRelevancyEvaluator.js.map +1 -0
- package/dist/src/llm/createHallucinationEvaluator.d.ts +16 -5
- package/dist/src/llm/createHallucinationEvaluator.d.ts.map +1 -1
- package/dist/src/llm/createHallucinationEvaluator.js +6 -5
- package/dist/src/llm/createHallucinationEvaluator.js.map +1 -1
- package/dist/src/llm/index.d.ts +3 -1
- package/dist/src/llm/index.d.ts.map +1 -1
- package/dist/src/llm/index.js +3 -1
- package/dist/src/llm/index.js.map +1 -1
- package/dist/src/types/evals.d.ts +49 -4
- package/dist/src/types/evals.d.ts.map +1 -1
- package/dist/src/types/prompts.d.ts +7 -6
- package/dist/src/types/prompts.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.ts +25 -0
- package/src/default_templates/HALLUCINATION_TEMPLATE.ts +2 -2
- package/src/default_templates/index.ts +1 -0
- package/src/llm/createClassificationEvaluator.ts +13 -0
- package/src/llm/{createClassifier.ts → createClassifierFn.ts} +4 -7
- package/src/llm/createDocumentRelevancyEvaluator.ts +72 -0
- package/src/llm/createHallucinationEvaluator.ts +26 -8
- package/src/llm/index.ts +3 -1
- package/src/types/evals.ts +54 -7
- package/src/types/prompts.ts +7 -6
- package/dist/esm/llm/createClassifier.d.ts +0 -6
- package/dist/esm/llm/createClassifier.d.ts.map +0 -1
- package/dist/esm/llm/createClassifier.js.map +0 -1
- package/dist/src/llm/createClassifier.d.ts +0 -6
- package/dist/src/llm/createClassifier.d.ts.map +0 -1
- package/dist/src/llm/createClassifier.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DOCUMENT_RELEVANCY_CHOICES = exports.DOCUMENT_RELEVANCY_TEMPLATE = void 0;
|
|
4
|
+
exports.DOCUMENT_RELEVANCY_TEMPLATE = `
|
|
5
|
+
You are comparing a document to a question and trying to determine if the document text
|
|
6
|
+
contains information relevant to answering the question. Here is the data:
|
|
7
|
+
|
|
8
|
+
[BEGIN DATA]
|
|
9
|
+
************
|
|
10
|
+
[Question]: {{input}}
|
|
11
|
+
************
|
|
12
|
+
[Document text]: {{documentText}}
|
|
13
|
+
************
|
|
14
|
+
[END DATA]
|
|
15
|
+
|
|
16
|
+
Compare the Question above to the Document text. You must determine whether the Document text
|
|
17
|
+
contains information that can answer the Question. Please focus on whether the very specific
|
|
18
|
+
question can be answered by the information in the Document text.
|
|
19
|
+
Your response must be single word, either "relevant" or "unrelated",
|
|
20
|
+
and should not contain any text or characters aside from that word.
|
|
21
|
+
"unrelated" means that the document text does not contain an answer to the Question.
|
|
22
|
+
"relevant" means the document text contains an answer to the Question.
|
|
23
|
+
`;
|
|
24
|
+
exports.DOCUMENT_RELEVANCY_CHOICES = {
|
|
25
|
+
relevant: 1,
|
|
26
|
+
unrelated: 0,
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=DOCUMENT_RELEVANCY_TEMPLATE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DOCUMENT_RELEVANCY_TEMPLATE.js","sourceRoot":"","sources":["../../../src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;CAmB1C,CAAC;AAEW,QAAA,0BAA0B,GAAG;IACxC,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;CACb,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const HALLUCINATION_TEMPLATE = "\nIn this task, you will be presented with a query, a reference text and an answer. The answer is\ngenerated to the question based on the reference text. The answer may contain false information. You\nmust use the reference text to determine if the answer to the question contains false information,\nif the answer is a hallucination of facts. Your objective is to determine whether the answer text\ncontains factual information and is not a hallucination. A 'hallucination' refers to\nan answer that is not based on the reference text or assumes information that is not available in\nthe reference text. Your response should be a single word: either \"factual\" or \"hallucinated\", and\nit should not include any other text or characters. \"hallucinated\" indicates that the answer\nprovides factually inaccurate information to the query based on the reference text. \"factual\"\nindicates that the answer to the question is correct relative to the reference text, and does not\ncontain made up information. Please read the query and reference text carefully before determining\nyour response.\n\n [BEGIN DATA]\n ************\n [Query]: {{input}}\n ************\n [Reference text]: {{reference}}\n ************\n [Answer]: {{output}}\n ************\n [END DATA]\n\nIs the answer above factual or hallucinated based on the query and reference text?\n";
|
|
2
2
|
export declare const HALLUCINATION_CHOICES: {
|
|
3
|
-
factual: number;
|
|
4
3
|
hallucinated: number;
|
|
4
|
+
factual: number;
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=HALLUCINATION_TEMPLATE.d.ts.map
|
|
@@ -28,7 +28,7 @@ your response.
|
|
|
28
28
|
Is the answer above factual or hallucinated based on the query and reference text?
|
|
29
29
|
`;
|
|
30
30
|
exports.HALLUCINATION_CHOICES = {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
hallucinated: 1,
|
|
32
|
+
factual: 0,
|
|
33
33
|
};
|
|
34
34
|
//# sourceMappingURL=HALLUCINATION_TEMPLATE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HALLUCINATION_TEMPLATE.js","sourceRoot":"","sources":["../../../src/default_templates/HALLUCINATION_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrC,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACnC,
|
|
1
|
+
{"version":3,"file":"HALLUCINATION_TEMPLATE.js","sourceRoot":"","sources":["../../../src/default_templates/HALLUCINATION_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrC,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACnC,YAAY,EAAE,CAAC;IACf,OAAO,EAAE,CAAC;CACX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/default_templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/default_templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,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("./HALLUCINATION_TEMPLATE"), exports);
|
|
18
|
+
__exportStar(require("./DOCUMENT_RELEVANCY_TEMPLATE"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/default_templates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/default_templates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,gEAA8C"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CreateClassificationEvaluatorArgs, Evaluator } from "../types/evals";
|
|
2
|
+
export declare function createClassificationEvaluator<ExampleType extends Record<string, unknown>>(args: CreateClassificationEvaluatorArgs): Evaluator<ExampleType>;
|
|
3
|
+
//# sourceMappingURL=createClassificationEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createClassificationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassificationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG9E,wBAAgB,6BAA6B,CAC3C,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,IAAI,EAAE,iCAAiC,GAAG,SAAS,CAAC,WAAW,CAAC,CAOjE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createClassificationEvaluator = createClassificationEvaluator;
|
|
4
|
+
const createClassifierFn_1 = require("./createClassifierFn");
|
|
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
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=createClassificationEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createClassificationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createClassificationEvaluator.ts"],"names":[],"mappings":";;AAGA,sEASC;AAXD,6DAA0D;AAE1D,SAAgB,6BAA6B,CAE3C,IAAuC;IACvC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,KAAK;QACb,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;QACjD,QAAQ,EAAE,IAAA,uCAAkB,EAAC,IAAI,CAAC;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreateClassifierArgs, EvaluatorFn } from "../types/evals";
|
|
2
|
+
/**
|
|
3
|
+
* A function that serves as a factory that will output a classification evaluator function
|
|
4
|
+
*/
|
|
5
|
+
export declare function createClassifierFn<ExampleType extends Record<string, unknown>>(args: CreateClassifierArgs): EvaluatorFn<ExampleType>;
|
|
6
|
+
//# sourceMappingURL=createClassifierFn.d.ts.map
|
|
@@ -0,0 +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,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5E,IAAI,EAAE,oBAAoB,GACzB,WAAW,CAAC,WAAW,CAAC,CA4B1B"}
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.createClassifierFn = createClassifierFn;
|
|
15
15
|
const generateClassification_1 = require("./generateClassification");
|
|
16
16
|
const template_1 = require("../template");
|
|
17
17
|
/**
|
|
@@ -26,9 +26,9 @@ function choicesToLabels(choices) {
|
|
|
26
26
|
return labels;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* A function that serves as a factory that will output a classification evaluator
|
|
29
|
+
* A function that serves as a factory that will output a classification evaluator function
|
|
30
30
|
*/
|
|
31
|
-
function
|
|
31
|
+
function createClassifierFn(args) {
|
|
32
32
|
const { model, choices, promptTemplate } = args, rest = __rest(args, ["model", "choices", "promptTemplate"]);
|
|
33
33
|
return async (args) => {
|
|
34
34
|
const templateVariables = Object.assign({}, args);
|
|
@@ -42,4 +42,4 @@ function createClassifier(args) {
|
|
|
42
42
|
return Object.assign({ score }, classification);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=createClassifierFn.js.map
|
|
@@ -0,0 +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,CAChC,IAA0B;IAE1B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,KAAc,IAAI,EAAb,IAAI,UAAK,IAAI,EAAlD,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,42 @@
|
|
|
1
|
+
import { CreateClassificationEvaluatorArgs, Evaluator } from "../types/evals";
|
|
2
|
+
export interface DocumentRelevancyEvaluatorArgs extends Omit<CreateClassificationEvaluatorArgs, "promptTemplate" | "choices" | "optimizationDirection" | "name"> {
|
|
3
|
+
optimizationDirection?: CreateClassificationEvaluatorArgs["optimizationDirection"];
|
|
4
|
+
name?: CreateClassificationEvaluatorArgs["name"];
|
|
5
|
+
choices?: CreateClassificationEvaluatorArgs["choices"];
|
|
6
|
+
promptTemplate?: CreateClassificationEvaluatorArgs["promptTemplate"];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* An example to be evaluated by the document relevancy evaluator.
|
|
10
|
+
*/
|
|
11
|
+
export type DocumentRelevancyExample = {
|
|
12
|
+
input: string;
|
|
13
|
+
documentText: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Creates a document relevancy evaluator function.
|
|
17
|
+
*
|
|
18
|
+
* This function returns an evaluator that determines whether a given document text
|
|
19
|
+
* is relevant to a provided input question. The evaluator uses a classification model
|
|
20
|
+
* and a prompt template to make its determination.
|
|
21
|
+
*
|
|
22
|
+
* @param args - The arguments for creating the document relevancy evaluator.
|
|
23
|
+
* @param args.model - The model to use for classification.
|
|
24
|
+
* @param args.choices - The possible classification choices (defaults to DOCUMENT_RELEVANCY_CHOICES).
|
|
25
|
+
* @param args.promptTemplate - The prompt template to use (defaults to DOCUMENT_RELEVANCY_TEMPLATE).
|
|
26
|
+
* @param args.telemetry - The telemetry to use for the evaluator.
|
|
27
|
+
*
|
|
28
|
+
* @returns An evaluator function that takes a {@link DocumentRelevancyExample} and returns a classification result
|
|
29
|
+
* indicating whether the document is relevant to the input question.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const evaluator = createDocumentRelevancyEvaluator({ model: openai("gpt-4o-mini") });
|
|
34
|
+
* const result = await evaluator.evaluate({
|
|
35
|
+
* input: "What is the capital of France?",
|
|
36
|
+
* documentText: "Paris is the capital and most populous city of France.",
|
|
37
|
+
* });
|
|
38
|
+
* console.log(result.label); // "relevant" or "unrelated"
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function createDocumentRelevancyEvaluator(args: DocumentRelevancyEvaluatorArgs): Evaluator<DocumentRelevancyExample>;
|
|
42
|
+
//# sourceMappingURL=createDocumentRelevancyEvaluator.d.ts.map
|
|
@@ -0,0 +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,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,SAAS,CAAC,wBAAwB,CAAC,CAiBrC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 DOCUMENT_RELEVANCY_TEMPLATE_1 = require("../default_templates/DOCUMENT_RELEVANCY_TEMPLATE");
|
|
16
|
+
const createClassificationEvaluator_1 = require("./createClassificationEvaluator");
|
|
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.evaluate({
|
|
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, optimizationDirection = "MAXIMIZE", name = "document_relevancy" } = args, rest = __rest(args, ["choices", "promptTemplate", "optimizationDirection", "name"]);
|
|
45
|
+
return (0, createClassificationEvaluator_1.createClassificationEvaluator)(Object.assign(Object.assign(Object.assign({}, args), { promptTemplate,
|
|
46
|
+
choices,
|
|
47
|
+
optimizationDirection,
|
|
48
|
+
name }), rest));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=createDocumentRelevancyEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDocumentRelevancyEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createDocumentRelevancyEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAoDA,4EAmBC;AAtED,kGAG0D;AAC1D,mFAAgF;AAqBhF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,gCAAgC,CAC9C,IAAoC;IAEpC,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,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface HallucinationEvaluatorArgs extends Omit<
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { CreateClassificationEvaluatorArgs, Evaluator } from "../types/evals";
|
|
2
|
+
export interface HallucinationEvaluatorArgs extends Omit<CreateClassificationEvaluatorArgs, "promptTemplate" | "choices" | "optimizationDirection" | "name"> {
|
|
3
|
+
optimizationDirection?: CreateClassificationEvaluatorArgs["optimizationDirection"];
|
|
4
|
+
name?: CreateClassificationEvaluatorArgs["name"];
|
|
5
|
+
choices?: CreateClassificationEvaluatorArgs["choices"];
|
|
6
|
+
promptTemplate?: CreateClassificationEvaluatorArgs["promptTemplate"];
|
|
5
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* An example to be evaluated by the hallucination evaluator.
|
|
10
|
+
*/
|
|
11
|
+
export type HallucinationExample = {
|
|
12
|
+
input: string;
|
|
13
|
+
output: string;
|
|
14
|
+
reference?: string;
|
|
15
|
+
context?: string;
|
|
16
|
+
};
|
|
6
17
|
/**
|
|
7
18
|
* Creates a function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
|
|
8
19
|
*
|
|
9
20
|
* @param args - The arguments for creating the hallucination evaluator.
|
|
10
21
|
* @returns A function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
|
|
11
22
|
*/
|
|
12
|
-
export declare function createHallucinationEvaluator(args: HallucinationEvaluatorArgs):
|
|
23
|
+
export declare function createHallucinationEvaluator(args: HallucinationEvaluatorArgs): Evaluator<HallucinationExample>;
|
|
13
24
|
//# sourceMappingURL=createHallucinationEvaluator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO9E,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,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,SAAS,CAAC,oBAAoB,CAAC,CAgBjC"}
|
|
@@ -12,8 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.createHallucinationEvaluator = createHallucinationEvaluator;
|
|
15
|
-
const createClassifier_1 = require("./createClassifier");
|
|
16
15
|
const HALLUCINATION_TEMPLATE_1 = require("../default_templates/HALLUCINATION_TEMPLATE");
|
|
16
|
+
const createClassificationEvaluator_1 = require("./createClassificationEvaluator");
|
|
17
17
|
/**
|
|
18
18
|
* Creates a function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
|
|
19
19
|
*
|
|
@@ -21,9 +21,10 @@ const HALLUCINATION_TEMPLATE_1 = require("../default_templates/HALLUCINATION_TEM
|
|
|
21
21
|
* @returns A function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
|
|
22
22
|
*/
|
|
23
23
|
function createHallucinationEvaluator(args) {
|
|
24
|
-
const { choices = HALLUCINATION_TEMPLATE_1.HALLUCINATION_CHOICES, promptTemplate = HALLUCINATION_TEMPLATE_1.HALLUCINATION_TEMPLATE } = args, rest = __rest(args, ["choices", "promptTemplate"]);
|
|
25
|
-
|
|
26
|
-
choices
|
|
27
|
-
|
|
24
|
+
const { choices = HALLUCINATION_TEMPLATE_1.HALLUCINATION_CHOICES, promptTemplate = HALLUCINATION_TEMPLATE_1.HALLUCINATION_TEMPLATE, optimizationDirection = "MINIMIZE", name = "hallucination" } = args, rest = __rest(args, ["choices", "promptTemplate", "optimizationDirection", "name"]);
|
|
25
|
+
return (0, createClassificationEvaluator_1.createClassificationEvaluator)(Object.assign(Object.assign(Object.assign({}, args), { promptTemplate,
|
|
26
|
+
choices,
|
|
27
|
+
optimizationDirection,
|
|
28
|
+
name }), rest));
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=createHallucinationEvaluator.js.map
|
|
@@ -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":";;;;;;;;;;;;;AAiCA,oEAkBC;AAlDD,wFAGqD;AACrD,mFAAgF;AAsBhF;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,IAAgC;IAEhC,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"}
|
package/dist/src/llm/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./generateClassification";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./createClassifierFn";
|
|
3
|
+
export * from "./createClassificationEvaluator";
|
|
3
4
|
export * from "./createHallucinationEvaluator";
|
|
5
|
+
export * from "./createDocumentRelevancyEvaluator";
|
|
4
6
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC"}
|
package/dist/src/llm/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./generateClassification"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./createClassifierFn"), exports);
|
|
19
|
+
__exportStar(require("./createClassificationEvaluator"), exports);
|
|
19
20
|
__exportStar(require("./createHallucinationEvaluator"), exports);
|
|
21
|
+
__exportStar(require("./createDocumentRelevancyEvaluator"), exports);
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC;AACrC,kEAAgD;AAChD,iEAA+C;AAC/C,qEAAmD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LanguageModel } from "ai";
|
|
2
2
|
import { WithTelemetry } from "./otel";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* A specific AI example that is under evaluation
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
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
|
|
15
|
+
export interface LLMEvaluationArgs extends WithLLM {
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* The result of an evaluation
|
|
@@ -67,5 +67,50 @@ export interface CreateClassifierArgs extends WithTelemetry {
|
|
|
67
67
|
*/
|
|
68
68
|
promptTemplate: string;
|
|
69
69
|
}
|
|
70
|
-
export
|
|
70
|
+
export interface CreateClassificationEvaluatorArgs extends CreateClassifierArgs {
|
|
71
|
+
/**
|
|
72
|
+
* The name of the metric that the evaluator produces
|
|
73
|
+
* E.x. "correctness"
|
|
74
|
+
*/
|
|
75
|
+
name: string;
|
|
76
|
+
/**
|
|
77
|
+
* If present, represents the direction in which you want the metric to be optimized
|
|
78
|
+
* E.x. "MAXIMIZE" means you want the number to be higher.
|
|
79
|
+
*/
|
|
80
|
+
optimizationDirection?: OptimizationDirection;
|
|
81
|
+
}
|
|
82
|
+
export type EvaluatorFn<ExampleType extends Record<string, unknown>> = (args: ExampleType) => Promise<EvaluationResult>;
|
|
83
|
+
/**
|
|
84
|
+
* The source of the evaluation
|
|
85
|
+
*/
|
|
86
|
+
type EvaluationSource = "LLM" | "CODE";
|
|
87
|
+
/**
|
|
88
|
+
* The direction to optimize the numeric evaluation score
|
|
89
|
+
* E.x. "MAXIMIZE" means that the higher the score, the better the evaluation
|
|
90
|
+
*/
|
|
91
|
+
type OptimizationDirection = "MAXIMIZE" | "MINIMIZE";
|
|
92
|
+
/**
|
|
93
|
+
* The Base Evaluator interface
|
|
94
|
+
* This is the interface that all evaluators must implement
|
|
95
|
+
*/
|
|
96
|
+
export interface Evaluator<ExampleType extends Record<string, unknown>> {
|
|
97
|
+
/**
|
|
98
|
+
* The name of the evaluator / the metric that it measures
|
|
99
|
+
*/
|
|
100
|
+
name: string;
|
|
101
|
+
/**
|
|
102
|
+
* The source of the evaluation. Also known as the "kind" of evaluator.
|
|
103
|
+
*/
|
|
104
|
+
source: EvaluationSource;
|
|
105
|
+
/**
|
|
106
|
+
* The direction to optimize the numeric evaluation score
|
|
107
|
+
* E.x. "MAXIMIZE" means that the higher the score, the better the evaluation
|
|
108
|
+
*/
|
|
109
|
+
optimizationDirection?: OptimizationDirection;
|
|
110
|
+
/**
|
|
111
|
+
* The function that evaluates the example
|
|
112
|
+
*/
|
|
113
|
+
evaluate: EvaluatorFn<ExampleType>;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
71
116
|
//# 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,
|
|
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;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,WAAW,iCACf,SAAQ,oBAAoB;IAC5B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,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,KAAK,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvC;;;GAGG;AACH,KAAK,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CACpC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
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<
|
|
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,
|
|
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"}
|