llm-testrunner-components 1.0.4 → 1.0.6

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 (63) hide show
  1. package/README.md +113 -10
  2. package/dist/cjs/app-globals-CbbEbofA.js +14 -0
  3. package/dist/cjs/app-globals-CbbEbofA.js.map +1 -0
  4. package/dist/cjs/{index-CY2lQip_.js → index-D-FySkoV.js} +25 -5
  5. package/dist/cjs/index-D-FySkoV.js.map +1 -0
  6. package/dist/cjs/index.cjs.js +159 -66
  7. package/dist/cjs/index.cjs.js.map +1 -1
  8. package/dist/cjs/llm-test-runner.cjs.entry.js +1 -1
  9. package/dist/cjs/llm-testrunner.cjs.js +4 -4
  10. package/dist/cjs/llm-testrunner.cjs.js.map +1 -1
  11. package/dist/cjs/loader.cjs.js +3 -3
  12. package/dist/collection/collection-manifest.json +3 -2
  13. package/dist/collection/components/llm-test-runner/llm-test-runner.js +152 -72
  14. package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
  15. package/dist/collection/global/env.js +6 -0
  16. package/dist/collection/global/env.js.map +1 -0
  17. package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js +39 -0
  18. package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js.map +1 -0
  19. package/dist/components/index.js +6 -1650
  20. package/dist/components/index.js.map +1 -1
  21. package/dist/components/llm-test-runner.js +1 -1
  22. package/dist/components/p-CYUbsbxt.js +1770 -0
  23. package/dist/components/p-CYUbsbxt.js.map +1 -0
  24. package/dist/esm/app-globals-BOQOUavG.js +12 -0
  25. package/dist/esm/app-globals-BOQOUavG.js.map +1 -0
  26. package/dist/esm/{index-DBp-rMPb.js → index-cncubhtM.js} +25 -6
  27. package/dist/esm/index-cncubhtM.js.map +1 -0
  28. package/dist/esm/index.js +159 -66
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/llm-test-runner.entry.js +1 -1
  31. package/dist/esm/llm-testrunner.js +5 -5
  32. package/dist/esm/llm-testrunner.js.map +1 -1
  33. package/dist/esm/loader.js +4 -4
  34. package/dist/llm-testrunner/index.esm.js +1 -1
  35. package/dist/llm-testrunner/index.esm.js.map +1 -1
  36. package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
  37. package/dist/llm-testrunner/llm-testrunner.esm.js.map +1 -1
  38. package/dist/llm-testrunner/p-BOQOUavG.js +2 -0
  39. package/dist/llm-testrunner/p-BOQOUavG.js.map +1 -0
  40. package/dist/llm-testrunner/p-cncubhtM.js +3 -0
  41. package/dist/llm-testrunner/p-cncubhtM.js.map +1 -0
  42. package/dist/llm-testrunner/p-f68fd660.entry.js +2 -0
  43. package/dist/react/components.d.ts +6 -3
  44. package/dist/react/components.d.ts.map +1 -1
  45. package/dist/react/components.js +2 -2
  46. package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +13 -4
  47. package/dist/types/components.d.ts +26 -2
  48. package/dist/types/global/env.d.ts +8 -0
  49. package/dist/types/lib/rate-limited-fetcher/rate-limited-fetcher.d.ts +10 -0
  50. package/dist/types/stencil-public-runtime.d.ts +19 -10
  51. package/package.json +6 -4
  52. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -8
  53. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  54. package/dist/cjs/index-CY2lQip_.js.map +0 -1
  55. package/dist/esm/app-globals-DQuL1Twl.js +0 -6
  56. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  57. package/dist/esm/index-DBp-rMPb.js.map +0 -1
  58. package/dist/llm-testrunner/p-DBp-rMPb.js +0 -3
  59. package/dist/llm-testrunner/p-DBp-rMPb.js.map +0 -1
  60. package/dist/llm-testrunner/p-DQuL1Twl.js +0 -2
  61. package/dist/llm-testrunner/p-DQuL1Twl.js.map +0 -1
  62. package/dist/llm-testrunner/p-ed2ea423.entry.js +0 -2
  63. /package/dist/llm-testrunner/{p-ed2ea423.entry.js.map → p-f68fd660.entry.js.map} +0 -0
