Web Frontend
llm-contracts includes a web-based frontend for testing and validating LLM outputs.
Features
- API Key Management: Securely store and test your Gemini API key
- Schema Builder: Create validation schemas using visual builder, AI generation, or YAML editor
- Template Library: Pre-built schemas for common use cases
- LLM Integration: Generate outputs using Gemini API
- Validation: Validate LLM outputs against your schemas using the llm-contracts library
- Reports: Generate HTML and Markdown validation reports
Getting Started
Prerequisites
- A modern web browser (Chrome, Firefox, Edge, Safari)
- Python 3.8+ with pip
- A Gemini API key (get one at https://makersuite.google.com/app/apikey)
Setup
- Install the backend dependencies:
cd frontend pip install -r requirements.txt - Run the backend server:
python server.py - Open
index.htmlin your web browser
Usage Guide
API Configuration
- Enter your Gemini API key in the input field
- Click “Test API Key” to verify it works
- The key is stored in your browser’s local storage for convenience
Creating Schemas
Visual Builder
- Click “Add Field” to add schema fields
- Configure field properties (name, type, constraints)
- Click “Add Rule” to add validation rules
- Configure rule properties
AI Builder
- Describe your validation requirements in natural language
- Click “Generate Schema” to create a schema using AI
- Review and adjust the generated schema as needed
YAML Editor
- Write or paste YAML schema directly
- Changes are automatically parsed and validated
Templates
- Click on a template to load a pre-built schema
- Customize the template as needed
Validation
- Enter a prompt in the “Prompt” field
- Click “Generate & Validate” to generate LLM output and validate it
- View validation results in the “Validation Results” section
- Download HTML or Markdown reports for documentation
Screenshots
(Screenshots will be added here)
Technical Details
The frontend consists of:
- HTML/CSS/JavaScript frontend
- Flask backend that interfaces with the llm-contracts library
- Gemini API integration for LLM generation