Skip to content

LLM-Dev-Ops/forge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

33 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš’๏ธ LLM-Forge

npm version npm downloads Tests Coverage CI Security License Node.js

A unified response parser and SDK generator for LLM APIs across multiple programming languages

LLM-Forge provides a production-ready, type-safe way to parse and normalize responses from multiple LLM providers (OpenAI, Anthropic, Cohere, Google AI, Mistral, and more) with support for generating client libraries in 6 languages: TypeScript, Python, Rust, Go, Java, and C#.

Why LLM-Forge?

  • ๐Ÿ”„ Unified API - One interface for 12+ LLM providers
  • ๐Ÿš€ Ultra-Fast - 136K-454K ops/sec parsing performance
  • ๐Ÿ›ก๏ธ Type-Safe - Full TypeScript inference and validation
  • ๐Ÿงช Battle-Tested - 666 tests, 93.77% coverage
  • ๐Ÿ“ฆ Zero Dependencies - Lightweight, production-ready
  • ๐ŸŒ Multi-Language - Generate SDKs in 6 languages

๐Ÿ“‹ Table of Contents


โœจ Features

Provider Support (12 Providers)

  • โœ… Multi-Provider Parsing: Unified response format for 12 LLM providers
  • โœ… Auto-Detection: Automatically detect provider from response structure
  • โœ… Streaming Support: Real-time streaming chunk parsing
  • โœ… Type-Safe: Full TypeScript type inference and safety
  • โœ… Production Ready: 93.77% test coverage, 666 passing tests
  • โœ… High Performance: 136K-454K ops/sec parsing, 1-10M ops/sec detection

Code Generation (6 Languages)

  • โœ… TypeScript: Full type inference, decorators, async/await
  • โœ… Python: Type hints, Pydantic models, async support
  • โœ… Rust: Serde, strong typing, Result<T,E>
  • โœ… Java: Record classes, Jackson, CompletableFuture
  • โœ… C#: Record types, System.Text.Json, async streams
  • โœ… Go: Struct tags, JSON marshaling, context support

Enterprise Features

  • โœ… CI/CD Pipeline: 7 GitHub Actions workflows for automation
  • โœ… Security Scanning: Multi-layer security with CodeQL, npm audit, OSSF
  • โœ… Performance Monitoring: Automated benchmarking and regression detection
  • โœ… Automated Releases: npm and GitHub Packages publishing
  • โœ… Comprehensive Documentation: Production guides and API docs

๐Ÿ“Š Status

Production Ready โœ…

Test Coverage:  93.77% โœ…
Tests Passing:  666/666 (100%) โœ…
Benchmarks:     27 performance tests โœ…
CI/CD:          7 automated workflows โœ…
Documentation:  Complete โœ…

๐Ÿš€ Quick Start

Installation

# Using npm
npm install @llm-dev-ops/llm-forge

# Using yarn
yarn add @llm-dev-ops/llm-forge

# Using pnpm
pnpm add @llm-dev-ops/llm-forge

Basic Usage - Response Parsing

import { parseResponse } from '@llm-dev-ops/llm-forge';

// Parse any LLM provider response - automatically detects the provider
const response = await fetch('https://api.openai.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'gpt-4',
    messages: [{ role: 'user', content: 'Hello, world!' }]
  })
});

const data = await response.json();
const parsed = await parseResponse(data);

if (parsed.success) {
  console.log(parsed.response.messages[0].content);
  // Output: "Hello! How can I help you today?"

  console.log(`Provider: ${parsed.response.provider}`);
  // Output: "Provider: openai"

  console.log(`Model: ${parsed.response.model.id}`);
  // Output: "Model: gpt-4"

  console.log(`Tokens: ${parsed.response.usage.totalTokens}`);
  // Output: "Tokens: 25"
}

Real-World Example - Multi-Provider Chat

import { parseResponse } from '@llm-dev-ops/llm-forge';