package/README.md CHANGED
@@ -7,7 +7,7 @@ A Stencil web component library that provides a comprehensive LLM testing soluti
7
7
  The LLM TestRunner is a tool for testing Large Language Model (LLM) responses against expected criteria. It provides a complete interface for:
8
8
 
9
9
  - **Question Management**: Add, edit, and organize test questions
10
- - **AI Integration**: Direct integration with Google's Gemini AI API
10
+ - **AI Integration**: Can be integrated with any LLM provider
11
11
  - **Automated Evaluation**: Built-in evaluation engine that checks responses against expected keywords and source links
12
12
  - **Batch Testing**: Run multiple tests sequentially
13
13
  - **Real-time Results**: Live evaluation results with pass/fail indicators
@@ -19,7 +19,7 @@ The main component that provides a complete LLM testing interface.
19
19
 
20
20
  **Features:**
21
21
  - Question input with expected keywords and source links
22
- - Real-time AI response generation via Gemini API
22
+ - Real-time AI response generation any LLM provider
23
23
  - Test case management (add, delete, run individual or all tests)
24
24
  - Built-in evaluation engine with keyword and source link matching
25
25
  - Error handling and loading states
@@ -27,7 +27,7 @@ The main component that provides a complete LLM testing interface.
27
27
 
28
28
  **Usage:**
29
29
  ```html
30
- <llm-test-runner api-key="your-gemini-api-key-here"></llm-test-runner>
30
+ <llm-test-runner delay-ms="1000"></llm-test-runner>
31
31
  ```
32
32
 
33
33
  ## 🎯 Usage Modes
@@ -42,8 +42,47 @@ Simply include the component in your HTML:
42
42
  <script nomodule src="/build/llm-testrunner.js"></script>
43
43
  </head>
44
44
  <body>
45
- <llm-test-runner api-key="your-gemini-api-key-here"></llm-test-runner>
45
+ <llm-test-runner id="llm-test-runner" delay-ms="1000"></llm-test-runner>
46
46
  </body>
47
+ <script>
48
+ const llmTestRunner = document.getElementById('llm-test-runner');
49
+ // Gemini API
50
+ async function handlellmRequest(event) {
51
+ try {
52
+ const requestBody = {
53
+ contents: [{
54
+ parts: [{
55
+ text: event.detail.prompt
56
+ }]
57
+ }]
58
+ };
59
+
60
+ const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=your-gemini-api-key-here`, {
61
+ method: 'POST',
62
+ headers: {
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ body: JSON.stringify(requestBody)
66
+ });
67
+
68
+ if (!response.ok) {
69
+ const errorData = await response.json().catch(() => ({}));
70
+ throw new Error(errorData.error?.message || `HTTP error! status: ${response.status}`);
71
+ }
72
+
73
+ const data = await response.json();
74
+
75
+ if (data.candidates && data.candidates[0] && data.candidates[0].content) {
76
+ event.detail.resolve(data.candidates[0].content.parts[0].text);
77
+ } else {
78
+ throw new Error('Unexpected response format from Gemini API');
79
+ }
80
+ } catch (err) {
81
+ event.detail.reject(err);
82
+ }
83
+ }
84
+ llmTestRunner.addEventListener('llmRequest', handlellmRequest);
85
+ </script>
47
86
  </html>
48
87
  ```
49
88
 
@@ -54,14 +93,21 @@ import { LLMTestRunner } from 'llm-testrunner-components';
54
93
 
55
94
  // The component is automatically registered and ready to use
56
95
  ```
57
-
58
96
  ## Configuration
59
97
 
60
- ### API Key Prop
61
- The component accepts the Gemini API key as a prop.
98
+ ### 🧠 delayMs Prop — Controlling API Rate Limiting
99
+ The `delayMs` prop allows you to control **how frequently API calls are made** when triggering multiple requests.
100
+ This helps prevent exceeding **API rate limits** by spacing out requests automatically.
101
+
102
+ ### ⚙️ Description
103
+
104
+ | Prop Name | Type | Default | Description |
105
+ |------------|------|----------|--------------|
106
+ | `delayMs` | `number` | `undefined` | Optional delay (in milliseconds) between consecutive API calls. If not provided, all API calls are made in parallel. |
107
+
62
108
 
63
109
  ```html
64
- <llm-test-runner api-key="your-gemini-api-key-here"></llm-test-runner>
110
+ <llm-test-runner delay-ms="2000"></llm-test-runner>
65
111
  ```
66
112
 
67
113
  ### React/JSX Usage
@@ -69,7 +115,7 @@ The component accepts the Gemini API key as a prop.
69
115
  function App() {
70
116
  return (
71
117
  <div>
72
- <llm-test-runner apiKey="your-gemini-api-key-here" />
118
+ <llm-test-runner delayMs="1000" />
73
119
  </div>
74
120
  );
75
121
  }
@@ -91,6 +137,13 @@ The built-in evaluation engine provides:
91
137
 
92
138
  ## Development
93
139
 
140
+ ### 🛠 Prerequisites
141
+
142
+ Before you begin, ensure you have:
143
+
144
+ - **Node.js** (>=16.x recommended)
145
+ - **npm** (>=7.x) or **yarn**
146
+
94
147
  ### Building
95
148
  ```bash
96
149
  npm run build
@@ -106,6 +159,11 @@ npm test
106
159
  npm start
107
160
  ```
108
161
 
162
+ ### Create a new component
163
+ ```bash
164
+ npm run generate
165
+ ```
166
+
109
167
  ### Project Structure
110
168
  ```
111
169
  src/
@@ -139,10 +197,46 @@ function App() {
139
197
  defineCustomElements();
140
198
  }, []);
141
199
 
200
+ const handlellmRequest = (event: CustomEvent<LLMRequestPayload>) => {
201
+ try {
202
+ console.log('🚀 callGeminiAPI called with prompt:', event.detail.prompt);
203
+ const requestBody = {
204
+ contents: [{
205
+ parts: [{
206
+ text: event.detail.prompt
207
+ }]
208
+ }]
209
+ };
210
+
211
+ const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=your-gemini-api-key-here`, {
212
+ method: 'POST',
213
+ headers: {
214
+ 'Content-Type': 'application/json',
215
+ },
216
+ body: JSON.stringify(requestBody)
217
+ });
218
+
219
+ if (!response.ok) {
220
+ const errorData = await response.json().catch(() => ({}));
221
+ throw new Error(errorData.error?.message || `HTTP error! status: ${response.status}`);
222
+ }
223
+
224
+ const data = await response.json();
225
+
226
+ if (data.candidates && data.candidates[0] && data.candidates[0].content) {
227
+ event.detail.resolve(data.candidates[0].content.parts[0].text);
228
+ } else {
229
+ throw new Error('Unexpected response format from Gemini API');
230
+ }
231
+ } catch (err) {
232
+ event.detail.reject(err);
233
+ }
234
+ };
235
+
142
236
  return (
143
237
  <div>
144
238
  <h1>LLM Test Runner</h1>
145
- <llm-test-runner api-key="your-gemini-api-key-here"></llm-test-runner>
239
+ <llm-test-runner llmRequest={handlellmRequest}></llm-test-runner>
146
240
  </div>
147
241
  );
148
242
  }
@@ -191,4 +285,13 @@ interface EvaluationResult {
191
285
  sourceLinkMatches: SourceLinkMatch[];
192
286
  timestamp?: string;
193
287
  }
288
+ ```
289
+
290
+ ### LLMRequestPayload Interface
291
+ ```typescript
292
+ interface LLMRequestPayload {
293
+ prompt: string;
294
+ resolve: (result: string) => void;
295
+ reject: (err: any) => void;
296
+ }
194
297
  ```
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ function appGlobalScript () {
4
+ window.env = {
5
+ API_KEY: ''
6
+ };
7
+ }
8
+
9
+ const globalScripts = appGlobalScript;
10
+
11
+ exports.globalScripts = globalScripts;
12
+ //# sourceMappingURL=app-globals-CbbEbofA.js.map
13
+
14
+ //# sourceMappingURL=app-globals-CbbEbofA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-globals-CbbEbofA.js","sources":["src/global/env.ts","@stencil/core/internal/app-globals"],"sourcesContent":["declare global {\n interface Window {\n env: {\n API_KEY: string;\n };\n }\n}\n\nexport default function () {\n window.env = {\n API_KEY: '__GEMINI_API_KEY__'\n };\n}","import appGlobalScript from '/Users/akhilan/Documents/work/llm-testrunner/packages/stencil-library/src/global/env.ts';\nexport const globalScripts = appGlobalScript;\nexport const globalStyles = \"\";\n"],"names":[],"mappings":";;AAQc,wBAAA,IAAA;IACZ,MAAM,CAAC,GAAG,GAAG;AACX,QAAA,OAAO,EAAE;KACV;AACH;;ACXY,MAAC,aAAa,GAAG;;;;"}
@@ -4,7 +4,7 @@ const NAMESPACE = 'llm-testrunner';
4
4
  const BUILD = /* llm-testrunner */ { hydratedSelectorName: "hydrated", lazyLoad: true, propChangeCallback: false, updatable: true};
5
5
 
6
6
  /*
7
- Stencil Client Platform v4.38.1 | MIT Licensed | https://stenciljs.com
7
+ Stencil Client Platform v4.38.2 | MIT Licensed | https://stenciljs.com
8
8
  */
9
9
  var __defProp = Object.defineProperty;
10
10
  var __export = (target, all) => {
@@ -492,13 +492,32 @@ createSupportsRuleRe(":host");
492
492
  createSupportsRuleRe(":host-context");
493
493
  var parsePropertyValue = (propValue, propType, isFormAssociated) => {
494
494
  if (propValue != null && !isComplexType(propValue)) {
495
- if (propType & 1 /* String */) {
496
- return String(propValue);
495
+ if (propType & 2 /* Number */) {
496
+ return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
497
497
  }
498
498
  return propValue;
499
499
  }
500
500
  return propValue;
501
501
  };
502
+ var getElement = (ref) => {
503
+ var _a;
504
+ return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
505
+ };
506
+
507
+ // src/runtime/event-emitter.ts
508
+ var createEvent = (ref, name, flags) => {
509
+ const elm = getElement(ref);
510
+ return {
511
+ emit: (detail) => {
512
+ return emitEvent(elm, name, {
513
+ bubbles: true,
514
+ composed: true,
515
+ cancelable: true,
516
+ detail
517
+ });
518
+ }
519
+ };
520
+ };
502
521
  var emitEvent = (elm, name, opts) => {
503
522
  const ev = plt.ce(name, opts);
504
523
  elm.dispatchEvent(ev);
@@ -1441,10 +1460,11 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1441
1460
  var setNonce = (nonce) => plt.$nonce$ = nonce;
1442
1461
 
1443
1462
  exports.bootstrapLazy = bootstrapLazy;
1463
+ exports.createEvent = createEvent;
1444
1464
  exports.h = h;
1445
1465
  exports.promiseResolve = promiseResolve;
1446
1466
  exports.registerInstance = registerInstance;
1447
1467
  exports.setNonce = setNonce;
1448
- //# sourceMappingURL=index-CY2lQip_.js.map
1468
+ //# sourceMappingURL=index-D-FySkoV.js.map
1449
1469
 
1450
- //# sourceMappingURL=index-CY2lQip_.js.map
1470
+ //# sourceMappingURL=index-D-FySkoV.js.map