### LintAI Web Dashboard Setup Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Start the LintAI web dashboard development server. Navigate to the frontend directory, install dependencies, and run the development script. ```bash cd frontend npm install npm run dev ``` -------------------------------- ### Install LintAI from PyPI Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Use this command to install the LintAI package from the Python Package Index. This is the recommended installation method. ```bash pip install llm-validator ``` -------------------------------- ### Install LintAI from Source Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Clone the repository and install LintAI locally. This is useful for development or when you need the latest unreleased features. ```bash git clone https://github.com/SoulSniper-V2/lintai.git cd lintai pip install -e . ``` -------------------------------- ### Example Assertions Configuration JSON Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Define validation rules for LLM outputs using a JSON file. Specify assertion types, parameters, and weights for scoring. ```json { "assertions": [ { "name": "max_length", "type": "MAX_LENGTH", "params": { "max_chars": 1000 }, "weight": 0.3 }, { "name": "contains_steps", "type": "CONTAINS_TEXT", "params": { "text": "step 1" }, "weight": 0.5 }, { "name": "no_profanity", "type": "NO_PATTERN", "params": { "pattern": "badword|offensive" }, "weight": 0.2 } ] } ``` -------------------------------- ### Example Customer Email Validator Configuration Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Defines a validator named 'customer_email' using Claude 3 Opus with assertions for professional tone, greeting presence, signature presence, and no PII. ```yaml name: customer_email model: claude-3-opus assertions: - name: professional_tone type: SENTIMENT params: { min_positive: 0.3, max_negative: 0.2 } weight: 0.3 - name: has_greeting type: CONTAINS_TEXT params: { text: "Dear|Hello|Hi" } weight: 0.1 - name: has_signature type: CONTAINS_TEXT params: { text: "Sincerely|Best|Thanks" } weight: 0.1 - name: no_pii type: NO_PATTERN params: { pattern: "\\d{3}-\\d{2}-\\d{4}" } # SSN pattern weight: 0.5 ``` -------------------------------- ### GitHub Actions Workflow for Validation Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md A GitHub Actions workflow that checks out code, sets up Python, installs the validator, runs validation against a config file, and checks the resulting score. ```yaml name: Validate AI Outputs on: [push] jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: { python-version: '3.11' } - name: Install run: pip install llm-validator - name: Run Validation run: | llm-validate \ --config validators/code_review.yaml \ --output validation_results.json - name: Check Score run: | if [ $(jq '.score' validation_results.json) -lt 80 ]; then echo "Score below threshold!" exit 1 fi ``` -------------------------------- ### Example Code Review Validator Configuration Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Defines a validator named 'code_review' using GPT-4 with assertions for test presence, no hardcoded secrets, reasonable length, and error handling. ```yaml name: code_review model: gpt-4 assertions: - name: has_tests type: CONTAINS_TEXT params: { text: "test" } weight: 0.3 - name: no_hardcoded_secrets type: NO_PATTERN params: { pattern: "api_key|password|secret" } weight: 0.4 - name: reasonable_length type: MAX_LENGTH params: { max_tokens: 2000 } weight: 0.2 - name: has_error_handling type: REGEX_MATCH params: { pattern: "except|try|catch" } weight: 0.1 ``` -------------------------------- ### LintAI CLI: Initialize Configuration Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Use the 'lintai init-config' command to generate a default configuration file for validation. ```bash # Initialize a validation config lintai init-config ``` -------------------------------- ### Provider Selection in Python Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Demonstrates how to instantiate the LLMValidator with different LLM providers like OpenAI, Anthropic, or a local model. ```python from llm_validator.providers import OpenAIProvider, AnthropicProvider, LocalProvider # OpenAI validator = LLMValidator(provider=OpenAIProvider(model="gpt-4")) # Anthropic validator = LLMValidator(provider=AnthropicProvider(model="claude-3-opus")) # Local/Ollama validator = LLMValidator(provider=LocalProvider(model="llama2")) ``` -------------------------------- ### Releasing a New Version Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Steps to release a new version of the project, including committing changes, creating a version tag, and pushing the tag. ```bash # Make changes, commit git add -A git commit -m "Description of changes" # Create a version tag (follows semver) git tag v0.1.1 ``` -------------------------------- ### LintAI CLI: Quick Test Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Perform a quick validation using command-line arguments for prompt, output, and rules. Useful for rapid testing. ```bash # Quick test llm-validate --prompt "Summarize this" --output "The text says..." --rules "max_tokens:100" ``` -------------------------------- ### LintAI CLI: Validate with Config File Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Run validations using a specified configuration file with the 'lintai validate' command. ```bash # Validate with a config file lintai validate --config validators/my_config.yaml ``` -------------------------------- ### LintAI CLI: Run Validation from Config Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Execute validation using the 'llm-validate' command with a specified configuration file. ```bash # Run validation from config llm-validate --config validators/sales_plan.yaml ``` -------------------------------- ### Environment Variables for API Keys Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Sets environment variables for API keys required by different LLM providers. ```bash OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=... GOOGLE_API_KEY=... ``` -------------------------------- ### Running Tests with Pytest Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Commands to execute tests using pytest, including running all tests, running with code coverage, and running a specific test file. ```bash # Run all tests pytest tests/ # Run with coverage pytest --cov=llm_validator tests/ # Run specific test pytest tests/test_core.py -v ``` -------------------------------- ### Trigger PyPI Release with Git Tags Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Pushing a tag to the main branch triggers an automated CI workflow for building and publishing the package to PyPI. Ensure the PYPI_API_TOKEN secret is configured in GitHub repository settings. ```bash git push origin main git push origin v0.1.1 ``` -------------------------------- ### Python API: Initialize LLMValidator Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Instantiate the LLMValidator with your chosen model and API key. This object is used to perform validation tasks. ```python from llm_validator import LLMValidator, Assertion, AssertionType # Initialize validator validator = LLMValidator( model="gpt-4", api_key="your-key" ) ``` -------------------------------- ### LintAI CLI: Batch Validation Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Perform batch validation on multiple test cases from a JSONL file and save the results to an output file using 'lintai batch'. ```bash # Batch validation from JSONL lintai batch --input test_cases.jsonl --output results.jsonl ``` -------------------------------- ### LintAI CLI: Batch Validation (llm-validate) Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Conduct batch validation from a JSONL input file and output the results to a JSONL file using the 'llm-validate' command. ```bash # Batch validation llm-validate --input test_cases.jsonl --output results.jsonl ``` -------------------------------- ### LintAI GitHub Action for CI/CD Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Integrate LintAI into your GitHub Actions workflow to automatically validate LLM outputs. Configure prompts, expected outputs, and assertion rules. ```yaml name: Validate AI Output on: [push] jobs: validate: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Validate LLM Output uses: SoulSniper-V2/lintai@v0.1 with: prompt: "Summarize this document" output: "${{ steps.generate.outputs.result }}" assertions-config: "./assertions.json" pass-threshold: 80 ``` -------------------------------- ### Python API: Define Assertions Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Create a list of Assertion objects to define the validation rules. Each assertion includes a name, type, parameters, and weight. ```python # Define assertions assertions = [ Assertion( name="max_length", type=AssertionType.MAX_LENGTH, params={"max_tokens": 500}, weight=0.3 ), Assertion( name="no_profanity", type=AssertionType.NO_PATTERN, params={"pattern": r"(?i)badword|offensive"}, weight=0.5 ), Assertion( name="contains_action_plan", type=AssertionType.CONTAINS_TEXT, params={"text": "step 1", "count": 1}, weight=0.2 ) ] ``` -------------------------------- ### Python API: Validate Output Source: https://github.com/soulsniper-v2/lintai/blob/master/README.md Use the validator.validate() method to check an LLM's output against the defined assertions. It returns a result object with score and pass/fail status. ```python # Validate output result = validator.validate( prompt="Create a plan to increase sales", output="Here is a step by step plan...", assertions=assertions ) print(f"Confidence Score: {result.score}/100") print(f"Passed: {result.passed}") print(f"Failed: {result.failed_assertions}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.