async function chat(provider: 'openai' | 'anthropic' | 'cohere', message: string) {
  // Use any provider's API - LLM-Forge normalizes the response
  const endpoints = {
    openai: 'https://api.openai.com/v1/chat/completions',
    anthropic: 'https://api.anthropic.com/v1/messages',
    cohere: 'https://api.cohere.ai/v1/chat'
  };

  const response = await fetch(endpoints[provider], {
    method: 'POST',
    headers: { /* provider-specific headers */ },
    body: JSON.stringify({ /* provider-specific payload */ })
  });

  const data = await response.json();
  const parsed = await parseResponse(data);

  if (parsed.success) {
    return {
      text: parsed.response.messages[0].content,
      tokens: parsed.response.usage.totalTokens,
      cost: calculateCost(parsed.response.usage, parsed.response.model.id)
    };
  }

  throw new Error(parsed.error.message);
}

// Works seamlessly with any provider
const openAIResult = await chat('openai', 'Explain quantum computing');
const claudeResult = await chat('anthropic', 'Explain quantum computing');
const cohereResult = await chat('cohere', 'Explain quantum computing');

Auto-Detection

import { parseResponse } from '@llm-dev-ops/llm-forge';

// Automatically detects provider from response structure
const openAIResponse = await parseResponse(openAIData);    // Detects OpenAI
const anthropicResponse = await parseResponse(claudeData); // Detects Anthropic
const cohereResponse = await parseResponse(cohereData);    // Detects Cohere

๐Ÿ’ก Use Cases

1. Multi-Provider Chatbots

Build chatbots that can seamlessly switch between different LLM providers based on cost, performance, or availability.

2. LLM Abstraction Layer

Create a unified interface for your application that works with any LLM provider, making it easy to switch providers or A/B test different models.

3. Cost Optimization

Parse usage data from multiple providers to track and optimize token usage and costs across your organization.

4. SDK Generation

Generate type-safe client libraries in multiple programming languages from OpenAPI specifications, accelerating development across teams.

5. LLM Gateway/Proxy

Build an LLM gateway that routes requests to different providers, normalizes responses, and provides unified monitoring and analytics.

6. Testing & Development

Easily switch between providers during development and testing without changing your application code.

Provider-Specific Parsing

import { OpenAIProvider, AnthropicProvider } from '@llm-dev-ops/llm-forge';

const openai = new OpenAIProvider();
const result = await openai.parse(openAIResponse);

const anthropic = new AnthropicProvider();
const claudeResult = await anthropic.parse(anthropicResponse);

Streaming Support

import { OpenAIProvider } from '@llm-dev-ops/llm-forge';

const provider = new OpenAIProvider();

// Parse streaming chunks
for await (const chunk of streamingResponse) {
  const parsed = await provider.parseStream(chunk);
  if (parsed.success) {
    process.stdout.write(parsed.response.messages[0].content);
  }
}

๐ŸŽฏ Supported Providers

Provider Status Detection Parsing Streaming
OpenAI โœ… Complete โœ… โœ… โœ…
Anthropic โœ… Complete โœ… โœ… โœ…
Google AI โœ… Complete โœ… โœ… โœ…
Cohere โœ… Complete โœ… โœ… โœ…
Mistral โœ… Complete โœ… โœ… โœ…
Azure OpenAI โœ… Complete โœ… โœ… โœ…
Hugging Face โœ… Complete โœ… โœ… โš ๏ธ Limited
Replicate โœ… Complete โœ… โœ… โš ๏ธ Limited
Together AI โœ… Complete โœ… โœ… โš ๏ธ Limited
Perplexity โœ… Complete โœ… โœ… โœ…
OpenRouter โœ… Complete โœ… โœ… โœ…
Custom โœ… Complete โœ… โœ… โš ๏ธ Provider-dependent

๐Ÿ”ง Code Generation

Generate TypeScript Client

import { generateTypeScript } from '@llm-dev-ops/llm-forge';

const schema = {
  name: 'ChatCompletion',
  properties: {
    messages: { type: 'array', items: { type: 'Message' } },
    model: { type: 'string' }
  }
};

const code = await generateTypeScript(schema);
console.log(code);

Supported Languages

