llm-testrunner-components 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/cjs/index.cjs.js +12 -7
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/cjs/llm-testrunner.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.js +2 -2
  6. package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.js.map +1 -1
  7. package/dist/collection/components/llm-test-runner/llm-test-runner.js +54 -1
  8. package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
  9. package/dist/collection/lib/evaluation/evaluators/semantic/SemanticEvaluator.js +4 -3
  10. package/dist/collection/lib/evaluation/evaluators/semantic/SemanticEvaluator.js.map +1 -1
  11. package/dist/collection/lib/test-cases/test-case-factory.js +1 -1
  12. package/dist/collection/lib/test-cases/test-case-factory.js.map +1 -1
  13. package/dist/components/index.js +1 -1
  14. package/dist/components/llm-test-runner.js +1 -1
  15. package/dist/components/{p-Bb89MYYu.js → p-CJBscebi.js} +3 -3
  16. package/dist/components/p-CJBscebi.js.map +1 -0
  17. package/dist/esm/index.js +12 -7
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/llm-testrunner.js +1 -1
  20. package/dist/esm/loader.js +1 -1
  21. package/dist/llm-testrunner/index.esm.js +2 -2
  22. package/dist/llm-testrunner/index.esm.js.map +1 -1
  23. package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
  24. package/dist/types/components/llm-test-runner/header/llm-test-runner-header.d.ts +1 -0
  25. package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +2 -0
  26. package/dist/types/components.d.ts +12 -0
  27. package/package.json +5 -1
  28. package/dist/components/p-Bb89MYYu.js.map +0 -1
package/dist/esm/index.js CHANGED
@@ -335,7 +335,7 @@ function createExpectedOutcomeFieldFromSchema(schemaField) {
335
335
  type: 'select',
336
336
  label: schemaField.label,
337
337
  placeholder: schemaField.placeholder,
338
- value: '',
338
+ value: schemaField.options[0],
339
339
  options: schemaField.options,
340
340
  evaluationParameters: normalizeEvaluationParametersForField(schemaField.type, schemaField.evaluationParameters),
341
341
  };
@@ -29616,6 +29616,7 @@ class SemanticEvaluator {
29616
29616
  }
29617
29617
  }
