Skip to main content

A simple CI/CD utility for running LLM tasks with Semantic Kernel

Project description

AI-First Toolkit: LLM-Powered Automation

PyPI version CI Unit Tests CodeQL

๐Ÿš€ The Future of DevOps is AI-First
This toolkit represents a step toward AI-First DevOps - where intelligent automation handles the entire development lifecycle. Built for teams ready to embrace the exponential productivity gains of AI-powered development. Please read the blog post for more details on the motivation.

TLDR: What This Tool Does

Purpose: Zero-friction LLM integration for pipelines with 100% guaranteed schema compliance. This is your foundation for AI-first integration practices.

Perfect For:

  • ๐Ÿค– AI-Generated Code Reviews: Automated PR analysis with structured findings
  • ๐Ÿ“ Intelligent Documentation: Generate changelogs, release notes, and docs automatically
  • ๐Ÿ” Security Analysis: AI-powered vulnerability detection with structured reports
  • ๐ŸŽฏ Quality Gates: Enforce standards through AI-driven validation
  • ๐Ÿš€ Autonomous Development: Enable AI agents to make decisions in your pipelines
  • ๐ŸŽฏ JIRA Ticket Updates: Update JIRA tickets based on LLM output
  • ๐Ÿ”— Unlimited Integration Possibilities: Chain it multiple times and use as glue code in your tool stack

Simple structured output example

# Install and use immediately
pip install llm-ci-runner
llm-ci-runner --input-file examples/02-devops/pr-description/input.json --schema-file examples/02-devops/pr-description/schema.json

Structured output of the PR review example

The AI-First Development Revolution

This toolkit embodies the principles outlined in Building AI-First DevOps:

Traditional DevOps AI-First DevOps (This Tool)
Manual code reviews ๐Ÿค– AI-powered reviews with structured findings
Human-written documentation ๐Ÿ“ AI-generated docs with guaranteed consistency
Reactive security scanning ๐Ÿ” Proactive AI security analysis
Manual quality gates ๐ŸŽฏ AI-driven validation with schema enforcement
Linear productivity ๐Ÿ“ˆ Exponential gains through intelligent automation

Features

  • ๐ŸŽฏ 100% Schema Enforcement: Your pipeline never gets invalid data. Token-level schema enforcement with guaranteed compliance
  • ๐Ÿ”„ Resilient execution: Retries with exponential back-off and jitter plus a clear exception hierarchy keep transient cloud faults from breaking your CI.
  • ๐Ÿš€ Zero-Friction CLI: Single script, minimal configuration for pipeline integration and automation
  • ๐Ÿ” Enterprise Security: Azure RBAC via DefaultAzureCredential with fallback to API Key
  • ๐Ÿ“ฆ CI-friendly CLI: Stateless command that reads JSON/YAML, writes JSON/YAML, and exits with proper codes
  • ๐ŸŽจ Beautiful Logging: Rich console output with timestamps and colors
  • ๐Ÿ“ File-based I/O: CI/CD friendly with JSON/YAML input/output
  • ๐Ÿ“‹ Template-Driven Workflows: Handlebars and Jinja2 templates with YAML variables for dynamic prompt generation
  • ๐Ÿ“„ YAML Support: Use YAML for schemas, input files, and output files - more readable than JSON
  • ๐Ÿ”ง Simple & Extensible: Easy to understand and modify for your specific needs
  • ๐Ÿค– Semantic Kernel foundation: async, service-oriented design ready for skills, memories, orchestration, and future model upgrades
  • ๐Ÿ“š Documentation: Comprehensive documentation for all features and usage examples. Use your semantic kernel skills to extend the functionality.
  • ๐Ÿง‘โ€โš–๏ธ Acceptance Tests: pytest framework with the LLM-as-Judge pattern for quality gates. Test your scripts before you run them in production.
  • ๐Ÿ’ฐ Coming soon: token usage and cost estimation appended to each result for budgeting and optimisation

Installation

pip install llm-ci-runner

That's it! No complex setup, no dependency management - just install and use. Perfect for CI/CD pipelines and local development.

Quick Start

1. Install from PyPI

pip install llm-ci-runner

2. Set Environment Variables

export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
export AZURE_OPENAI_MODEL="gpt-4.1-nano"  # or any other GPT deployment name
export AZURE_OPENAI_API_VERSION="2024-12-01-preview"  # Optional

Authentication Options:

  • RBAC (Recommended): Uses DefaultAzureCredential for Azure RBAC authentication - no API key needed! See Microsoft Docs for setup.
  • API Key: Set AZURE_OPENAI_API_KEY environment variable if not using RBAC.