Language Status Package Manager Type Safety Async Support
TypeScript โœ… Complete npm Full async/await
Python โœ… Complete pip Type hints async/await
Rust โœ… Complete cargo Strong tokio
Java โœ… Complete Maven/Gradle Strong CompletableFuture
C# โœ… Complete NuGet Strong async/await
Go โœ… Complete go modules Static goroutines

๐Ÿ“ˆ Performance

Benchmarks (ops/sec)

Provider Detection:

  • OpenAI: 9.7M ops/sec
  • Anthropic: 9.4M ops/sec
  • Cohere: 8.7M ops/sec
  • Mistral: 6.7M ops/sec
  • Google AI: 5.5M ops/sec

Response Parsing:

  • Mistral: 454K ops/sec (fastest)
  • OpenAI: 422K ops/sec
  • Anthropic: 368K ops/sec
  • Cohere: 313K ops/sec
  • Google AI: 137K ops/sec

Streaming:

  • OpenAI: 504K chunks/sec
  • Anthropic: 485K chunks/sec

Benchmarked on Node.js 20 with Vitest bench suite (27 benchmarks)

๐Ÿ—๏ธ Architecture

LLM-Forge uses a layered architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Provider Responses (OpenAI, Anthropic, etc.)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Provider Detection & Auto-detection                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Unified Response Parsing                           โ”‚
โ”‚  - Message extraction                               โ”‚
โ”‚  - Metadata normalization                           โ”‚
โ”‚  - Token usage tracking                             โ”‚
โ”‚  - Error handling                                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Code Generation (6 languages)                      โ”‚
โ”‚  - Type generation                                  โ”‚
โ”‚  - Client generation                                โ”‚
โ”‚  - Serialization                                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

See docs/ARCHITECTURE.md for detailed architecture documentation.

๐Ÿงช Testing

Test Coverage

Overall Coverage:    93.77%
Providers Coverage:  92.68%
Generators Coverage: 98.17%
Parsers Coverage:    98.04%
Core Coverage:       97.73%

Total Tests: 666 passing
Test Files:  23 files
Duration:    ~10 seconds

Run Tests

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run benchmarks
npm run bench

# Run specific test file
npm test tests/providers/integration.test.ts

๐Ÿ”’ Security

LLM-Forge implements multiple security layers:

  • โœ… Daily Security Scans: Automated vulnerability detection
  • โœ… CodeQL Analysis: Static security analysis
  • โœ… Secret Detection: TruffleHog scanning
  • โœ… License Compliance: Automated license checking
  • โœ… Dependency Updates: Dependabot automation
  • โœ… OSSF Scorecard: Security best practices validation

See docs/CI_CD_PIPELINE.md for security documentation.

๐Ÿ”„ CI/CD Pipeline

7 automated workflows ensure quality:

  1. PR Validation - Quality gates for pull requests
  2. Continuous Integration - Multi-OS testing (Ubuntu, macOS, Windows)
  3. Security Scanning - Multi-layer security analysis
  4. Performance Monitoring - Benchmark tracking and regression detection
  5. Release & Publish - Automated npm publishing
  6. Dependabot Auto-Merge - Safe dependency updates
  7. Stale Management - Issue/PR lifecycle management

See .github/README.md for workflow documentation.

๐Ÿ“š Documentation

User Guides

Implementation

Reference

๐Ÿ› ๏ธ Development

Prerequisites

  • Node.js >= 20.0.0
  • npm >= 10.0.0
  • TypeScript >= 5.3.3

Setup

# Clone repository
git clone https://github.com/globalbusinessadvisors/llm-forge.git
cd llm-forge

# Install dependencies
npm install

# Run tests
npm test

# Build project
npm run build

# Run development mode
npm run dev

# Run benchmarks
npm run bench

# Run all quality checks
npm run quality

CLI Usage

LLM-Forge includes a command-line interface for generating SDKs:

# Run CLI in development
npm run cli -- --help

# Generate SDK from OpenAPI spec
npm run cli -- generate --input openapi.json --output ./sdk --language typescript

# After installation (globally or in project)
npx llm-forge generate --input openapi.json --language python

Project Structure