29618
29618
  async performEvaluation(request) {
29619
+ const threshold = request.evaluationParameters?.threshold ?? DEFAULT_SEMANTIC_PASS_SCORE;
29619
29620
  try {
29620
29621
  await this.initialize();
29621
29622
  // Split expectedOutcome by newlines to create keywords array
@@ -29625,7 +29626,7 @@ class SemanticEvaluator {
29625
29626
  .map(k => k.trim())
29626
29627
  .filter(k => k.length > 0)
29627
29628
  : [];
29628
- const keywordMatches = await evaluateKeywordsSemantically(SemanticEvaluator.extractor, request.actualResponse, expectedKeywords, DEFAULT_SEMANTIC_PASS_SCORE);
29629
+ const keywordMatches = await evaluateKeywordsSemantically(SemanticEvaluator.extractor, request.actualResponse, expectedKeywords, threshold);
29629
29630
  const totalItems = keywordMatches.length;
29630
29631
  // calculate the overall score by averaging the score of the keyword matches
29631
29632
  const keywordScore = keywordMatches.reduce((acc, curr) => acc + curr.evaluationApproachResult.score, 0);
@@ -29633,7 +29634,7 @@ class SemanticEvaluator {
29633
29634
  const passed = keywordMatches.every(match => match.found);
29634
29635
  const evaluationParameters = {
29635
29636
  approach: EvaluationApproach.SEMANTIC,
29636
- threshold: DEFAULT_SEMANTIC_PASS_SCORE,
29637
+ threshold,
29637
29638
  };
29638
29639
  return {
29639
29640
  testCaseId: request.testCaseId,
@@ -29655,7 +29656,7 @@ class SemanticEvaluator {
29655
29656
  keywordMatches: [],
29656
29657
  evaluationParameters: {
29657
29658
  approach: EvaluationApproach.SEMANTIC,
29658
- threshold: DEFAULT_SEMANTIC_PASS_SCORE,
29659
+ threshold,
29659
29660
  },
29660
29661
  evaluationApproachResult: {
29661
29662
  score: 0,
@@ -30060,7 +30061,7 @@ const Button = (props, children) => {
30060
30061
  return (h("button", { type: type, class: classes, disabled: disabled || loading, onClick: onClick, "aria-busy": loading, "aria-label": ariaLabel }, icon && h("span", { class: "icon" }, icon), children));
30061
30062
  };
30062
30063
 
30063
- const LLMTestRunnerHeader = ({ isExportingTestSuite, isExportingTestResults, isRunningAll, useSave = false, isSaving = false, onImport, onExportSuite, onExportResults, onRunAll, onSave, }) => {
30064
+ const LLMTestRunnerHeader = ({ isExportingTestSuite, isExportingTestResults, isRunningAll, useSave = false, isSaving = false, usePromptEditor = false, onImport, onExportSuite, onExportResults, onRunAll, onSave, }) => {
30064
30065
  let fileInputRef;
30065
30066
  const handleFileSelect = () => {
30066
30067
  fileInputRef?.click();
@@ -30073,7 +30074,7 @@ const LLMTestRunnerHeader = ({ isExportingTestSuite, isExportingTestResults, isR
30073
30074
  onImport(file);
30074
30075
  }
30075
30076
  };
30076
- return (h("header", { class: "test-runner-header" }, h("div", { class: "test-runner-header__left" }, h("input", { class: "test-runner-header--hidden", type: "file", ref: el => (fileInputRef = el), onChange: handleFileChange, accept: ".json,application/json" }), h(Button, { variant: "secondary", size: "md", onClick: handleFileSelect, icon: "\u2191" }, "Import Test Suite"), h(Button, { variant: "secondary", size: "md", onClick: onExportSuite, disabled: isExportingTestSuite, loading: isExportingTestSuite, icon: isExportingTestSuite ? '⏳' : '↓' }, isExportingTestSuite ? 'Exporting...' : 'Export Test Suite')), h("div", { class: "test-runner-header__right" }, h(Button, { variant: "secondary", size: "md", icon: "\u2699\uFE0F" }, "Prompt Editor"), h(Button, { variant: "secondary", size: "md", onClick: onExportResults, disabled: isExportingTestResults, loading: isExportingTestResults, icon: isExportingTestResults ? '⏳' : '↓' }, isExportingTestResults ? 'Exporting...' : 'Export Test Results'), useSave && (h(Button, { variant: "secondary", size: "md", onClick: onSave, disabled: isSaving, loading: isSaving, icon: isSaving ? '⏳' : '💾' }, isSaving ? 'Saving...' : 'Save')), h(Button, { "aria-label": "Run All", variant: "primary", size: "md", onClick: onRunAll, disabled: isRunningAll, loading: isRunningAll }, isRunningAll ? 'Running...' : 'Run All'))));
30077
+ return (h("header", { class: "test-runner-header" }, h("div", { class: "test-runner-header__left" }, h("input", { class: "test-runner-header--hidden", type: "file", ref: el => (fileInputRef = el), onChange: handleFileChange, accept: ".json,application/json" }), h(Button, { variant: "secondary", size: "md", onClick: handleFileSelect, icon: "\u2191" }, "Import Test Suite"), h(Button, { variant: "secondary", size: "md", onClick: onExportSuite, disabled: isExportingTestSuite, loading: isExportingTestSuite, icon: isExportingTestSuite ? '⏳' : '↓' }, isExportingTestSuite ? 'Exporting...' : 'Export Test Suite')), h("div", { class: "test-runner-header__right" }, usePromptEditor && (h(Button, { variant: "secondary", size: "md", icon: "\u2699\uFE0F" }, "Prompt Editor")), h(Button, { variant: "secondary", size: "md", onClick: onExportResults, disabled: isExportingTestResults, loading: isExportingTestResults, icon: isExportingTestResults ? '⏳' : '↓' }, isExportingTestResults ? 'Exporting...' : 'Export Test Results'), useSave && (h(Button, { variant: "secondary", size: "md", onClick: onSave, disabled: isSaving, loading: isSaving, icon: isSaving ? '⏳' : '💾' }, isSaving ? 'Saving...' : 'Save')), h(Button, { "aria-label": "Run All", variant: "primary", size: "md", onClick: onRunAll, disabled: isRunningAll, loading: isRunningAll }, isRunningAll ? 'Running...' : 'Run All'))));
30077
30078
  };
30078
30079
 
30079
30080
  const ResponseOutput = ({ output, isRunning, }) => {
@@ -30254,6 +30255,7 @@ const LLMTestRunner = class {
30254
30255
  save;
30255
30256
  delayMs = 500;
30256
30257
  useSave = false;
30258
+ usePromptEditor = false;
30257
30259
  initialTestCases;
30258
30260
  defaultExpectedOutcomeSchema;
30259
30261
  testCases = [
@@ -30317,6 +30319,9 @@ const LLMTestRunner = class {
30317
30319
  async resetSavingState() {
30318
30320
  this.isSaving = false;
30319
30321
  }
30322
+ async getTestCases() {
30323
+ return this.testCases;
30324
+ }
30320
30325
  handleTestCaseChange = (event) => {
30321
30326
  const { testCaseId, key, value } = event.detail;
30322
30327
  this.testCases = this.testCases.map(tc => tc.id === testCaseId ? { ...tc, [key]: value } : tc);
@@ -30479,7 +30484,7 @@ const LLMTestRunner = class {
30479
30484
  }
30480
30485
  }
30481
30486
  render() {
30482
- return (h("div", { key: 'e3d007b453f770fcb59c29f8ee83bd8a35e82a34', class: "test-runner-container" }, h(LLMTestRunnerHeader, { key: 'b7c44bf4807fe8d9e5de514818420d67d2e0dbfb', isExportingTestSuite: this.isExportingTestSuite, isExportingTestResults: this.isExportingTestResults, isRunningAll: this.isRunningAll, useSave: this.useSave, isSaving: this.isSaving, onImport: file => this.handleImport(file), onExportSuite: () => this.handleExportTestSuite(), onExportResults: () => this.handleExportTestResults(), onRunAll: () => this.runAllTests(), onSave: () => this.handleSave() }), h(ErrorMessage, { key: '697237ec0f8d2e704609fd0b240629f22c2a3ef6', message: this.error, onClear: () => (this.error = '') }), h("div", { key: '64a623f897dfb96d922ddc0cbdfcf529c52bef76', class: "test-runner-container__content" }, h(LLMTestCases, { key: '017da41567c5c13933d9cf31d1a972743bd9b100', testCases: this.testCases, onRun: testCase => this.runSingleTest(testCase).catch(() => { }), onDelete: id => this.deleteTestCase(id), onAddTestCase: () => this.addNewTestCase(), handleTestCaseChange: this.handleTestCaseChange, onExpectedOutcomeChange: this.handleExpectedOutcomeChange }))));
30487
+ return (h("div", { key: '29cf8a93402ebad6f6df43e147fa10406577c9aa', class: "test-runner-container" }, h(LLMTestRunnerHeader, { key: 'a07d3d1d823f8d473808752932cd1b2ab72d9e08', isExportingTestSuite: this.isExportingTestSuite, isExportingTestResults: this.isExportingTestResults, isRunningAll: this.isRunningAll, useSave: this.useSave, isSaving: this.isSaving, usePromptEditor: this.usePromptEditor, onImport: file => this.handleImport(file), onExportSuite: () => this.handleExportTestSuite(), onExportResults: () => this.handleExportTestResults(), onRunAll: () => this.runAllTests(), onSave: () => this.handleSave() }), h(ErrorMessage, { key: 'ec68912728b06fc4a76c330fb1b7d5acde92c3d1', message: this.error, onClear: () => (this.error = '') }), h("div", { key: 'ce308dd4bd5437c94ae6e3e8a28970b799865281', class: "test-runner-container__content" }, h(LLMTestCases, { key: '3368df0bb7de4d099da1fad400f59dfc9a2cfb62', testCases: this.testCases, onRun: testCase => this.runSingleTest(testCase).catch(() => { }), onDelete: id => this.deleteTestCase(id), onAddTestCase: () => this.addNewTestCase(), handleTestCaseChange: this.handleTestCaseChange, onExpectedOutcomeChange: this.handleExpectedOutcomeChange }))));
30483
30488
  }
30484
30489
  };
30485
30490
  LLMTestRunner.style = tokensCss() + (llmTestRunnerCss() + (llmTestRunnerHeaderCss() + (llmTestCasesCss() + (llmTestCaseRowCss() + (rowActionsCss() + (evaluationSummaryCss() + (responseOutputCss() + (errorMessageCss() + (buttonCss() + iconButtonCss())))))))));