3a. Basic Usage

# Simple chat example
llm-ci-runner --input-file examples/01-basic/simple-chat/input.json

# With structured output schema
llm-ci-runner \
  --input-file examples/01-basic/sentiment-analysis/input.json \
  --schema-file examples/01-basic/sentiment-analysis/schema.json

# Custom output file
llm-ci-runner \
  --input-file examples/02-devops/pr-description/input.json \
  --schema-file examples/02-devops/pr-description/schema.json \
  --output-file pr-analysis.json

# YAML input files (alternative to JSON)
llm-ci-runner \
  --input-file config.yaml \
  --schema-file schema.yaml \
  --output-file result.yaml

3b. Template-Based Workflows

Dynamic prompt generation with YAML, Handlebars or Jinja2 templates:

# Handlebars template example
llm-ci-runner \
  --template-file examples/05-templates/handlebars-template/template.hbs \
  --template-vars examples/05-templates/handlebars-template/template-vars.yaml \
  --schema-file examples/05-templates/handlebars-template/schema.yaml \
  --output-file handlebars-result.yaml
  
# Or using Jinja2 templates
llm-ci-runner \
  --template-file examples/05-templates/jinja2-template/template.j2 \
  --template-vars examples/05-templates/jinja2-template/template-vars.yaml \
  --schema-file examples/05-templates/jinja2-template/schema.yaml \
  --output-file jinja2-result.yaml

For more examples see the examples directory.

Benefits of Template Approach:

  • ๐ŸŽฏ Reusable Templates: Create once, use across multiple scenarios
  • ๐Ÿ“ YAML Configuration: More readable than JSON for complex setups
  • ๐Ÿ”„ Dynamic Content: Variables and conditional rendering
  • ๐Ÿš€ CI/CD Ready: Perfect for parameterized pipeline workflows

4. Development Setup (Optional)

For contributors or advanced users who want to modify the source:

# Install UV if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and install for development
git clone https://github.com/Nantero1/ai-first-devops-toolkit.git
cd ai-first-devops-toolkit
uv sync

# Run from source
uv run llm-ci-runner --input-file examples/01-basic/simple-chat/input.json

Real-World Examples

You can explore the examples directory for a complete collection of self-contained examples organized by category.

For comprehensive real-world CI/CD scenarios, see examples/uv-usage-example.md which includes:

  • ๐Ÿ”„ Automated PR Description Updates: Generate comprehensive PR descriptions from commit messages and code changes
  • ๐Ÿ”’ Security Analysis with LLM-as-Judge: Analyze code changes for vulnerabilities with guaranteed schema compliance
  • ๐Ÿ“‹ Automated Changelog Generation: Create structured changelogs from commit history
  • ๐Ÿค– Code Review Automation: Automated reviews with structured findings and quality gates
  • ๐Ÿ”— Multi-Stage AI Pipelines: Chain multiple AI operations for complex workflows

Input Formats

Traditional JSON Input

{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user", 
      "content": "Your task description here"
    }
  ],
  "context": {
    "session_id": "optional-session-id",
    "metadata": {
      "any": "additional context"
    }
  }
}

YAML Input

messages:
  - role: system
    content: "You are a helpful assistant."
  - role: user
    content: "Your task description here"
context:
  session_id: "optional-session-id"
  metadata:
    any: "additional context"

Template-Based Input

Handlebars Template (template.hbs):

<message role="system">
You are an expert {{expertise.domain}} engineer.
Focus on {{expertise.focus_areas}}.
</message>

<message role="user">
Analyze this {{task.type}}:

{{#each task.items}}
- {{this}}
{{/each}}

Requirements: {{task.requirements}}
</message>

Jinja2 Template (template.j2):

<message role="system">
You are an expert {{expertise.domain}} engineer.
Focus on {{expertise.focus_areas}}.
</message>

<message role="user">
Analyze this {{task.type}}:

{% for item in task.items %}
- {{item}}
{% endfor %}

Requirements: {{task.requirements}}
</message>

Template Variables (vars.yaml):

expertise:
  domain: "DevOps"
  focus_areas: "security, performance, maintainability"
task:
  type: "pull request"
  items:
    - "Changed authentication logic"
    - "Updated database queries"
    - "Added input validation"
  requirements: "Focus on security vulnerabilities"

Structured Outputs with 100% Schema Enforcement

When you provide a --schema-file, the runner guarantees perfect schema compliance:

llm-ci-runner \
  --input-file examples/01-basic/sentiment-analysis/input.json \
  --schema-file examples/01-basic/sentiment-analysis/schema.json

Note: Output defaults to result.json. Use --output-file custom-name.json for custom output files.

Supported Schema Features: โœ… String constraints (enum, minLength, maxLength, pattern)
โœ… Numeric constraints (minimum, maximum, multipleOf)
โœ… Array constraints (minItems, maxItems, items type)
โœ… Required fields enforced at generation time
โœ… Type validation (string, number, integer, boolean, array)

CI/CD Integration

GitHub Actions Example

- name: Setup Python
  uses: actions/setup-python@v5
  with:
    python-version: '3.12'

- name: Install LLM CI Runner
  run: pip install llm-ci-runner

- name: Generate PR Review with Templates
  run: |
    llm-ci-runner \
      --template-file .github/templates/pr-review.j2 \
      --template-vars pr-context.yaml \
      --schema-file .github/schemas/pr-review.yaml \
      --output-file pr-analysis.yaml
  env:
    AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
    AZURE_OPENAI_MODEL: ${{ secrets.AZURE_OPENAI_MODEL }}

For complete CI/CD examples, see examples/uv-usage-example.md.

Authentication

Uses Azure's DefaultAzureCredential supporting:

  • Environment variables (local development)
  • Managed Identity (recommended for Azure CI/CD)
  • Azure CLI (local development)
  • Service Principal (non-Azure CI/CD)

Testing

We maintain comprehensive test coverage with 100% success rate:

# For package users - install test dependencies
pip install llm-ci-runner[dev]

# For development - install from source with test dependencies
uv sync --group dev

# Run specific test categories
pytest tests/unit/ -v          # 70 unit tests
pytest tests/integration/ -v   # End-to-end examples
pytest acceptance/ -v          # LLM-as-judge evaluation

# Or with uv for development
uv run pytest tests/unit/ -v
uv run pytest tests/integration/ -v
uv run pytest acceptance/ -v

Architecture

Built on Microsoft Semantic Kernel for:

  • Enterprise-ready Azure OpenAI integration
  • Future-proof model compatibility
  • 100% Schema Enforcement: KernelBaseModel integration with token-level constraints
  • Dynamic Model Creation: Runtime JSON schema โ†’ Pydantic model conversion
  • RBAC: Azure RBAC via DefaultAzureCredential

The AI-First Development Journey

This toolkit is your first step toward AI-First DevOps. As you integrate AI into your development workflows, you'll experience:

  1. ๐Ÿš€ Exponential Productivity: AI handles routine tasks while you focus on architecture
  2. ๐ŸŽฏ Guaranteed Quality: Schema enforcement eliminates validation errors
  3. ๐Ÿค– Autonomous Operations: AI agents make decisions in your pipelines
  4. ๐Ÿ“ˆ Continuous Improvement: Every interaction improves your AI system

The future belongs to teams that master AI-first principles. This toolkit gives you the foundation to start that journey today.

License

MIT License - See LICENSE file for details. Copyright (c) 2025, Benjamin Linnik.

Support

๐Ÿ› Found a bug? ๐Ÿ’ก Have a question? ๐Ÿ“š Need help?

GitHub is your primary destination for all support:

Before opening an issue, please:

  1. โœ… Check the examples directory for solutions
  2. โœ… Review the error logs (beautiful output with Rich!)
  3. โœ… Validate your Azure authentication and permissions
  4. โœ… Ensure your input JSON follows the required format
  5. โœ… Search existing issues for similar problems

Quick Links:


Ready to embrace the AI-First future? Start with this toolkit and build your path to exponential productivity. Learn more about the AI-First DevOps revolution in Building AI-First DevOps.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_ci_runner-1.2.2.tar.gz (795.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_ci_runner-1.2.2-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file llm_ci_runner-1.2.2.tar.gz.

File metadata

  • Download URL: llm_ci_runner-1.2.2.tar.gz
  • Upload date:
  • Size: 795.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for llm_ci_runner-1.2.2.tar.gz
Algorithm Hash digest
SHA256 82053e1157b6869c3c16c6a8d801826261456733a96d070b0153bc082f7503f7
MD5 6be1575e0ac0ac16adb966b509d999b2
BLAKE2b-256 17dd6b22368667f7707b6b045324e40afaed8c07840e06cf17634da2f8d9ada4

See more details on using hashes here.

File details

Details for the file llm_ci_runner-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: llm_ci_runner-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for llm_ci_runner-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a93a2a1480e46b50f355b4566b158ac5a3fc75e0c7f36e8458aa7584ab6f6f44
MD5 4fc890b84572bc7f51310b16daac377f
BLAKE2b-256 d03eb07290f2d77c51a0de5ee4ec97c03508d975feeba5b4f46d3a68cd0e2668

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page