llm-testrunner-components 1.2.2 → 1.2.4
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/cjs/{app-chips_4.cjs.entry.js → app-chips_5.cjs.entry.js} +41 -6
- package/dist/cjs/app-chips_5.cjs.entry.js.map +1 -0
- package/dist/cjs/index.cjs.js +235 -44
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/llm-testrunner.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/llm-test-runner/llm-test-runner.import-export.test.js +22 -12
- package/dist/collection/components/llm-test-runner/llm-test-runner.import-export.test.js.map +1 -1
- package/dist/collection/components/llm-test-runner/llm-test-runner.js +91 -30
- package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
- package/dist/collection/components/llm-test-runner/test-cases/chat-history.css +101 -0
- package/dist/collection/components/llm-test-runner/test-cases/chat-history.js +105 -0
- package/dist/collection/components/llm-test-runner/test-cases/chat-history.js.map +1 -0
- package/dist/collection/components/llm-test-runner/test-cases/expected-outcome-renderer.js +37 -4
- package/dist/collection/components/llm-test-runner/test-cases/expected-outcome-renderer.js.map +1 -1
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js +12 -2
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js.map +1 -1
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js +2 -2
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/lib/evaluation/evaluation-service.js +14 -7
- package/dist/collection/lib/evaluation/evaluation-service.js.map +1 -1
- package/dist/collection/lib/form/components/app-chips.js +1 -1
- package/dist/collection/lib/form/components/app-select.js +1 -1
- package/dist/collection/lib/form/components/app-textarea.css +17 -0
- package/dist/collection/lib/form/components/app-textarea.js +4 -1
- package/dist/collection/lib/form/components/app-textarea.js.map +1 -1
- package/dist/collection/lib/import-export/test-suite-exporter.js +4 -0
- package/dist/collection/lib/import-export/test-suite-exporter.js.map +1 -1
- package/dist/collection/lib/test-cases/dynamic-expected-outcome-resolver.js +44 -0
- package/dist/collection/lib/test-cases/dynamic-expected-outcome-resolver.js.map +1 -0
- package/dist/collection/lib/test-cases/test-case-factory.js +2 -0
- package/dist/collection/lib/test-cases/test-case-factory.js.map +1 -1
- package/dist/collection/lib/test-cases/test-case-mutations.js +35 -0
- package/dist/collection/lib/test-cases/test-case-mutations.js.map +1 -1
- package/dist/collection/schemas/expected-outcome.js +15 -1
- package/dist/collection/schemas/expected-outcome.js.map +1 -1
- package/dist/collection/schemas/test-case.js +6 -0
- package/dist/collection/schemas/test-case.js.map +1 -1
- package/dist/collection/types/expected-outcome.js.map +1 -1
- package/dist/collection/types/llm-test-runner.js.map +1 -1
- package/dist/collection/types/test-case.js.map +1 -1
- package/dist/components/app-chips.js +1 -1
- package/dist/components/app-select.js +1 -1
- package/dist/components/app-textarea.js +1 -1
- package/dist/components/chat-history.d.ts +11 -0
- package/dist/components/chat-history.js +2 -0
- package/dist/components/chat-history.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/llm-test-runner.js +1 -1
- package/dist/components/{p-CJBscebi.js → p-B87Lt3z4.js} +3 -3
- package/dist/components/p-B87Lt3z4.js.map +1 -0
- package/dist/components/p-Bx2jqguC.js +2 -0
- package/dist/components/p-Bx2jqguC.js.map +1 -0
- package/dist/components/p-D2qDAxFN.js +2 -0
- package/dist/components/p-D2qDAxFN.js.map +1 -0
- package/dist/components/{p-Dv7cB5FU.js → p-D4dHUFN9.js} +2 -2
- package/dist/components/{p-CE5-1jfZ.js → p-eN2dLrsr.js} +2 -2
- package/dist/esm/{app-chips_4.entry.js → app-chips_5.entry.js} +41 -7
- package/dist/esm/app-chips_5.entry.js.map +1 -0
- package/dist/esm/index.js +235 -44
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/llm-testrunner.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/llm-testrunner/index.esm.js +2 -2
- package/dist/llm-testrunner/index.esm.js.map +1 -1
- package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
- package/dist/llm-testrunner/p-21202f12.entry.js +2 -0
- package/dist/llm-testrunner/p-21202f12.entry.js.map +1 -0
- package/dist/react/components.d.ts +6 -1
- package/dist/react/components.d.ts.map +1 -1
- package/dist/react/components.js +9 -0
- package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +6 -0
- package/dist/types/components/llm-test-runner/test-cases/chat-history.d.ts +14 -0
- package/dist/types/components/llm-test-runner/test-cases/expected-outcome-renderer.d.ts +1 -0
- package/dist/types/components/llm-test-runner/test-cases/llm-test-case-row.d.ts +6 -0
- package/dist/types/components/llm-test-runner/test-cases/llm-test-cases.d.ts +3 -0
- package/dist/types/components.d.ts +55 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/import-export/test-suite-exporter.d.ts +4 -0
- package/dist/types/lib/test-cases/dynamic-expected-outcome-resolver.d.ts +7 -0
- package/dist/types/lib/test-cases/test-case-mutations.d.ts +9 -1
- package/dist/types/schemas/expected-outcome.d.ts +16 -1
- package/dist/types/schemas/test-case.d.ts +34 -2
- package/dist/types/types/expected-outcome.d.ts +1 -1
- package/dist/types/types/llm-test-runner.d.ts +3 -2
- package/dist/types/types/test-case.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/app-chips_4.cjs.entry.js.map +0 -1
- package/dist/components/p-BZrzx5jG.js +0 -2
- package/dist/components/p-BZrzx5jG.js.map +0 -1
- package/dist/components/p-CJBscebi.js.map +0 -1
- package/dist/esm/app-chips_4.entry.js.map +0 -1
- package/dist/llm-testrunner/p-2cc09217.entry.js +0 -2
- package/dist/llm-testrunner/p-2cc09217.entry.js.map +0 -1
- /package/dist/components/{p-Dv7cB5FU.js.map → p-D4dHUFN9.js.map} +0 -0
- /package/dist/components/{p-CE5-1jfZ.js.map → p-eN2dLrsr.js.map} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const MISSING_RESOLVER_MESSAGE = 'resolveExpectedOutcome is required when a test case has dynamic expected outcomes.';
|
|
2
|
+
function isDynamicTextareaField(field) {
|
|
3
|
+
return field.type === 'textarea' && field.outcomeMode === 'dynamic';
|
|
4
|
+
}
|
|
5
|
+
function applyResolvedDynamicValues(testCase, resolvedValues) {
|
|
6
|
+
if (resolvedValues.length === 0) {
|
|
7
|
+
return testCase;
|
|
8
|
+
}
|
|
9
|
+
const expectedOutcome = [...(testCase.expectedOutcome || [])];
|
|
10
|
+
for (const resolved of resolvedValues) {
|
|
11
|
+
const field = expectedOutcome[resolved.index];
|
|
12
|
+
if (!field || !isDynamicTextareaField(field)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
expectedOutcome[resolved.index] = {
|
|
16
|
+
...field,
|
|
17
|
+
value: resolved.value,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...testCase,
|
|
22
|
+
expectedOutcome,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export async function resolveDynamicExpectedOutcomes(testCase, resolver) {
|
|
26
|
+
const dynamicFields = (testCase.expectedOutcome || []).flatMap((field, index) => {
|
|
27
|
+
if (!isDynamicTextareaField(field)) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return [{ field, index }];
|
|
31
|
+
});
|
|
32
|
+
if (dynamicFields.length === 0) {
|
|
33
|
+
return testCase;
|
|
34
|
+
}
|
|
35
|
+
if (!resolver) {
|
|
36
|
+
throw new Error(MISSING_RESOLVER_MESSAGE);
|
|
37
|
+
}
|
|
38
|
+
const resolvedValues = await Promise.all(dynamicFields.map(async ({ field, index }) => ({
|
|
39
|
+
index,
|
|
40
|
+
value: await resolver(field.resolutionQuery || '', { testCase, fieldIndex: index }),
|
|
41
|
+
})));
|
|
42
|
+
return applyResolvedDynamicValues(testCase, resolvedValues);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=dynamic-expected-outcome-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-expected-outcome-resolver.js","sourceRoot":"","sources":["../../../src/lib/test-cases/dynamic-expected-outcome-resolver.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,wBAAwB,GACnC,oFAAoF,CAAC;AAIvF,SAAS,sBAAsB,CAC7B,KAA2B;IAE3B,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,0BAA0B,CACjC,QAAkB,EAClB,cAAsC;IAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,eAAe,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9D,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,SAAS;QACX,CAAC;QACD,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG;YAChC,GAAG,KAAK;YACR,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,QAAQ;QACX,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,QAAkB,EAClB,QAAkC;IAElC,MAAM,aAAa,GAAG,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9E,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACtC,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7C,KAAK;QACL,KAAK,EAAE,MAAM,QAAQ,CACnB,KAAK,CAAC,eAAe,IAAI,EAAE,EAC3B,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAChC;KACF,CAAC,CAAC,CACJ,CAAC;IAEF,OAAO,0BAA0B,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import {\n ExpectedOutcomeField,\n TestCase,\n TextareaExpectedOutcomeField,\n} from '../../types/llm-test-runner';\n\nexport type ExpectedOutcomeResolver = (\n resolutionQuery: string,\n context: { testCase: TestCase; fieldIndex: number },\n) => Promise<string>;\n\nexport const MISSING_RESOLVER_MESSAGE =\n 'resolveExpectedOutcome is required when a test case has dynamic expected outcomes.';\n\ntype ResolvedDynamicValue = { index: number; value: string };\n\nfunction isDynamicTextareaField(\n field: ExpectedOutcomeField,\n): field is TextareaExpectedOutcomeField {\n return field.type === 'textarea' && field.outcomeMode === 'dynamic';\n}\n\nfunction applyResolvedDynamicValues(\n testCase: TestCase,\n resolvedValues: ResolvedDynamicValue[],\n): TestCase {\n if (resolvedValues.length === 0) {\n return testCase;\n }\n\n const expectedOutcome = [...(testCase.expectedOutcome || [])];\n for (const resolved of resolvedValues) {\n const field = expectedOutcome[resolved.index];\n if (!field || !isDynamicTextareaField(field)) {\n continue;\n }\n expectedOutcome[resolved.index] = {\n ...field,\n value: resolved.value,\n };\n }\n\n return {\n ...testCase,\n expectedOutcome,\n };\n}\n\nexport async function resolveDynamicExpectedOutcomes(\n testCase: TestCase,\n resolver?: ExpectedOutcomeResolver,\n): Promise<TestCase> {\n const dynamicFields = (testCase.expectedOutcome || []).flatMap((field, index) => {\n if (!isDynamicTextareaField(field)) {\n return [];\n }\n return [{ field, index }];\n });\n\n if (dynamicFields.length === 0) {\n return testCase;\n }\n\n if (!resolver) {\n throw new Error(MISSING_RESOLVER_MESSAGE);\n }\n\n const resolvedValues = await Promise.all(\n dynamicFields.map(async ({ field, index }) => ({\n index,\n value: await resolver(\n field.resolutionQuery || '',\n { testCase, fieldIndex: index },\n ),\n })),\n );\n\n return applyResolvedDynamicValues(testCase, resolvedValues);\n}\n"]}
|
|
@@ -23,6 +23,7 @@ export function createTestCase(expectedOutcomeSchema = DEFAULT_EXPECTED_OUTCOME_
|
|
|
23
23
|
id: uuidv4(),
|
|
24
24
|
question: '',
|
|
25
25
|
expectedOutcome: createExpectedOutcomeFromSchema(expectedOutcomeSchema),
|
|
26
|
+
chatHistory: { enabled: false, value: '' },
|
|
26
27
|
isRunning: false,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
@@ -82,6 +83,7 @@ export function createExpectedOutcomeFromSchema(expectedOutcomeSchema) {
|
|
|
82
83
|
export function createTestCaseFromInput(data) {
|
|
83
84
|
return {
|
|
84
85
|
...data,
|
|
86
|
+
chatHistory: data.chatHistory ?? { enabled: false, value: '' },
|
|
85
87
|
expectedOutcome: data.expectedOutcome.map(normalizeExpectedOutcomeField),
|
|
86
88
|
};
|
|
87
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-case-factory.js","sourceRoot":"","sources":["../../../src/lib/test-cases/test-case-factory.ts"],"names":[],"mappings":"AAAA,OAAO,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B,WAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;QAEJ,KAAK,aAAa;YAChB,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,WAAW,EAAE,WAAW,CAAC,WAAW;gBACpC,KAAK,EAAE,EAAE;gBACT,oBAAoB,EAAE,qCAAqC,CACzD,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;QAEJ,KAAK,QAAQ;YACX,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,WAAW,EAAE,WAAW,CAAC,WAAW;gBACpC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC7B,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,oBAAoB,EAAE,qCAAqC,CACzD,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,oBAAoB,CAC6B;aAChE,CAAC;QAEJ,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,gBAAgB,GAAU,WAAW,CAAC;YAC5C,OAAO,gBAAgB,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,qBAA4C;IAE5C,OAAO,qBAAqB,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAmB;IACzD,OAAO;QACL,GAAG,IAAI;QACP,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,6BAA6B,CAAC;KACzE,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport {\n ExpectedOutcomeField,\n ExpectedOutcomeSchema,\n ExpectedOutcomeSchemaField,\n TestCase,\n TestCaseInput,\n} from '../../types/llm-test-runner';\nimport { EvaluationApproach } from '../evaluation/constants';\nimport { normalizeEvaluationParametersForField } from '../evaluation/field-evaluation-approach';\n\nexport const DEFAULT_EXPECTED_OUTCOME_SCHEMA: ExpectedOutcomeSchema = [\n {\n type: 'textarea',\n label: 'Expected Outcome',\n placeholder: 'Enter expected outcome...',\n rows: 2,\n },\n];\n\nfunction normalizeExpectedOutcomeField(\n field: ExpectedOutcomeField,\n): ExpectedOutcomeField {\n return {\n ...field,\n evaluationParameters: normalizeEvaluationParametersForField(\n field.type,\n field.evaluationParameters,\n ),\n };\n}\n\n/**\n * Creates a new test case with default values\n * @returns A new TestCase object with a unique ID\n */\nexport function createTestCase(\n expectedOutcomeSchema: ExpectedOutcomeSchema = DEFAULT_EXPECTED_OUTCOME_SCHEMA,\n): TestCase {\n return {\n id: uuidv4(),\n question: '',\n expectedOutcome: createExpectedOutcomeFromSchema(expectedOutcomeSchema),\n isRunning: false,\n };\n}\n\nfunction createExpectedOutcomeFieldFromSchema(\n schemaField: ExpectedOutcomeSchemaField,\n): ExpectedOutcomeField {\n switch (schemaField.type) {\n case 'text':\n return {\n type: 'text',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n value: '',\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ),\n };\n\n case 'textarea':\n return {\n type: 'textarea',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n rows: schemaField.rows,\n value: '',\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ),\n };\n\n case 'chips-input':\n return {\n type: 'chips-input',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n value: [],\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ),\n };\n\n case 'select':\n return {\n type: 'select',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n value: schemaField.options[0],\n options: schemaField.options,\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ) as { approach: EvaluationApproach.EXACT; threshold?: number },\n };\n\n default: {\n const _exhaustiveCheck: never = schemaField;\n return _exhaustiveCheck;\n }\n }\n}\n\nexport function createExpectedOutcomeFromSchema(\n expectedOutcomeSchema: ExpectedOutcomeSchema,\n): ExpectedOutcomeField[] {\n return expectedOutcomeSchema.map(createExpectedOutcomeFieldFromSchema);\n}\n\n/**\n * Creates a runtime test case from validated input data.\n * The input is expected to already satisfy `TestCaseInput`,\n * and this function only performs normalization/defaulting.\n *\n * @param data - Validated test case input\n * @returns A normalized TestCase object with runtime defaults applied\n */\nexport function createTestCaseFromInput(data: TestCaseInput): TestCase {\n return {\n ...data,\n expectedOutcome: data.expectedOutcome.map(normalizeExpectedOutcomeField),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test-case-factory.js","sourceRoot":"","sources":["../../../src/lib/test-cases/test-case-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AASpC,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAEhG,MAAM,CAAC,MAAM,+BAA+B,GAA0B;IACpE;QACE,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,2BAA2B;QACxC,IAAI,EAAE,CAAC;KACR;CACF,CAAC;AAEF,SAAS,6BAA6B,CACpC,KAA2B;IAE3B,OAAO;QACL,GAAG,KAAK;QACR,oBAAoB,EAAE,qCAAqC,CACzD,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,oBAAoB,CAC3B;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,wBAA+C,+BAA+B;IAE9E,OAAO;QACL,EAAE,EAAE,MAAM,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,+BAA+B,CAAC,qBAAqB,CAAC;QACvE,WAAW,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1C,SAAS,EAAE,KAAK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AC,CAAC,CAAC;YACR,MAAM,gBAAgB,GAAU,WAAW,CAAC;YAC5C,OAAO,gBAAgB,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,qBAA4C;IAE5C,OAAO,qBAAqB,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAmB;IACzD,OAAO;QACL,GAAG,IAAI;QACP,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE;QAC9D,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,6BAA6B,CAAC;KACzE,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport {\n ExpectedOutcomeField,\n ExpectedOutcomeSchema,\n ExpectedOutcomeSchemaField,\n TestCase,\n TestCaseInput,\n} from '../../types/llm-test-runner';\nimport { EvaluationApproach } from '../evaluation/constants';\nimport { normalizeEvaluationParametersForField } from '../evaluation/field-evaluation-approach';\n\nexport const DEFAULT_EXPECTED_OUTCOME_SCHEMA: ExpectedOutcomeSchema = [\n {\n type: 'textarea',\n label: 'Expected Outcome',\n placeholder: 'Enter expected outcome...',\n rows: 2,\n },\n];\n\nfunction normalizeExpectedOutcomeField(\n field: ExpectedOutcomeField,\n): ExpectedOutcomeField {\n return {\n ...field,\n evaluationParameters: normalizeEvaluationParametersForField(\n field.type,\n field.evaluationParameters,\n ),\n };\n}\n\n/**\n * Creates a new test case with default values\n * @returns A new TestCase object with a unique ID\n */\nexport function createTestCase(\n expectedOutcomeSchema: ExpectedOutcomeSchema = DEFAULT_EXPECTED_OUTCOME_SCHEMA,\n): TestCase {\n return {\n id: uuidv4(),\n question: '',\n expectedOutcome: createExpectedOutcomeFromSchema(expectedOutcomeSchema),\n chatHistory: { enabled: false, value: '' },\n isRunning: false,\n };\n}\n\nfunction createExpectedOutcomeFieldFromSchema(\n schemaField: ExpectedOutcomeSchemaField,\n): ExpectedOutcomeField {\n switch (schemaField.type) {\n case 'text':\n return {\n type: 'text',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n value: '',\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ),\n };\n\n case 'textarea':\n return {\n type: 'textarea',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n rows: schemaField.rows,\n value: '',\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ),\n };\n\n case 'chips-input':\n return {\n type: 'chips-input',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n value: [],\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ),\n };\n\n case 'select':\n return {\n type: 'select',\n label: schemaField.label,\n placeholder: schemaField.placeholder,\n value: schemaField.options[0],\n options: schemaField.options,\n evaluationParameters: normalizeEvaluationParametersForField(\n schemaField.type,\n schemaField.evaluationParameters,\n ) as { approach: EvaluationApproach.EXACT; threshold?: number },\n };\n\n default: {\n const _exhaustiveCheck: never = schemaField;\n return _exhaustiveCheck;\n }\n }\n}\n\nexport function createExpectedOutcomeFromSchema(\n expectedOutcomeSchema: ExpectedOutcomeSchema,\n): ExpectedOutcomeField[] {\n return expectedOutcomeSchema.map(createExpectedOutcomeFieldFromSchema);\n}\n\n/**\n * Creates a runtime test case from validated input data.\n * The input is expected to already satisfy `TestCaseInput`,\n * and this function only performs normalization/defaulting.\n *\n * @param data - Validated test case input\n * @returns A normalized TestCase object with runtime defaults applied\n */\nexport function createTestCaseFromInput(data: TestCaseInput): TestCase {\n return {\n ...data,\n chatHistory: data.chatHistory ?? { enabled: false, value: '' },\n expectedOutcome: data.expectedOutcome.map(normalizeExpectedOutcomeField),\n };\n}\n"]}
|
|
@@ -11,6 +11,9 @@ export function applyExpectedOutcomeChange(testCase, change) {
|
|
|
11
11
|
if (target.type === 'chips-input') {
|
|
12
12
|
return testCase;
|
|
13
13
|
}
|
|
14
|
+
if (target.type === 'textarea' && target.outcomeMode === 'dynamic') {
|
|
15
|
+
return testCase;
|
|
16
|
+
}
|
|
14
17
|
expectedOutcome[index] = {
|
|
15
18
|
...target,
|
|
16
19
|
value: change.value,
|
|
@@ -39,6 +42,38 @@ export function applyExpectedOutcomeChange(testCase, change) {
|
|
|
39
42
|
}
|
|
40
43
|
case 'set-evaluation-approach':
|
|
41
44
|
return updateExpectedOutcomeFieldApproach(testCase, index, change.value);
|
|
45
|
+
case 'set-outcome-mode': {
|
|
46
|
+
if (target.type !== 'textarea') {
|
|
47
|
+
return testCase;
|
|
48
|
+
}
|
|
49
|
+
const mode = change.value;
|
|
50
|
+
if (mode === 'static') {
|
|
51
|
+
const { resolutionQuery: _, ...rest } = target;
|
|
52
|
+
expectedOutcome[index] = {
|
|
53
|
+
...rest,
|
|
54
|
+
outcomeMode: 'static',
|
|
55
|
+
value: '',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
expectedOutcome[index] = {
|
|
60
|
+
...target,
|
|
61
|
+
outcomeMode: 'dynamic',
|
|
62
|
+
value: '',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { ...testCase, expectedOutcome };
|
|
66
|
+
}
|
|
67
|
+
case 'set-resolution-query': {
|
|
68
|
+
if (target.type !== 'textarea' || target.outcomeMode !== 'dynamic') {
|
|
69
|
+
return testCase;
|
|
70
|
+
}
|
|
71
|
+
expectedOutcome[index] = {
|
|
72
|
+
...target,
|
|
73
|
+
resolutionQuery: change.value,
|
|
74
|
+
};
|
|
75
|
+
return { ...testCase, expectedOutcome };
|
|
76
|
+
}
|
|
42
77
|
}
|
|
43
78
|
}
|
|
44
79
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-case-mutations.js","sourceRoot":"","sources":["../../../src/lib/test-cases/test-case-mutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-case-mutations.js","sourceRoot":"","sources":["../../../src/lib/test-cases/test-case-mutations.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAkChG,MAAM,UAAU,0BAA0B,CACxC,QAAkB,EAClB,MAA6B;IAE7B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,eAAe,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,MAAM,CAAC,SAAS,EAAE,CAAC;QACzB,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;gBAClC,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBACnE,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,eAAe,CAAC,KAAK,CAAC,GAAG;gBACvB,GAAG,MAAM;gBACT,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC;YACF,OAAO,EAAE,GAAG,QAAQ,EAAE,eAAe,EAAE,CAAC;QAC1C,CAAC;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;gBAClC,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,eAAe,CAAC,KAAK,CAAC,GAAG;gBACvB,GAAG,MAAM;gBACT,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;aACvC,CAAC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AC5B,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBACnE,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,eAAe,CAAC,KAAK,CAAC,GAAG;gBACvB,GAAG,MAAM;gBACT,eAAe,EAAE,MAAM,CAAC,KAAK;aAC9B,CAAC;YACF,OAAO,EAAE,GAAG,QAAQ,EAAE,eAAe,EAAE,CAAC;QAC1C,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CAChD,QAAkB,EAClB,UAAkB,EAClB,QAA4B;IAE5B,MAAM,eAAe,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,2BAA2B,GAAG,MAAM,CAAC,oBAAoB,CAAC;IAChE,eAAe,CAAC,UAAU,CAAC,GAAG;QAC5B,GAAG,MAAM;QACT,oBAAoB,EAAE,qCAAqC,CAAC,MAAM,CAAC,IAAI,EAAE;YACvE,GAAG,2BAA2B;YAC9B,QAAQ;SACT,CAAC;KACH,CAAC;IAEF,OAAO;QACL,GAAG,QAAQ;QACX,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import {\n TestCase,\n type ExpectedOutcomeMode,\n} from '../../types/llm-test-runner';\nimport { EvaluationApproach } from '../evaluation/constants';\nimport { normalizeEvaluationParametersForField } from '../evaluation/field-evaluation-approach';\n\nexport type ExpectedOutcomeChange =\n | {\n index: number;\n operation: 'set-value';\n value: string;\n }\n | {\n index: number;\n operation: 'add-chip';\n value: string;\n }\n | {\n index: number;\n operation: 'remove-chip';\n value: string;\n }\n | {\n index: number;\n operation: 'set-evaluation-approach';\n value: EvaluationApproach;\n }\n | {\n index: number;\n operation: 'set-outcome-mode';\n value: ExpectedOutcomeMode;\n }\n | {\n index: number;\n operation: 'set-resolution-query';\n value: string;\n };\n\nexport function applyExpectedOutcomeChange(\n testCase: TestCase,\n change: ExpectedOutcomeChange,\n): TestCase {\n const { index } = change;\n const expectedOutcome = [...(testCase.expectedOutcome || [])];\n const target = expectedOutcome[index];\n\n if (!target) {\n return testCase;\n }\n\n switch (change.operation) {\n case 'set-value': {\n if (target.type === 'chips-input') {\n return testCase;\n }\n if (target.type === 'textarea' && target.outcomeMode === 'dynamic') {\n return testCase;\n }\n expectedOutcome[index] = {\n ...target,\n value: change.value,\n };\n return { ...testCase, expectedOutcome };\n }\n case 'add-chip': {\n if (target.type !== 'chips-input') {\n return testCase;\n }\n expectedOutcome[index] = {\n ...target,\n value: [...target.value, change.value],\n };\n return { ...testCase, expectedOutcome };\n }\n case 'remove-chip': {\n if (target.type !== 'chips-input') {\n return testCase;\n }\n expectedOutcome[index] = {\n ...target,\n value: target.value.filter(chip => chip !== change.value),\n };\n return { ...testCase, expectedOutcome };\n }\n case 'set-evaluation-approach':\n return updateExpectedOutcomeFieldApproach(testCase, index, change.value);\n case 'set-outcome-mode': {\n if (target.type !== 'textarea') {\n return testCase;\n }\n const mode = change.value;\n if (mode === 'static') {\n const { resolutionQuery: _, ...rest } = target;\n expectedOutcome[index] = {\n ...rest,\n outcomeMode: 'static',\n value: '',\n };\n } else {\n expectedOutcome[index] = {\n ...target,\n outcomeMode: 'dynamic',\n value: '',\n };\n }\n return { ...testCase, expectedOutcome };\n }\n case 'set-resolution-query': {\n if (target.type !== 'textarea' || target.outcomeMode !== 'dynamic') {\n return testCase;\n }\n expectedOutcome[index] = {\n ...target,\n resolutionQuery: change.value,\n };\n return { ...testCase, expectedOutcome };\n }\n }\n}\n\n/**\n * Updates the evaluation approach for a specific expected outcome field.\n * Select fields always use exact matching.\n */\nexport function updateExpectedOutcomeFieldApproach(\n testCase: TestCase,\n fieldIndex: number,\n approach: EvaluationApproach,\n): TestCase {\n const expectedOutcome = [...(testCase.expectedOutcome || [])];\n const target = expectedOutcome[fieldIndex];\n\n if (!target) {\n return testCase;\n }\n\n const currentEvaluationParameters = target.evaluationParameters;\n expectedOutcome[fieldIndex] = {\n ...target,\n evaluationParameters: normalizeEvaluationParametersForField(target.type, {\n ...currentEvaluationParameters,\n approach,\n }),\n };\n\n return {\n ...testCase,\n expectedOutcome,\n };\n}\n"]}
|
|
@@ -6,6 +6,7 @@ const optionalPositiveInt = z.number().int().positive().optional();
|
|
|
6
6
|
const optionalString = z.string().optional();
|
|
7
7
|
const selectOptionsSchema = z.array(nonEmptyString).min(1);
|
|
8
8
|
const optionalNumber = z.number().optional();
|
|
9
|
+
export const expectedOutcomeModeSchema = z.enum(['static', 'dynamic']);
|
|
9
10
|
const evaluationParametersSchema = z.object({
|
|
10
11
|
approach: z.enum(EvaluationApproach),
|
|
11
12
|
threshold: optionalNumber,
|
|
@@ -68,8 +69,21 @@ export const expectedOutcomeFieldSchema = z.discriminatedUnion('type', [
|
|
|
68
69
|
defaultFieldDefinitions.text.extend({
|
|
69
70
|
value: z.string(),
|
|
70
71
|
}),
|
|
71
|
-
defaultFieldDefinitions.textarea
|
|
72
|
+
defaultFieldDefinitions.textarea
|
|
73
|
+
.extend({
|
|
72
74
|
value: z.string(),
|
|
75
|
+
outcomeMode: expectedOutcomeModeSchema.default('static'),
|
|
76
|
+
resolutionQuery: z.string().optional(),
|
|
77
|
+
})
|
|
78
|
+
.superRefine((field, ctx) => {
|
|
79
|
+
if (field.outcomeMode === 'dynamic' &&
|
|
80
|
+
(!field.resolutionQuery || field.resolutionQuery.trim().length === 0)) {
|
|
81
|
+
ctx.addIssue({
|
|
82
|
+
code: 'custom',
|
|
83
|
+
path: ['resolutionQuery'],
|
|
84
|
+
message: 'resolutionQuery is required when outcomeMode is dynamic.',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
73
87
|
}),
|
|
74
88
|
defaultFieldDefinitions.chipsInput.extend({
|
|
75
89
|
value: z.array(z.string()).superRefine((values, ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/schemas/expected-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE5F,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAChD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnE,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC7C,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAE7C,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC;IACpC,SAAS,EAAE,cAAc;CAC1B,CAAC,CAAC;AAEH,MAAM,gCAAgC,GAAG,0BAA0B,CAAC,WAAW,CAC7E,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE;IAClB,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,UAAU,CAAC;YAClB,OAAO,EAAE,+BAA+B,kBAAkB,CAAC,KAAK,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,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,OAAO,CAAC;gBACf,OAAO,EAAE,mDAAmD;aAC7D,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AA4CrF,MAAM,UAAU,6BAA6B,CAC3C,MAAe;IAEf,MAAM,MAAM,GAAG,2BAA2B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,kCAAkC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,eAAwB;IAExB,MAAM,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EvaluationApproach } from '../lib/evaluation/constants';\nimport { isApproachAllowedForFieldType } from '../lib/evaluation/field-evaluation-approach';\n\nconst nonEmptyString = z.string().trim().min(1);\nconst optionalPositiveInt = z.number().int().positive().optional();\nconst optionalString = z.string().optional();\nconst selectOptionsSchema = z.array(nonEmptyString).min(1);\nconst optionalNumber = z.number().optional();\n\nconst evaluationParametersSchema = z.object({\n approach: z.enum(EvaluationApproach),\n threshold: optionalNumber,\n});\n\nconst selectEvaluationParametersSchema = evaluationParametersSchema.superRefine(\n (parameters, ctx) => {\n if (!isApproachAllowedForFieldType('select', parameters.approach)) {\n ctx.addIssue({\n code: 'custom',\n path: ['approach'],\n message: `select fields only support \"${EvaluationApproach.EXACT}\" evaluation approach.`,\n });\n }\n },\n);\n\nconst defaultExpectedOutcomeBaseSchema = z.object({\n label: nonEmptyString,\n placeholder: optionalString,\n});\n\nconst createDefaultExpectedOutcomeFieldSchemas = (\n baseSchema: typeof defaultExpectedOutcomeBaseSchema,\n) => ({\n text: baseSchema.extend({\n type: z.literal('text'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n textarea: baseSchema.extend({\n type: z.literal('textarea'),\n rows: optionalPositiveInt,\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n chipsInput: baseSchema.extend({\n type: z.literal('chips-input'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n select: baseSchema.extend({\n type: z.literal('select'),\n options: selectOptionsSchema,\n evaluationParameters: selectEvaluationParametersSchema.optional(),\n }),\n});\n\nfunction hasDuplicateChips(values: string[]): boolean {\n const seen = new Set<string>();\n for (const value of values) {\n const normalized = value.trim().toLowerCase();\n if (seen.has(normalized)) {\n return true;\n }\n seen.add(normalized);\n }\n return false;\n}\n\nconst defaultFieldDefinitions =\n createDefaultExpectedOutcomeFieldSchemas(defaultExpectedOutcomeBaseSchema);\n\nexport const expectedOutcomeSchemaFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text,\n defaultFieldDefinitions.textarea,\n defaultFieldDefinitions.chipsInput,\n defaultFieldDefinitions.select,\n]);\n\nexport const expectedOutcomeSchemaSchema = z\n .array(expectedOutcomeSchemaFieldSchema)\n .min(1);\n\nexport const expectedOutcomeFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text.extend({\n value: z.string(),\n }),\n defaultFieldDefinitions.textarea.extend({\n value: z.string(),\n }),\n defaultFieldDefinitions.chipsInput.extend({\n value: z.array(z.string()).superRefine((values, ctx) => {\n if (hasDuplicateChips(values)) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'chips-input values must be unique (case-insensitive, trimmed).',\n });\n }\n }),\n }),\n defaultFieldDefinitions.select\n .extend({\n value: z.string(),\n })\n .superRefine((field, ctx) => {\n if (!field.options.includes(field.value)) {\n ctx.addIssue({\n code: 'custom',\n path: ['value'],\n message: 'select value must be one of the provided options.',\n });\n }\n }),\n]);\n\nexport const expectedOutcomeArraySchema = z.array(expectedOutcomeFieldSchema).min(1);\n\nexport type ExpectedOutcomeSchemaField = z.infer<\n typeof expectedOutcomeSchemaFieldSchema\n>;\nexport type ExpectedOutcomeSchema = z.infer<typeof expectedOutcomeSchemaSchema>;\nexport type ExpectedOutcomeField = z.infer<typeof expectedOutcomeFieldSchema>;\nexport type ExpectedOutcomeFieldType = ExpectedOutcomeField['type'];\nexport type ExpectedOutcomeBase = z.infer<typeof defaultExpectedOutcomeBaseSchema>;\n\nexport type TextExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'select' }\n>;\n\nexport type TextExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'select' }\n>;\n\nexport function validateExpectedOutcomeSchema(\n schema: unknown,\n): asserts schema is ExpectedOutcomeSchema {\n const parsed = expectedOutcomeSchemaSchema.safeParse(schema);\n if (!parsed.success) {\n throw new Error(\n `Invalid expectedOutcomeSchema: ${parsed.error.issues[0].message}`,\n );\n }\n}\n\nexport function validateExpectedOutcomeArray(\n expectedOutcome: unknown,\n): asserts expectedOutcome is ExpectedOutcomeField[] {\n const parsed = expectedOutcomeArraySchema.safeParse(expectedOutcome);\n if (!parsed.success) {\n throw new Error(`Invalid expectedOutcome: ${parsed.error.issues[0].message}`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/schemas/expected-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE5F,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAChD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnE,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC7C,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAE7C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAGvE,MAAM,0BAA0B,GAAG,CAAC,CAAC,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ACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AA4CrF,MAAM,UAAU,6BAA6B,CAC3C,MAAe;IAEf,MAAM,MAAM,GAAG,2BAA2B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,kCAAkC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,eAAwB;IAExB,MAAM,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EvaluationApproach } from '../lib/evaluation/constants';\nimport { isApproachAllowedForFieldType } from '../lib/evaluation/field-evaluation-approach';\n\nconst nonEmptyString = z.string().trim().min(1);\nconst optionalPositiveInt = z.number().int().positive().optional();\nconst optionalString = z.string().optional();\nconst selectOptionsSchema = z.array(nonEmptyString).min(1);\nconst optionalNumber = z.number().optional();\n\nexport const expectedOutcomeModeSchema = z.enum(['static', 'dynamic']);\nexport type ExpectedOutcomeMode = z.infer<typeof expectedOutcomeModeSchema>;\n\nconst evaluationParametersSchema = z.object({\n approach: z.enum(EvaluationApproach),\n threshold: optionalNumber,\n});\n\nconst selectEvaluationParametersSchema = evaluationParametersSchema.superRefine(\n (parameters, ctx) => {\n if (!isApproachAllowedForFieldType('select', parameters.approach)) {\n ctx.addIssue({\n code: 'custom',\n path: ['approach'],\n message: `select fields only support \"${EvaluationApproach.EXACT}\" evaluation approach.`,\n });\n }\n },\n);\n\nconst defaultExpectedOutcomeBaseSchema = z.object({\n label: nonEmptyString,\n placeholder: optionalString,\n});\n\nconst createDefaultExpectedOutcomeFieldSchemas = (\n baseSchema: typeof defaultExpectedOutcomeBaseSchema,\n) => ({\n text: baseSchema.extend({\n type: z.literal('text'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n textarea: baseSchema.extend({\n type: z.literal('textarea'),\n rows: optionalPositiveInt,\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n chipsInput: baseSchema.extend({\n type: z.literal('chips-input'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n select: baseSchema.extend({\n type: z.literal('select'),\n options: selectOptionsSchema,\n evaluationParameters: selectEvaluationParametersSchema.optional(),\n }),\n});\n\nfunction hasDuplicateChips(values: string[]): boolean {\n const seen = new Set<string>();\n for (const value of values) {\n const normalized = value.trim().toLowerCase();\n if (seen.has(normalized)) {\n return true;\n }\n seen.add(normalized);\n }\n return false;\n}\n\nconst defaultFieldDefinitions =\n createDefaultExpectedOutcomeFieldSchemas(defaultExpectedOutcomeBaseSchema);\n\nexport const expectedOutcomeSchemaFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text,\n defaultFieldDefinitions.textarea,\n defaultFieldDefinitions.chipsInput,\n defaultFieldDefinitions.select,\n]);\n\nexport const expectedOutcomeSchemaSchema = z\n .array(expectedOutcomeSchemaFieldSchema)\n .min(1);\n\nexport const expectedOutcomeFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text.extend({\n value: z.string(),\n }),\n defaultFieldDefinitions.textarea\n .extend({\n value: z.string(),\n outcomeMode: expectedOutcomeModeSchema.default('static'),\n resolutionQuery: z.string().optional(),\n })\n .superRefine((field, ctx) => {\n if (\n field.outcomeMode === 'dynamic' &&\n (!field.resolutionQuery || field.resolutionQuery.trim().length === 0)\n ) {\n ctx.addIssue({\n code: 'custom',\n path: ['resolutionQuery'],\n message: 'resolutionQuery is required when outcomeMode is dynamic.',\n });\n }\n }),\n defaultFieldDefinitions.chipsInput.extend({\n value: z.array(z.string()).superRefine((values, ctx) => {\n if (hasDuplicateChips(values)) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'chips-input values must be unique (case-insensitive, trimmed).',\n });\n }\n }),\n }),\n defaultFieldDefinitions.select\n .extend({\n value: z.string(),\n })\n .superRefine((field, ctx) => {\n if (!field.options.includes(field.value)) {\n ctx.addIssue({\n code: 'custom',\n path: ['value'],\n message: 'select value must be one of the provided options.',\n });\n }\n }),\n]);\n\nexport const expectedOutcomeArraySchema = z.array(expectedOutcomeFieldSchema).min(1);\n\nexport type ExpectedOutcomeSchemaField = z.infer<\n typeof expectedOutcomeSchemaFieldSchema\n>;\nexport type ExpectedOutcomeSchema = z.infer<typeof expectedOutcomeSchemaSchema>;\nexport type ExpectedOutcomeField = z.input<typeof expectedOutcomeFieldSchema>;\nexport type ExpectedOutcomeFieldType = ExpectedOutcomeField['type'];\nexport type ExpectedOutcomeBase = z.infer<typeof defaultExpectedOutcomeBaseSchema>;\n\nexport type TextExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'select' }\n>;\n\nexport type TextExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'select' }\n>;\n\nexport function validateExpectedOutcomeSchema(\n schema: unknown,\n): asserts schema is ExpectedOutcomeSchema {\n const parsed = expectedOutcomeSchemaSchema.safeParse(schema);\n if (!parsed.success) {\n throw new Error(\n `Invalid expectedOutcomeSchema: ${parsed.error.issues[0].message}`,\n );\n }\n}\n\nexport function validateExpectedOutcomeArray(\n expectedOutcome: unknown,\n): asserts expectedOutcome is ExpectedOutcomeField[] {\n const parsed = expectedOutcomeArraySchema.safeParse(expectedOutcome);\n if (!parsed.success) {\n throw new Error(`Invalid expectedOutcome: ${parsed.error.issues[0].message}`);\n }\n}\n"]}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { expectedOutcomeArraySchema } from "./expected-outcome";
|
|
3
|
+
export const testCaseChatHistorySchema = z.object({
|
|
4
|
+
enabled: z.boolean(),
|
|
5
|
+
value: z.string(),
|
|
6
|
+
});
|
|
3
7
|
export const testCaseInputSchema = z.object({
|
|
4
8
|
id: z.string(),
|
|
5
9
|
question: z.string(),
|
|
6
10
|
expectedOutcome: expectedOutcomeArraySchema,
|
|
11
|
+
chatHistory: testCaseChatHistorySchema.optional(),
|
|
7
12
|
});
|
|
8
13
|
export const testCaseInputArraySchema = z.array(testCaseInputSchema);
|
|
9
14
|
export const testCaseSchema = z.object({
|
|
10
15
|
id: z.string(),
|
|
11
16
|
question: z.string(),
|
|
12
17
|
expectedOutcome: expectedOutcomeArraySchema,
|
|
18
|
+
chatHistory: testCaseChatHistorySchema,
|
|
13
19
|
output: z.string().optional(),
|
|
14
20
|
isRunning: z.boolean().optional(),
|
|
15
21
|
error: z.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-case.js","sourceRoot":"","sources":["../../src/schemas/test-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,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AAC,QAAQ,EAAE;IAC5B,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAoB,CAAC,QAAQ,EAAE;IACzD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAMH,MAAM,UAAU,qBAAqB,CACnC,IAAa;IAEb,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,IAAa;IAEb,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,OAAO,GACX,UAAU,CAAC,IAAI,KAAK,cAAc;YAChC,CAAC,CAAC,gDAAgD;YAClD,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport type { EvaluationResult } from '../lib/evaluation/types';\nimport { expectedOutcomeArraySchema } from './expected-outcome';\n\nexport const testCaseChatHistorySchema = z.object({\n enabled: z.boolean(),\n value: z.string(),\n});\n\nexport const testCaseInputSchema = z.object({\n id: z.string(),\n question: z.string(),\n expectedOutcome: expectedOutcomeArraySchema,\n chatHistory: testCaseChatHistorySchema.optional(),\n});\n\nexport const testCaseInputArraySchema = z.array(testCaseInputSchema);\n\nexport const testCaseSchema = z.object({\n id: z.string(),\n question: z.string(),\n expectedOutcome: expectedOutcomeArraySchema,\n chatHistory: testCaseChatHistorySchema,\n output: z.string().optional(),\n isRunning: z.boolean().optional(),\n error: z.string().optional(),\n evaluationResult: z.custom<EvaluationResult>().optional(),\n responseTime: z.number().optional(),\n});\n\nexport type TestCaseChatHistory = z.infer<typeof testCaseChatHistorySchema>;\nexport type TestCaseInput = z.input<typeof testCaseInputSchema>;\nexport type TestCase = z.input<typeof testCaseSchema>;\n\nexport function validateTestCaseInput(\n data: unknown,\n): asserts data is TestCaseInput {\n const parsed = testCaseInputSchema.safeParse(data);\n if (!parsed.success) {\n throw new Error(`Invalid test case input: ${parsed.error.issues[0].message}`);\n }\n}\n\nexport function validateTestCaseInputArray(\n data: unknown,\n): asserts data is TestCaseInput[] {\n const parsed = testCaseInputArraySchema.safeParse(data);\n if (!parsed.success) {\n const firstIssue = parsed.error.issues[0];\n const message =\n firstIssue.code === 'invalid_type'\n ? 'Invalid JSON structure. Expected a JSON array.'\n : firstIssue.message;\n throw new Error(message);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/types/expected-outcome.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeSchema,\n ExpectedOutcomeField,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from '../schemas/expected-outcome';\n"]}
|
|
1
|
+
{"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/types/expected-outcome.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n ExpectedOutcomeMode,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeSchema,\n ExpectedOutcomeField,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from '../schemas/expected-outcome';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-test-runner.js","sourceRoot":"","sources":["../../src/types/llm-test-runner.ts"],"names":[],"mappings":"","sourcesContent":["import type { TestCase } from './test-case';\n\nexport type {\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n ExpectedOutcomeSchema,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeField,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from './expected-outcome';\nexport type {\n TestCase,\n TestCaseInput,\n} from './test-case';\n\nexport interface LLMRequestPayload {\n prompt: string;\n resolve: (result: string) => void;\n reject: (err: Error | unknown) => void;\n}\n\nexport interface SavePayload {\n timestamp: string;\n testCases: TestCase[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"llm-test-runner.js","sourceRoot":"","sources":["../../src/types/llm-test-runner.ts"],"names":[],"mappings":"","sourcesContent":["import type { TestCase } from './test-case';\n\nexport type {\n ExpectedOutcomeMode,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n ExpectedOutcomeSchema,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeField,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from './expected-outcome';\nexport type {\n TestCaseChatHistory,\n TestCase,\n TestCaseInput,\n} from './test-case';\n\nexport interface LLMRequestPayload {\n prompt: string;\n chatHistory?: string;\n resolve: (result: string) => void;\n reject: (err: Error | unknown) => void;\n}\n\nexport interface SavePayload {\n timestamp: string;\n testCases: TestCase[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-case.js","sourceRoot":"","sources":["../../src/types/test-case.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n TestCaseInput,\n TestCase,\n} from '../schemas/test-case';\n"]}
|
|
1
|
+
{"version":3,"file":"test-case.js","sourceRoot":"","sources":["../../src/types/test-case.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n TestCaseChatHistory,\n TestCaseInput,\n TestCase,\n} from '../schemas/test-case';\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as s,d as o}from"./p-eN2dLrsr.js";const r=s;const t=o;export{r as AppChips,t as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=app-chips.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as o,d as s}from"./p-
|
|
1
|
+
import{A as o,d as s}from"./p-D4dHUFN9.js";const t=o;const p=s;export{t as AppSelect,p as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=app-select.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as o,d as s}from"./p-
|
|
1
|
+
import{A as o,d as s}from"./p-D2qDAxFN.js";const t=o;const p=s;export{t as AppTextarea,p as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=app-textarea.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ChatHistory extends Components.ChatHistory, HTMLElement {}
|
|
4
|
+
export const ChatHistory: {
|
|
5
|
+
prototype: ChatHistory;
|
|
6
|
+
new (): ChatHistory;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":[],"mappings":"","ignoreList":[]}
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{G as t}from"./p-D9BrlHdP.js";export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-D9BrlHdP.js";export{L as LLMTestRunner}from"./p-
|
|
1
|
+
import{G as t}from"./p-D9BrlHdP.js";export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-D9BrlHdP.js";export{L as LLMTestRunner}from"./p-B87Lt3z4.js";class e{sdk;constructor(s){this.sdk=new t({apiKey:s})}async invoke(s){const t=await this.sdk.models.generateContent({model:"gemini-3-flash-preview",contents:s});return t.text}}function n(){window.env={API_KEY:""};window.GeminiAdapter=e}const o=n||(()=>{});const i=o;i();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{L as
|
|
1
|
+
import{L as o,d as s}from"./p-B87Lt3z4.js";const t=o;const p=s;export{t as LlmTestRunner,p as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=llm-test-runner.js.map
|