npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

llm-testrunner-components

v1.0.7

Published

A Stencil web component library for LLM test runner functionality

Readme

LLM TestRunner Web Components

A Stencil web component library that provides a comprehensive LLM testing solution with automated evaluation capabilities.

Overview

The LLM TestRunner is a tool for testing Large Language Model (LLM) responses against expected criteria. It provides a complete interface for:

  • Question Management: Add, edit, and organize test questions
  • AI Integration: Can be integrated with any LLM provider
  • Automated Evaluation: Built-in evaluation engine that checks responses against expected keywords and source links
  • Batch Testing: Run multiple tests sequentially
  • Real-time Results: Live evaluation results with pass/fail indicators

Components

<llm-test-runner>

The main component that provides a complete LLM testing interface.

Features:

  • Question input with expected keywords and source links
  • Real-time AI response generation any LLM provider
  • Test case management (add, delete, run individual or all tests)
  • Built-in evaluation engine with keyword and source link matching
  • Error handling and loading states
  • Rate limiting for batch operations

Usage:

<llm-test-runner delay-ms="1000"></llm-test-runner>

🎯 Usage Modes

1. Direct HTML Usage

Simply include the component in your HTML:

<!DOCTYPE html>
<html>
<head>
  <script type="module" src="/build/llm-testrunner.esm.js"></script>
  <script nomodule src="/build/llm-testrunner.js"></script>
</head>
<body>
  <llm-test-runner id="llm-test-runner" delay-ms="1000"></llm-test-runner>
</body>
<script>
    const llmTestRunner = document.getElementById('llm-test-runner');
    // Gemini API
    async function handlellmRequest(event) {
      try {
        const requestBody = {
          contents: [{
            parts: [{
              text: event.detail.prompt
            }]
          }]
        };

        const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=your-gemini-api-key-here`, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(requestBody)
        });

        if (!response.ok) {
          const errorData = await response.json().catch(() => ({}));
          throw new Error(errorData.error?.message || `HTTP error! status: ${response.status}`);
        }

        const data = await response.json();

        if (data.candidates && data.candidates[0] && data.candidates[0].content) {
          event.detail.resolve(data.candidates[0].content.parts[0].text);
        } else {
          throw new Error('Unexpected response format from Gemini API');
        }
      } catch (err) {
        event.detail.reject(err instanceof Error ? err : new Error(String(err)));
      }
    }
    llmTestRunner.addEventListener('llmRequest', handlellmRequest);
  </script>
</html>

2. Library Integration

Import as a module in your application:

import { LLMTestRunner } from 'llm-testrunner-components';

// The component is automatically registered and ready to use

Configuration

🧠 delayMs Prop — Controlling API Rate Limiting

The delayMs prop allows you to control how frequently API calls are made when triggering multiple requests.
This helps prevent exceeding API rate limits by spacing out requests automatically.

⚙️ Description

| Prop Name | Type | Default | Description | |------------|------|----------|--------------| | delayMs | number | undefined | Optional delay (in milliseconds) between consecutive API calls. If not provided, all API calls are made in parallel. |

<llm-test-runner delay-ms="2000"></llm-test-runner>

React/JSX Usage

function App() {
  return (
    <div>
      <llm-test-runner delayMs="1000" />
    </div>
  );
}

Evaluation Engine

The built-in evaluation engine provides:

  • Keyword Matching: Case-insensitive matching of expected keywords in AI responses
  • Source Link Validation: Checks for presence of expected URLs in responses
  • Pass/Fail Logic: Tests pass only when ALL expected items are found
  • Detailed Results: Shows which keywords and links were found/missing

Evaluation Criteria

  • Keywords: Must be present in the AI response (case-insensitive)
  • Source Links: Must be present as exact URL matches
  • Pass Condition: ALL expected keywords AND source links must be found

Using in React Applications

Installation

npm install llm-testrunner-components

Integration

import React, { useEffect } from 'react';
import { defineCustomElements } from 'llm-testrunner-components/loader';

function App() {
  useEffect(() => {
    defineCustomElements();
  }, []);

  const handlellmRequest = (event: CustomEvent<LLMRequestPayload>) => {
    try {
        console.log('🚀 callGeminiAPI called with prompt:', event.detail.prompt);
        const requestBody = {
          contents: [{
            parts: [{
              text: event.detail.prompt
            }]
          }]
        };

        const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=your-gemini-api-key-here`, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(requestBody)
        });

        if (!response.ok) {
          const errorData = await response.json().catch(() => ({}));
          throw new Error(errorData.error?.message || `HTTP error! status: ${response.status}`);
        }

        const data = await response.json();

        if (data.candidates && data.candidates[0] && data.candidates[0].content) {
          event.detail.resolve(data.candidates[0].content.parts[0].text);
        } else {
          throw new Error('Unexpected response format from Gemini API');
        }
      } catch (err) {
        event.detail.reject(err instanceof Error ? err : new Error(String(err)));
      }
  };

  return (
    <div>
      <h1>LLM Test Runner</h1>
      <llm-test-runner llmRequest={handlellmRequest}></llm-test-runner>
    </div>
  );
}

TypeScript Support

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'llm-test-runner': any;
    }
  }
}

API Reference

Component Props

interface LLMTestRunnerProps {
  apiKey: string; // Required: Your Gemini API key
}

TestCase Interface

interface TestCase {
  id: string;
  question: string;
  expectedKeywords: string[];
  expectedSourceLinks: string[];
  output?: string;
  isRunning?: boolean;
  error?: string;
  evaluationResult?: EvaluationResult;
}

EvaluationResult Interface

interface EvaluationResult {
  testCaseId: string;
  passed: boolean;
  keywordMatches: KeywordMatch[];
  sourceLinkMatches: SourceLinkMatch[];
  timestamp?: string;
}

LLMRequestPayload Interface

interface LLMRequestPayload {
  prompt: string;
  resolve: (result: string) => void;
  reject: (err: Error | unknown) => void;
}