llm-forge/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ core/           # Template engine and type system
โ”‚   โ”œโ”€โ”€ generators/     # Language-specific code generators
โ”‚   โ”œโ”€โ”€ parsers/        # OpenAPI and Anthropic parsers
โ”‚   โ”œโ”€โ”€ providers/      # Provider-specific parsers (12 providers)
โ”‚   โ”œโ”€โ”€ schema/         # Schema validation
โ”‚   โ””โ”€โ”€ types/          # TypeScript type definitions
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ core/           # Core functionality tests
โ”‚   โ”œโ”€โ”€ generators/     # Code generator tests
โ”‚   โ”œโ”€โ”€ parsers/        # Parser tests
โ”‚   โ”œโ”€โ”€ providers/      # Provider tests (integration, benchmarks)
โ”‚   โ””โ”€โ”€ schema/         # Schema validation tests
โ”œโ”€โ”€ docs/               # Comprehensive documentation
โ”œโ”€โ”€ examples/           # Example usage
โ”œโ”€โ”€ scripts/            # Build and utility scripts
โ””โ”€โ”€ .github/
    โ”œโ”€โ”€ workflows/      # 7 CI/CD workflows
    โ””โ”€โ”€ dependabot.yml  # Dependency automation

Available Scripts

npm test              # Run all tests
npm run test:coverage # Run tests with coverage report
npm run bench         # Run performance benchmarks
npm run type-check    # TypeScript type checking
npm run lint          # ESLint code linting
npm run format        # Prettier code formatting
npm run build         # Build package
npm run clean         # Clean build artifacts
npm run quality       # Run all quality checks

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Run quality checks (npm run quality)
  5. Commit your changes (git commit -m 'feat: add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

All PRs must pass:

  • โœ… TypeScript type checking
  • โœ… ESLint linting
  • โœ… Prettier formatting
  • โœ… All 666 tests
  • โœ… 93%+ code coverage
  • โœ… Security scans

See docs/CI_CD_PIPELINE.md for detailed contribution guidelines.

๐Ÿ“ฆ Publishing

npm

npm install @llm-dev-ops/llm-forge

GitHub Packages

npm install @llm-dev-ops/llm-forge

๐Ÿ—บ๏ธ Roadmap

โœ… Phase 1: Foundation (Complete)

  • โœ… Provider response parsing (12 providers)
  • โœ… Unified response format
  • โœ… Auto-detection system
  • โœ… Streaming support

โœ… Phase 2: Code Generation (Complete)

  • โœ… TypeScript generator
  • โœ… Python generator
  • โœ… Rust generator
  • โœ… Java generator
  • โœ… C# generator
  • โœ… Go generator

โœ… Phase 3: Production Ready (Complete)

  • โœ… Comprehensive testing (666 tests)
  • โœ… 93.77% code coverage
  • โœ… Performance benchmarking
  • โœ… CI/CD pipeline (7 workflows)
  • โœ… Security scanning
  • โœ… Complete documentation

๐Ÿ”ฎ Phase 4: Future Enhancements (Planned)

  • CLI tool for SDK generation
  • Plugin system for custom providers
  • Cost tracking and analytics
  • Advanced observability
  • Custom provider templates
  • GraphQL support

๐Ÿ“„ License

Apache License 2.0 - see LICENSE for details.

๐Ÿ™ Acknowledgments

Built with enterprise-grade quality using:

  • Testing: Vitest
  • CI/CD: GitHub Actions
  • Security: CodeQL, TruffleHug, OSSF Scorecard
  • Coverage: Codecov
  • Type Safety: TypeScript

๐Ÿ“Š Project Metrics

Lines of Code:       ~15,000
Test Coverage:       93.77%
Tests:              666 passing
Benchmarks:         27 performance tests
Providers:          12 supported
Languages:          6 code generators
CI/CD Workflows:    7 automated
Documentation:      35+ comprehensive docs
Performance:        136K-454K ops/sec parsing
Security:           Multi-layer scanning

๐Ÿ†˜ Support


Status: โœ… Production Ready | License: Apache 2.0 | Version: 1.0.0

Made with โค๏ธ by the LLM-Dev-Ops Team

Getting Started ยท Documentation ยท Report Bug ยท Request Feature

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors