@arizeai/phoenix-evals 0.5.1 → 0.6.1
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 +42 -0
- package/dist/esm/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.d.ts +3 -0
- package/dist/esm/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.d.ts.map +1 -0
- package/dist/esm/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.js +37 -0
- package/dist/esm/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.js.map +1 -0
- package/dist/esm/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.d.ts +3 -0
- package/dist/esm/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.d.ts.map +1 -0
- package/dist/esm/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js +43 -0
- package/dist/esm/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js.map +1 -0
- package/dist/esm/__generated__/default_templates/index.d.ts +3 -0
- package/dist/esm/__generated__/default_templates/index.d.ts.map +1 -0
- package/dist/esm/__generated__/default_templates/index.js +4 -0
- package/dist/esm/__generated__/default_templates/index.js.map +1 -0
- package/dist/esm/__generated__/types.d.ts +9 -0
- package/dist/esm/__generated__/types.d.ts.map +1 -0
- package/dist/esm/__generated__/types.js +3 -0
- package/dist/esm/__generated__/types.js.map +1 -0
- package/dist/esm/core/EvaluatorBase.d.ts +19 -0
- package/dist/esm/core/EvaluatorBase.d.ts.map +1 -0
- package/dist/esm/core/EvaluatorBase.js +18 -0
- package/dist/esm/core/EvaluatorBase.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/llm/ClassificationEvaluator.d.ts +19 -2
- package/dist/esm/llm/ClassificationEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/ClassificationEvaluator.js +29 -2
- package/dist/esm/llm/ClassificationEvaluator.js.map +1 -1
- package/dist/esm/llm/LLMEvaluator.d.ts +4 -7
- package/dist/esm/llm/LLMEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/LLMEvaluator.js +4 -7
- package/dist/esm/llm/LLMEvaluator.js.map +1 -1
- package/dist/esm/llm/createClassificationEvaluator.d.ts +1 -1
- package/dist/esm/llm/createClassificationEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/createClassificationEvaluator.js.map +1 -1
- package/dist/esm/llm/createDocumentRelevanceEvaluator.d.ts +44 -0
- package/dist/esm/llm/createDocumentRelevanceEvaluator.d.ts.map +1 -0
- package/dist/esm/llm/{createDocumentRelevancyEvaluator.js → createDocumentRelevanceEvaluator.js} +11 -12
- package/dist/esm/llm/createDocumentRelevanceEvaluator.js.map +1 -0
- package/dist/esm/llm/createHallucinationEvaluator.d.ts +6 -7
- package/dist/esm/llm/createHallucinationEvaluator.d.ts.map +1 -1
- package/dist/esm/llm/createHallucinationEvaluator.js +3 -4
- package/dist/esm/llm/createHallucinationEvaluator.js.map +1 -1
- package/dist/esm/llm/index.d.ts +1 -1
- package/dist/esm/llm/index.js +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types/data.d.ts +194 -0
- package/dist/esm/types/data.d.ts.map +1 -0
- package/dist/esm/types/data.js +2 -0
- package/dist/esm/types/data.js.map +1 -0
- package/dist/esm/types/evals.d.ts +17 -3
- package/dist/esm/types/evals.d.ts.map +1 -1
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/otel.d.ts +14 -13
- package/dist/esm/types/otel.d.ts.map +1 -1
- package/dist/esm/utils/bindEvaluator.d.ts +219 -0
- package/dist/esm/utils/bindEvaluator.d.ts.map +1 -0
- package/dist/esm/utils/bindEvaluator.js +163 -0
- package/dist/esm/utils/bindEvaluator.js.map +1 -0
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/objectMappingUtils.d.ts +166 -0
- package/dist/esm/utils/objectMappingUtils.d.ts.map +1 -0
- package/dist/esm/utils/objectMappingUtils.js +191 -0
- package/dist/esm/utils/objectMappingUtils.js.map +1 -0
- package/dist/src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.d.ts +3 -0
- package/dist/src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.d.ts.map +1 -0
- package/dist/src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.js +40 -0
- package/dist/src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.js.map +1 -0
- package/dist/src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.d.ts +3 -0
- package/dist/src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.d.ts.map +1 -0
- package/dist/src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js +46 -0
- package/dist/src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js.map +1 -0
- package/dist/src/__generated__/default_templates/index.d.ts +3 -0
- package/dist/src/__generated__/default_templates/index.d.ts.map +1 -0
- package/dist/src/__generated__/default_templates/index.js +9 -0
- package/dist/src/__generated__/default_templates/index.js.map +1 -0
- package/dist/src/__generated__/types.d.ts +9 -0
- package/dist/src/__generated__/types.d.ts.map +1 -0
- package/dist/src/__generated__/types.js +4 -0
- package/dist/src/__generated__/types.js.map +1 -0
- package/dist/src/core/EvaluatorBase.d.ts +19 -0
- package/dist/src/core/EvaluatorBase.d.ts.map +1 -0
- package/dist/src/core/EvaluatorBase.js +17 -0
- package/dist/src/core/EvaluatorBase.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/llm/ClassificationEvaluator.d.ts +19 -2
- package/dist/src/llm/ClassificationEvaluator.d.ts.map +1 -1
- package/dist/src/llm/ClassificationEvaluator.js +13 -2
- package/dist/src/llm/ClassificationEvaluator.js.map +1 -1
- package/dist/src/llm/LLMEvaluator.d.ts +4 -7
- package/dist/src/llm/LLMEvaluator.d.ts.map +1 -1
- package/dist/src/llm/LLMEvaluator.js +16 -5
- package/dist/src/llm/LLMEvaluator.js.map +1 -1
- package/dist/src/llm/createClassificationEvaluator.d.ts +1 -1
- package/dist/src/llm/createClassificationEvaluator.d.ts.map +1 -1
- package/dist/src/llm/createClassificationEvaluator.js.map +1 -1
- package/dist/src/llm/createDocumentRelevanceEvaluator.d.ts +44 -0
- package/dist/src/llm/createDocumentRelevanceEvaluator.d.ts.map +1 -0
- package/dist/src/llm/{createDocumentRelevancyEvaluator.js → createDocumentRelevanceEvaluator.js} +13 -13
- package/dist/src/llm/createDocumentRelevanceEvaluator.js.map +1 -0
- package/dist/src/llm/createHallucinationEvaluator.d.ts +6 -7
- package/dist/src/llm/createHallucinationEvaluator.d.ts.map +1 -1
- package/dist/src/llm/createHallucinationEvaluator.js +4 -4
- package/dist/src/llm/createHallucinationEvaluator.js.map +1 -1
- package/dist/src/llm/index.d.ts +1 -1
- package/dist/src/llm/index.js +1 -1
- package/dist/src/types/data.d.ts +194 -0
- package/dist/src/types/data.d.ts.map +1 -0
- package/dist/src/types/data.js +3 -0
- package/dist/src/types/data.js.map +1 -0
- package/dist/src/types/evals.d.ts +17 -3
- package/dist/src/types/evals.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/otel.d.ts +14 -13
- package/dist/src/types/otel.d.ts.map +1 -1
- package/dist/src/utils/bindEvaluator.d.ts +219 -0
- package/dist/src/utils/bindEvaluator.d.ts.map +1 -0
- package/dist/src/utils/bindEvaluator.js +166 -0
- package/dist/src/utils/bindEvaluator.js.map +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/{default_templates → utils}/index.js +1 -2
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/objectMappingUtils.d.ts +166 -0
- package/dist/src/utils/objectMappingUtils.d.ts.map +1 -0
- package/dist/src/utils/objectMappingUtils.js +191 -0
- package/dist/src/utils/objectMappingUtils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.ts +39 -0
- package/src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.ts +45 -0
- package/src/__generated__/default_templates/index.ts +4 -0
- package/src/__generated__/types.ts +11 -0
- package/src/core/EvaluatorBase.ts +43 -0
- package/src/index.ts +1 -0
- package/src/llm/ClassificationEvaluator.ts +39 -3
- package/src/llm/LLMEvaluator.ts +7 -16
- package/src/llm/createClassificationEvaluator.ts +1 -1
- package/src/llm/createDocumentRelevanceEvaluator.ts +79 -0
- package/src/llm/createHallucinationEvaluator.ts +17 -19
- package/src/llm/index.ts +1 -1
- package/src/types/data.ts +200 -0
- package/src/types/evals.ts +25 -5
- package/src/types/index.ts +1 -0
- package/src/types/otel.ts +15 -13
- package/src/utils/bindEvaluator.ts +229 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/objectMappingUtils.ts +202 -0
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts +0 -6
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts.map +0 -1
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js +0 -25
- package/dist/esm/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js.map +0 -1
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.d.ts +0 -6
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.d.ts.map +0 -1
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.js +0 -31
- package/dist/esm/default_templates/HALLUCINATION_TEMPLATE.js.map +0 -1
- package/dist/esm/default_templates/index.d.ts +0 -3
- package/dist/esm/default_templates/index.d.ts.map +0 -1
- package/dist/esm/default_templates/index.js +0 -3
- package/dist/esm/default_templates/index.js.map +0 -1
- package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts +0 -43
- package/dist/esm/llm/createDocumentRelevancyEvaluator.d.ts.map +0 -1
- package/dist/esm/llm/createDocumentRelevancyEvaluator.js.map +0 -1
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts +0 -6
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.d.ts.map +0 -1
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js +0 -28
- package/dist/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.js.map +0 -1
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.d.ts +0 -6
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.d.ts.map +0 -1
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.js +0 -34
- package/dist/src/default_templates/HALLUCINATION_TEMPLATE.js.map +0 -1
- package/dist/src/default_templates/index.d.ts +0 -3
- package/dist/src/default_templates/index.d.ts.map +0 -1
- package/dist/src/default_templates/index.js.map +0 -1
- package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts +0 -43
- package/dist/src/llm/createDocumentRelevancyEvaluator.d.ts.map +0 -1
- package/dist/src/llm/createDocumentRelevancyEvaluator.js.map +0 -1
- package/src/default_templates/DOCUMENT_RELEVANCY_TEMPLATE.ts +0 -25
- package/src/default_templates/HALLUCINATION_TEMPLATE.ts +0 -31
- package/src/default_templates/index.ts +0 -2
- package/src/llm/createDocumentRelevancyEvaluator.ts +0 -77
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binds an evaluator to a specific data structure using input mapping.
|
|
3
|
+
*
|
|
4
|
+
* This function creates a new evaluator instance that automatically transforms
|
|
5
|
+
* your data structure to match what the evaluator expects. This is particularly
|
|
6
|
+
* useful when your data schema doesn't match the evaluator's expected input format.
|
|
7
|
+
*
|
|
8
|
+
* @param evaluator - The evaluator to bind (e.g., a hallucination evaluator)
|
|
9
|
+
* @param context - The binding context containing the input mapping configuration
|
|
10
|
+
* @returns A new evaluator instance with the input mapping applied
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* **Basic usage with simple field mapping:**
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { bindEvaluator, createHallucinationEvaluator } from "@arizeai/phoenix-evals";
|
|
16
|
+
* import { openai } from "@ai-sdk/openai";
|
|
17
|
+
*
|
|
18
|
+
* type MyData = {
|
|
19
|
+
* question: string;
|
|
20
|
+
* context: string;
|
|
21
|
+
* answer: string;
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* const evaluator = bindEvaluator<MyData>(
|
|
25
|
+
* createHallucinationEvaluator({ model: openai("gpt-4") }),
|
|
26
|
+
* {
|
|
27
|
+
* inputMapping: {
|
|
28
|
+
* input: "question", // Evaluator expects "input", map from "question"
|
|
29
|
+
* reference: "context", // Evaluator expects "reference", map from "context"
|
|
30
|
+
* output: "answer", // Evaluator expects "output", map from "answer"
|
|
31
|
+
* },
|
|
32
|
+
* }
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* // Now you can evaluate with your data structure
|
|
36
|
+
* const result = await evaluator.evaluate({
|
|
37
|
+
* question: "What is AI?",
|
|
38
|
+
* context: "AI is artificial intelligence...",
|
|
39
|
+
* answer: "AI stands for artificial intelligence",
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* **Using nested property access:**
|
|
45
|
+
* ```typescript
|
|
46
|
+
* type ApiResponse = {
|
|
47
|
+
* request: {
|
|
48
|
+
* body: {
|
|
49
|
+
* query: string;
|
|
50
|
+
* context: string;
|
|
51
|
+
* };
|
|
52
|
+
* };
|
|
53
|
+
* response: {
|
|
54
|
+
* data: {
|
|
55
|
+
* text: string;
|
|
56
|
+
* };
|
|
57
|
+
* };
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* const evaluator = bindEvaluator<ApiResponse>(
|
|
61
|
+
* createHallucinationEvaluator({ model: openai("gpt-4") }),
|
|
62
|
+
* {
|
|
63
|
+
* inputMapping: {
|
|
64
|
+
* input: "request.body.query",
|
|
65
|
+
* reference: "request.body.context",
|
|
66
|
+
* output: "response.data.text",
|
|
67
|
+
* },
|
|
68
|
+
* }
|
|
69
|
+
* );
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* **Using function-based mapping for data transformation:**
|
|
74
|
+
* ```typescript
|
|
75
|
+
* type RawData = {
|
|
76
|
+
* question: string;
|
|
77
|
+
* contexts: string[]; // Array of context strings
|
|
78
|
+
* answer: string;
|
|
79
|
+
* };
|
|
80
|
+
*
|
|
81
|
+
* const evaluator = bindEvaluator<RawData>(
|
|
82
|
+
* createHallucinationEvaluator({ model: openai("gpt-4") }),
|
|
83
|
+
* {
|
|
84
|
+
* inputMapping: {
|
|
85
|
+
* input: "question",
|
|
86
|
+
* // Transform array to single string
|
|
87
|
+
* reference: (data) => data.contexts.join("\n\n"),
|
|
88
|
+
* output: "answer",
|
|
89
|
+
* },
|
|
90
|
+
* }
|
|
91
|
+
* );
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* **Using JSONPath for complex queries:**
|
|
96
|
+
* ```typescript
|
|
97
|
+
* type ComplexData = {
|
|
98
|
+
* conversation: {
|
|
99
|
+
* messages: Array<{ role: string; content: string }>;
|
|
100
|
+
* };
|
|
101
|
+
* metadata: {
|
|
102
|
+
* sources: string[];
|
|
103
|
+
* };
|
|
104
|
+
* };
|
|
105
|
+
*
|
|
106
|
+
* const evaluator = bindEvaluator<ComplexData>(
|
|
107
|
+
* createHallucinationEvaluator({ model: openai("gpt-4") }),
|
|
108
|
+
* {
|
|
109
|
+
* inputMapping: {
|
|
110
|
+
* // Extract last user message
|
|
111
|
+
* input: "$.conversation.messages[?(@.role=='user')].content[-1]",
|
|
112
|
+
* // Extract all sources
|
|
113
|
+
* reference: "$.metadata.sources[*]",
|
|
114
|
+
* // Extract last assistant message
|
|
115
|
+
* output: "$.conversation.messages[?(@.role=='assistant')].content[-1]",
|
|
116
|
+
* },
|
|
117
|
+
* }
|
|
118
|
+
* );
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* **Binding multiple evaluators with different mappings:**
|
|
123
|
+
* ```typescript
|
|
124
|
+
* type EvaluationData = {
|
|
125
|
+
* userQuery: string;
|
|
126
|
+
* systemContext: string;
|
|
127
|
+
* modelOutput: string;
|
|
128
|
+
* expectedOutput?: string;
|
|
129
|
+
* };
|
|
130
|
+
*
|
|
131
|
+
* // Hallucination evaluator
|
|
132
|
+
* const hallucinationEvaluator = bindEvaluator<EvaluationData>(
|
|
133
|
+
* createHallucinationEvaluator({ model: openai("gpt-4") }),
|
|
134
|
+
* {
|
|
135
|
+
* inputMapping: {
|
|
136
|
+
* input: "userQuery",
|
|
137
|
+
* reference: "systemContext",
|
|
138
|
+
* output: "modelOutput",
|
|
139
|
+
* },
|
|
140
|
+
* }
|
|
141
|
+
* );
|
|
142
|
+
*
|
|
143
|
+
* // Document relevancy evaluator (if it exists)
|
|
144
|
+
* const relevancyEvaluator = bindEvaluator<EvaluationData>(
|
|
145
|
+
* createDocumentRelevanceEvaluator({ model: openai("gpt-4") }),
|
|
146
|
+
* {
|
|
147
|
+
* inputMapping: {
|
|
148
|
+
* query: "userQuery",
|
|
149
|
+
* document: "systemContext",
|
|
150
|
+
* output: "modelOutput",
|
|
151
|
+
* },
|
|
152
|
+
* }
|
|
153
|
+
* );
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export function bindEvaluator(evaluator, context) {
|
|
157
|
+
let boundEvaluator = evaluator;
|
|
158
|
+
if (context.inputMapping) {
|
|
159
|
+
boundEvaluator = boundEvaluator.bindInputMapping(context.inputMapping);
|
|
160
|
+
}
|
|
161
|
+
return boundEvaluator;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=bindEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindEvaluator.js","sourceRoot":"","sources":["../../../src/utils/bindEvaluator.ts"],"names":[],"mappings":"AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AACH,MAAM,UAAU,aAAa,CAC3B,SAAoC,EACpC,OAAmC;IAEnC,IAAI,cAAc,GAA8B,SAAS,CAAC;IAC1D,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,cAAc,GAAG,cAAc,CAAC,gBAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { ObjectMapping } from "../types/data.js";
|
|
2
|
+
/**
|
|
3
|
+
* Remaps an object by applying field mappings while preserving original data.
|
|
4
|
+
*
|
|
5
|
+
* This function takes your original data object and a mapping configuration,
|
|
6
|
+
* then returns a new object that contains:
|
|
7
|
+
* - All original fields from the input data
|
|
8
|
+
* - Additional/overridden fields based on the mapping
|
|
9
|
+
*
|
|
10
|
+
* The mapping allows you to extract values using:
|
|
11
|
+
* - Simple property names: `"fieldName"`
|
|
12
|
+
* - Dot notation: `"user.profile.name"`
|
|
13
|
+
* - Array access: `"items[0].id"`
|
|
14
|
+
* - JSONPath expressions: `"$.items[*].id"`
|
|
15
|
+
* - Function extractors: `(data) => data.customField`
|
|
16
|
+
*
|
|
17
|
+
* @param data - The input data object to remap
|
|
18
|
+
* @param mapping - The mapping configuration defining how to extract/transform values
|
|
19
|
+
* @returns A new object with original fields plus mapped fields
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* **Basic remapping:**
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const data = {
|
|
25
|
+
* name: "John",
|
|
26
|
+
* age: 30,
|
|
27
|
+
* email: "john@example.com",
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
31
|
+
* userName: "name",
|
|
32
|
+
* userAge: "age",
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* const result = remapObject(data, mapping);
|
|
36
|
+
* // Result: {
|
|
37
|
+
* // name: "John",
|
|
38
|
+
* // age: 30,
|
|
39
|
+
* // email: "john@example.com",
|
|
40
|
+
* // userName: "John", // Added from mapping
|
|
41
|
+
* // userAge: 30, // Added from mapping
|
|
42
|
+
* // }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* **Nested property extraction:**
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const data = {
|
|
49
|
+
* user: {
|
|
50
|
+
* profile: {
|
|
51
|
+
* firstName: "John",
|
|
52
|
+
* lastName: "Doe",
|
|
53
|
+
* },
|
|
54
|
+
* email: "john@example.com",
|
|
55
|
+
* },
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
59
|
+
* firstName: "user.profile.firstName",
|
|
60
|
+
* lastName: "user.profile.lastName",
|
|
61
|
+
* email: "user.email",
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* const result = remapObject(data, mapping);
|
|
65
|
+
* // Result includes original data plus:
|
|
66
|
+
* // {
|
|
67
|
+
* // firstName: "John",
|
|
68
|
+
* // lastName: "Doe",
|
|
69
|
+
* // email: "john@example.com",
|
|
70
|
+
* // }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* **Array element access:**
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const data = {
|
|
77
|
+
* items: [
|
|
78
|
+
* { id: 1, name: "Apple" },
|
|
79
|
+
* { id: 2, name: "Banana" },
|
|
80
|
+
* ],
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
84
|
+
* firstItemId: "items[0].id",
|
|
85
|
+
* firstItemName: "items[0].name",
|
|
86
|
+
* };
|
|
87
|
+
*
|
|
88
|
+
* const result = remapObject(data, mapping);
|
|
89
|
+
* // Result includes:
|
|
90
|
+
* // {
|
|
91
|
+
* // firstItemId: 1,
|
|
92
|
+
* // firstItemName: "Apple",
|
|
93
|
+
* // }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* **Function-based transformation:**
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const data = {
|
|
100
|
+
* firstName: "John",
|
|
101
|
+
* lastName: "Doe",
|
|
102
|
+
* scores: [85, 92, 78],
|
|
103
|
+
* };
|
|
104
|
+
*
|
|
105
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
106
|
+
* fullName: (data) => `${data.firstName} ${data.lastName}`,
|
|
107
|
+
* averageScore: (data) =>
|
|
108
|
+
* data.scores.reduce((a, b) => a + b, 0) / data.scores.length,
|
|
109
|
+
* };
|
|
110
|
+
*
|
|
111
|
+
* const result = remapObject(data, mapping);
|
|
112
|
+
* // Result includes:
|
|
113
|
+
* // {
|
|
114
|
+
* // fullName: "John Doe",
|
|
115
|
+
* // averageScore: 85,
|
|
116
|
+
* // }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* **Field override:**
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const data = {
|
|
123
|
+
* name: "John",
|
|
124
|
+
* status: "inactive",
|
|
125
|
+
* };
|
|
126
|
+
*
|
|
127
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
128
|
+
* // Override existing field
|
|
129
|
+
* status: (data) => data.name === "John" ? "active" : "inactive",
|
|
130
|
+
* // Add new field
|
|
131
|
+
* displayName: (data) => `User: ${data.name}`,
|
|
132
|
+
* };
|
|
133
|
+
*
|
|
134
|
+
* const result = remapObject(data, mapping);
|
|
135
|
+
* // Result:
|
|
136
|
+
* // {
|
|
137
|
+
* // name: "John",
|
|
138
|
+
* // status: "active", // Overridden
|
|
139
|
+
* // displayName: "User: John", // Added
|
|
140
|
+
* // }
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* **Real-world evaluator usage:**
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Your data structure
|
|
147
|
+
* const example = {
|
|
148
|
+
* question: "What is AI?",
|
|
149
|
+
* context: "AI is artificial intelligence...",
|
|
150
|
+
* answer: "AI stands for artificial intelligence",
|
|
151
|
+
* };
|
|
152
|
+
*
|
|
153
|
+
* // Evaluator expects: { input, reference, output }
|
|
154
|
+
* const mapping: ObjectMapping<typeof example> = {
|
|
155
|
+
* input: "question",
|
|
156
|
+
* reference: "context",
|
|
157
|
+
* output: "answer",
|
|
158
|
+
* };
|
|
159
|
+
*
|
|
160
|
+
* const remapped = remapObject(example, mapping);
|
|
161
|
+
* // Now remapped has: { question, context, answer, input, reference, output }
|
|
162
|
+
* // The evaluator can access input, reference, and output fields
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare function remapObject<DataType extends Record<string, unknown>>(data: DataType, mapping: ObjectMapping<DataType>): DataType;
|
|
166
|
+
//# sourceMappingURL=objectMappingUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectMappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/objectMappingUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,eAAe,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,GAC/B,QAAQ,CAUV"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { JSONPath } from "jsonpath-plus";
|
|
2
|
+
/**
|
|
3
|
+
* Remaps an object by applying field mappings while preserving original data.
|
|
4
|
+
*
|
|
5
|
+
* This function takes your original data object and a mapping configuration,
|
|
6
|
+
* then returns a new object that contains:
|
|
7
|
+
* - All original fields from the input data
|
|
8
|
+
* - Additional/overridden fields based on the mapping
|
|
9
|
+
*
|
|
10
|
+
* The mapping allows you to extract values using:
|
|
11
|
+
* - Simple property names: `"fieldName"`
|
|
12
|
+
* - Dot notation: `"user.profile.name"`
|
|
13
|
+
* - Array access: `"items[0].id"`
|
|
14
|
+
* - JSONPath expressions: `"$.items[*].id"`
|
|
15
|
+
* - Function extractors: `(data) => data.customField`
|
|
16
|
+
*
|
|
17
|
+
* @param data - The input data object to remap
|
|
18
|
+
* @param mapping - The mapping configuration defining how to extract/transform values
|
|
19
|
+
* @returns A new object with original fields plus mapped fields
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* **Basic remapping:**
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const data = {
|
|
25
|
+
* name: "John",
|
|
26
|
+
* age: 30,
|
|
27
|
+
* email: "john@example.com",
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
31
|
+
* userName: "name",
|
|
32
|
+
* userAge: "age",
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* const result = remapObject(data, mapping);
|
|
36
|
+
* // Result: {
|
|
37
|
+
* // name: "John",
|
|
38
|
+
* // age: 30,
|
|
39
|
+
* // email: "john@example.com",
|
|
40
|
+
* // userName: "John", // Added from mapping
|
|
41
|
+
* // userAge: 30, // Added from mapping
|
|
42
|
+
* // }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* **Nested property extraction:**
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const data = {
|
|
49
|
+
* user: {
|
|
50
|
+
* profile: {
|
|
51
|
+
* firstName: "John",
|
|
52
|
+
* lastName: "Doe",
|
|
53
|
+
* },
|
|
54
|
+
* email: "john@example.com",
|
|
55
|
+
* },
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
59
|
+
* firstName: "user.profile.firstName",
|
|
60
|
+
* lastName: "user.profile.lastName",
|
|
61
|
+
* email: "user.email",
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* const result = remapObject(data, mapping);
|
|
65
|
+
* // Result includes original data plus:
|
|
66
|
+
* // {
|
|
67
|
+
* // firstName: "John",
|
|
68
|
+
* // lastName: "Doe",
|
|
69
|
+
* // email: "john@example.com",
|
|
70
|
+
* // }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* **Array element access:**
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const data = {
|
|
77
|
+
* items: [
|
|
78
|
+
* { id: 1, name: "Apple" },
|
|
79
|
+
* { id: 2, name: "Banana" },
|
|
80
|
+
* ],
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
84
|
+
* firstItemId: "items[0].id",
|
|
85
|
+
* firstItemName: "items[0].name",
|
|
86
|
+
* };
|
|
87
|
+
*
|
|
88
|
+
* const result = remapObject(data, mapping);
|
|
89
|
+
* // Result includes:
|
|
90
|
+
* // {
|
|
91
|
+
* // firstItemId: 1,
|
|
92
|
+
* // firstItemName: "Apple",
|
|
93
|
+
* // }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* **Function-based transformation:**
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const data = {
|
|
100
|
+
* firstName: "John",
|
|
101
|
+
* lastName: "Doe",
|
|
102
|
+
* scores: [85, 92, 78],
|
|
103
|
+
* };
|
|
104
|
+
*
|
|
105
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
106
|
+
* fullName: (data) => `${data.firstName} ${data.lastName}`,
|
|
107
|
+
* averageScore: (data) =>
|
|
108
|
+
* data.scores.reduce((a, b) => a + b, 0) / data.scores.length,
|
|
109
|
+
* };
|
|
110
|
+
*
|
|
111
|
+
* const result = remapObject(data, mapping);
|
|
112
|
+
* // Result includes:
|
|
113
|
+
* // {
|
|
114
|
+
* // fullName: "John Doe",
|
|
115
|
+
* // averageScore: 85,
|
|
116
|
+
* // }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* **Field override:**
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const data = {
|
|
123
|
+
* name: "John",
|
|
124
|
+
* status: "inactive",
|
|
125
|
+
* };
|
|
126
|
+
*
|
|
127
|
+
* const mapping: ObjectMapping<typeof data> = {
|
|
128
|
+
* // Override existing field
|
|
129
|
+
* status: (data) => data.name === "John" ? "active" : "inactive",
|
|
130
|
+
* // Add new field
|
|
131
|
+
* displayName: (data) => `User: ${data.name}`,
|
|
132
|
+
* };
|
|
133
|
+
*
|
|
134
|
+
* const result = remapObject(data, mapping);
|
|
135
|
+
* // Result:
|
|
136
|
+
* // {
|
|
137
|
+
* // name: "John",
|
|
138
|
+
* // status: "active", // Overridden
|
|
139
|
+
* // displayName: "User: John", // Added
|
|
140
|
+
* // }
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* **Real-world evaluator usage:**
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Your data structure
|
|
147
|
+
* const example = {
|
|
148
|
+
* question: "What is AI?",
|
|
149
|
+
* context: "AI is artificial intelligence...",
|
|
150
|
+
* answer: "AI stands for artificial intelligence",
|
|
151
|
+
* };
|
|
152
|
+
*
|
|
153
|
+
* // Evaluator expects: { input, reference, output }
|
|
154
|
+
* const mapping: ObjectMapping<typeof example> = {
|
|
155
|
+
* input: "question",
|
|
156
|
+
* reference: "context",
|
|
157
|
+
* output: "answer",
|
|
158
|
+
* };
|
|
159
|
+
*
|
|
160
|
+
* const remapped = remapObject(example, mapping);
|
|
161
|
+
* // Now remapped has: { question, context, answer, input, reference, output }
|
|
162
|
+
* // The evaluator can access input, reference, and output fields
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function remapObject(data, mapping) {
|
|
166
|
+
return {
|
|
167
|
+
...data,
|
|
168
|
+
...Object.fromEntries(Object.entries(mapping).map(([key, value]) => [
|
|
169
|
+
key,
|
|
170
|
+
getMappedObjectValue(data, value),
|
|
171
|
+
])),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Extracts a value from a data object using a value getter.
|
|
176
|
+
*
|
|
177
|
+
* This internal function handles the actual extraction logic, supporting both
|
|
178
|
+
* string-based paths (including JSONPath) and function-based extractors.
|
|
179
|
+
*
|
|
180
|
+
* @param data - The data object to extract from
|
|
181
|
+
* @param valueGetter - The value getter (string path or function)
|
|
182
|
+
* @returns The extracted value
|
|
183
|
+
*
|
|
184
|
+
* @internal
|
|
185
|
+
*/
|
|
186
|
+
function getMappedObjectValue(data, valueGetter) {
|
|
187
|
+
return typeof valueGetter === "function"
|
|
188
|
+
? valueGetter(data)
|
|
189
|
+
: JSONPath({ path: valueGetter, json: data, wrap: false });
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=objectMappingUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectMappingUtils.js","sourceRoot":"","sources":["../../../src/utils/objectMappingUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkKG;AACH,MAAM,UAAU,WAAW,CACzB,IAAc,EACd,OAAgC;IAEhC,OAAO;QACL,GAAG,IAAI;QACP,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YAC5C,GAAG;YACH,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC;SAClC,CAAC,CACH;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAC3B,IAAc,EACd,WAAkC;IAElC,OAAO,OAAO,WAAW,KAAK,UAAU;QACtC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACnB,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.d.ts","sourceRoot":"","sources":["../../../../src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAE9D,eAAO,MAAM,kDAAkD,EAAE,6BAkChE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is generated. Do not edit by hand.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG = void 0;
|
|
5
|
+
exports.DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG = {
|
|
6
|
+
name: "document_relevance",
|
|
7
|
+
description: "A specialized evaluator for determining document relevance to a given question.",
|
|
8
|
+
optimizationDirection: "MAXIMIZE",
|
|
9
|
+
template: [
|
|
10
|
+
{
|
|
11
|
+
role: "user",
|
|
12
|
+
content: `
|
|
13
|
+
You are comparing a document to a question and trying to determine
|
|
14
|
+
if the document text contains information relevant to answering the
|
|
15
|
+
question. Here is the data:
|
|
16
|
+
|
|
17
|
+
[BEGIN DATA]
|
|
18
|
+
************
|
|
19
|
+
[Question]: {{input}}
|
|
20
|
+
************
|
|
21
|
+
[Document text]: {{documentText}}
|
|
22
|
+
************
|
|
23
|
+
[END DATA]
|
|
24
|
+
|
|
25
|
+
Compare the question above to the document text. You must determine
|
|
26
|
+
whether the document text contains information that can answer the
|
|
27
|
+
question. Please focus on whether the very specific question can be
|
|
28
|
+
answered by the information in the document text. Your response must be
|
|
29
|
+
either "relevant" or "unrelated". "unrelated" means that the document
|
|
30
|
+
text does not contain an answer to the question. "relevant" means the
|
|
31
|
+
document text contains an answer to the question.
|
|
32
|
+
`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
choices: {
|
|
36
|
+
"relevant": 1,
|
|
37
|
+
"unrelated": 0
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.js","sourceRoot":"","sources":["../../../../src/__generated__/default_templates/DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG.ts"],"names":[],"mappings":";AAAA,+CAA+C;;;AAIlC,QAAA,kDAAkD,GAAkC;IAC/F,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,iFAAiF;IAC9F,qBAAqB,EAAE,UAAU;IACjC,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;CAoBd;SACI;KACF;IACD,OAAO,EAAE;QACT,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;KACf;CACA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.d.ts","sourceRoot":"","sources":["../../../../src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAE9D,eAAO,MAAM,6CAA6C,EAAE,6BAwC3D,CAAC"}
|
package/dist/src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is generated. Do not edit by hand.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG = void 0;
|
|
5
|
+
exports.HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG = {
|
|
6
|
+
name: "hallucination",
|
|
7
|
+
description: "A specialized evaluator for detecting hallucinations in grounded LLM responses.",
|
|
8
|
+
optimizationDirection: "MINIMIZE",
|
|
9
|
+
template: [
|
|
10
|
+
{
|
|
11
|
+
role: "user",
|
|
12
|
+
content: `
|
|
13
|
+
In this task, you will be presented with a query, some context and a response. The response
|
|
14
|
+
is generated to the question based on the context. The response may contain false
|
|
15
|
+
information. You must use the context to determine if the response to the question
|
|
16
|
+
contains false information, if the response is a hallucination of facts. Your objective is
|
|
17
|
+
to determine whether the response text contains factual information and is not a
|
|
18
|
+
hallucination. A 'hallucination' refers to a response that is not based on the context or
|
|
19
|
+
assumes information that is not available in the context. Your response should be a single
|
|
20
|
+
word: either 'factual' or 'hallucinated', and it should not include any other text or
|
|
21
|
+
characters. 'hallucinated' indicates that the response provides factually inaccurate
|
|
22
|
+
information to the query based on the context. 'factual' indicates that the response to
|
|
23
|
+
the question is correct relative to the context, and does not contain made up
|
|
24
|
+
information. Please read the query and context carefully before determining your
|
|
25
|
+
response.
|
|
26
|
+
|
|
27
|
+
[BEGIN DATA]
|
|
28
|
+
************
|
|
29
|
+
[Query]: {{input}}
|
|
30
|
+
************
|
|
31
|
+
[Context]: {{context}}
|
|
32
|
+
************
|
|
33
|
+
[Response]: {{output}}
|
|
34
|
+
************
|
|
35
|
+
[END DATA]
|
|
36
|
+
|
|
37
|
+
Is the response above factual or hallucinated based on the query and context?
|
|
38
|
+
`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
choices: {
|
|
42
|
+
"hallucinated": 1,
|
|
43
|
+
"factual": 0
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.js","sourceRoot":"","sources":["../../../../src/__generated__/default_templates/HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.ts"],"names":[],"mappings":";AAAA,+CAA+C;;;AAIlC,QAAA,6CAA6C,GAAkC;IAC1F,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,iFAAiF;IAC9F,qBAAqB,EAAE,UAAU;IACjC,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Bd;SACI;KACF;IACD,OAAO,EAAE;QACT,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,CAAC;KACb;CACA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/__generated__/default_templates/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kDAAkD,EAAE,MAAM,sDAAsD,CAAC;AAC1H,OAAO,EAAE,6CAA6C,EAAE,MAAM,iDAAiD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is generated. Do not edit by hand.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG = exports.DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG = void 0;
|
|
5
|
+
var DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG_1 = require("./DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG");
|
|
6
|
+
Object.defineProperty(exports, "DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG", { enumerable: true, get: function () { return DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG_1.DOCUMENT_RELEVANCE_CLASSIFICATION_EVALUATOR_CONFIG; } });
|
|
7
|
+
var HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG_1 = require("./HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG");
|
|
8
|
+
Object.defineProperty(exports, "HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG", { enumerable: true, get: function () { return HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG_1.HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|