donaldfilimon/abi
ABI Agent + WDBX Database: A lightning-fast, fully optimized AI and ML training stack written in Zig 0.16.0-dev for unmatched performance and reliabil...
<<<<<<< HEAD
=======
Modern, modular Zig framework for AI/ML experiments and production workloads
Abi is an experimental framework that provides a curated set of feature modules for building high-performance AI/ML applications in Zig. It emphasizes:
| Feature | Description | Status |
|---|---|---|
| AI/ML | Agent system, neural networks, transformers, RL | β Production |
| Vector Database | High-performance vector storage and retrieval | β Production |
| GPU Acceleration | Multi-backend GPU compute (CUDA, Vulkan, Metal) | π In Progress |
| Web Server | HTTP server and client | β Production |
| Monitoring | Metrics, logging, and distributed tracing | β Production |
| Plugin System | Dynamic plugin loading and management | π In Progress |
The ABI Framework has been completely refactored with a clean, modern architecture:
abi/
βββ lib/ # Primary library source
β βββ core/ # Core utilities (I/O, diagnostics, collections)
β βββ features/ # Feature modules (AI, GPU, Database, Web)
β βββ framework/ # Framework infrastructure
β βββ shared/ # Shared utilities
βββ tools/ # Development tools and CLI
βββ examples/ # Standalone examples
βββ tests/ # Comprehensive test suite
βββ benchmarks/ # Performance tests
lib/ directoryusingnamespace)0.16.0-dev.254+6dd0270a1 or latergit clone https://github.com/donaldfilimon/abi.git
cd abi
zig build
const std = @import("std");
const abi = @import("abi");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Initialize the framework
var framework = try abi.init(allocator, .{});
defer abi.shutdown(&framework);
// Create an AI agent
const Agent = abi.ai.agent.Agent;
var agent = try Agent.init(allocator, .{ .name = "Assistant" });
defer agent.deinit();
// Process a query
const response = try agent.process("Hello, world!", allocator);
defer allocator.free(@constCast(response));
std.debug.print("Agent response: {s}\n", .{response});
}
# Build with specific features
zig build -Denable-ai=true -Denable-gpu=true -Dgpu-cuda=true
# Build and run tests
zig build test # Unit tests
zig build test-integration # Integration tests
zig build test-all # All tests
# Build examples
zig build examples # All examples
zig build run-ai_demo # Run specific example
# Build benchmarks
zig build bench
zig build run-bench
# Generate documentation
zig build docs
zig build docs-auto
βββββββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β (CLI, User Code, Tools) β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌββββββββββββββββββββββββββ
β Framework Layer β
β Runtime Β· Features Β· Plugins β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌββββββββββββββββββββββββββ
β Core Infrastructure β
β I/O Β· Errors Β· Diagnostics Β· Types β
βββββββββββββββββββββββββββββββββββββββββββββββ
lib/
βββ core/ # Core infrastructure
β βββ io.zig # I/O abstractions
β βββ errors.zig # Error definitions
β βββ diagnostics.zig # Diagnostics system
β βββ ...
βββ features/ # Feature modules
β βββ ai/ # AI/ML capabilities
β βββ database/ # Vector database
β βββ gpu/ # GPU acceleration
β βββ ...
βββ framework/ # Framework runtime
βββ runtime.zig # Lifecycle management
βββ ...
The Abi CLI provides comprehensive access to all framework features:
# Show help
./zig-out/bin/abi --help
# Feature management
./zig-out/bin/abi features list
./zig-out/bin/abi features status
# AI operations
./zig-out/bin/abi agent run --name "MyAgent"
./zig-out/bin/abi agent list
# Database operations
./zig-out/bin/abi db create --name vectors
./zig-out/bin/abi db query --vector "..."
# GPU benchmarks
./zig-out/bin/abi gpu bench
./zig-out/bin/abi gpu info
# Version information
./zig-out/bin/abi version
# Unit tests
zig build test
# Integration tests
zig build test-integration
# All tests
zig build test-all
# With coverage
zig build test -- --coverage
tests/
βββ unit/ # Unit tests (mirrors lib/)
βββ integration/ # Integration tests
β βββ ai_pipeline_test.zig
β βββ database_ops_test.zig
β βββ framework_lifecycle_test.zig
βββ fixtures/ # Test utilities
const std = @import("std");
const abi = @import("abi");
const testing = std.testing;
test "AI agent processes input correctly" {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var framework = try abi.init(allocator, .{});
defer abi.shutdown(&framework);
const Agent = abi.ai.agent.Agent;
var agent = try Agent.init(allocator, .{ .name = "Test" });
defer agent.deinit();
const response = try agent.process("test", allocator);
defer allocator.free(@constCast(response));
try testing.expect(response.len > 0);
}
const abi = @import("abi");
>>>>>>> 08cbda559b270a4426611f5b6c970439485a216a
var agent = try abi.ai.agent.Agent.init(allocator, .{
.name = "Assistant",
.max_retries = 3,
});
defer agent.deinit();
<<<<<<< HEAD
[](https://ziglang.org/) β’ [Docs](https://donaldfilimon.github.io/abi/) β’ [CI: Pages](.github/workflows/deploy_docs.yml)
[](LICENSE)
[](https://github.com/yourusername/abi)
[]()
[]()
[]()
=======
const response = try agent.process("Explain quantum computing", allocator);
defer allocator.free(@constCast(response));
08cbda559b270a4426611f5b6c970439485a216a
const db = abi.database;
var vector_db = try db.VectorDB.init(allocator, .{
.dimension = 128,
.metric = .cosine,
});
defer vector_db.deinit();
try vector_db.insert("doc1", embedding);
const results = try vector_db.search(query, 10);
const gpu = abi.gpu;
var backend = try gpu.selectBackend(allocator);
defer backend.deinit();
<<<<<<< HEAD
### **Prerequisites**
- **Zig 0.16.0-dev.1225+bf9082518** (GitHub Actions uses `mlugg/setup-zig@v2` pinned to this version)
- GPU drivers (optional, for acceleration)
- OpenAI API key (for AI agent features)
=======
const kernel = try gpu.loadKernel("matrix_mul");
try backend.execute(kernel, .{ .a = a, .b = b, .result = result });
08cbda559b270a4426611f5b6c970439485a216a
We welcome contributions! Please see our Contributing Guide for details.
# Clone the repository
git clone https://github.com/donaldfilimon/abi.git
cd abi
# Run tests
zig build test-all
# Format code
zig fmt .
# Build all examples
zig build examples
Modular build system
I/O abstraction layer
Comprehensive error handling
Improved testing infrastructure
Complete GPU backend implementations
Advanced monitoring and tracing
Plugin system v2
Performance optimizations
Distributed computing support
Advanced ML model formats
Production deployment guides
Cloud provider integrations
<<<<<<< HEAD // Add embeddings const embedding = [_]f32{0.1, 0.2, 0.3, /* ... */}; const row_id = try db.addEmbedding(&embedding);
// Search for similar vectors const query = [_]f32{0.15, 0.25, 0.35, /* ... */}; const matches = try db.search(&query, 10, allocator); defer abi.features.database.database.Db.freeResults(matches, allocator);
> **Note:** Always release search metadata with `Db.freeResults` when you're done to reclaim allocator-backed resources.
### **WDBX Vector Database Features**
The ABI vector database provides enterprise-grade performance with:
- **High Performance**: SIMD-optimized vector operations and efficient file I/O
- **Vector Operations**: Add, query, and k-nearest neighbor search
- **Multiple APIs**: Command-line interface, HTTP REST API, TCP binary protocol, WebSocket
- **Security**: JWT authentication and rate limiting
- **Monitoring**: Comprehensive statistics and performance metrics
- **Production Ready**: Error handling, graceful degradation, and comprehensive testing
#### **Command Line Usage**
```bash
# Query k-nearest neighbors
./zig-out/bin/abi wdbx knn "1.1,2.1,3.1,4.1,5.1,6.1,7.1,8.1" 5
# Query nearest neighbor
./zig-out/bin/abi wdbx query "1.1,2.1,3.1,4.1,5.1,6.1,7.1,8.1"
# Add vector to database
./zig-out/bin/abi wdbx add "1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0"
# Start HTTP REST API server
./zig-out/bin/abi wdbx http 8080
Start the server and access endpoints:
./zig-out/bin/abi wdbx http 8080
API Endpoints:
GET /health - Health checkGET /stats - Database statisticsPOST /add - Add vector (requires admin token)GET /query?vec=1.0,2.0,3.0 - Query nearest neighborGET /knn?vec=1.0,2.0,3.0&k=5 - Query k-nearest neighbors| Component | Performance | Hardware |
|---|---|---|
| Text Processing | 3.2 GB/s | SIMD-accelerated with alignment safety |
| Vector Operations | 15 GFLOPS | SIMD dot product with memory tracking |
| Neural Networks | <1ms inference | 32x32 network with memory safety |
| LSP Completions | <10ms response | Sub-10ms completion responses |
| GPU Rendering | 500+ FPS | Terminal UI with GPU acceleration |
| Lock-free Queue | 10M ops/sec | Single producer, minimal contention |
| WDBX Database | 2,777+ ops/sec | Production-validated performance |
# AI Chat (Interactive)
abi chat --persona creative --backend openai --interactive
# AI Chat (Single Message)
abi chat "Hello, how can you help me?" --persona analytical
# Model Training
abi llm train --data training_data.csv --output model.bin --epochs 100 --lr 0.001
# Model Training with GPU
abi llm train --data data.csv --gpu --threads 8 --batch-size 64
# Vector Database Operations
abi llm embed --db vectors.wdbx --text "Sample text for embedding"
abi llm query --db vectors.wdbx --text "Query text" --k 5
# Web Server
abi web --port 8080
# Performance Benchmarking
abi benchmark --iterations 1000 --memory-track
# Memory Profiling
abi --memory-profile benchmark
Configure features and targets via command-line flags:
-Denable_cuda=true|false (default: true) - Enable NVIDIA CUDA support-Denable_spirv=true|false (default: true) - Enable Vulkan/SPIRV compilation-Denable_wasm=true|false (default: true) - Enable WebAssembly compilation-Dtarget=<triple> - Cross-compilation target (e.g., x86_64-linux-gnu, aarch64-macos)-Doptimize=Debug|ReleaseSafe|ReleaseFast|ReleaseSmall (default: Debug)-Denable_cross_compilation=true|false (default: true) - Enable cross-compilation support-Denable_heavy_tests=true|false (default: false) - Run heavy database/HNSW tests# Production build with CUDA acceleration
zig build -Dtarget=x86_64-linux-gnu -Doptimize=ReleaseFast -Denable_cuda=true
# Cross-compile for ARM64 macOS
zig build -Dtarget=aarch64-macos -Doptimize=ReleaseSmall
# Run with all tests including heavy ones
zig build test-all -Denable_heavy_tests=true
# Minimal build without GPU support
zig build -Denable_cuda=false -Denable_spirv=false
Build options are available at compile-time via the options module:
const options = @import("options");
pub fn main() void {
std.log.info("CUDA: {}, SPIRV: {}", .{ options.enable_cuda, options.enable_spirv });
std.log.info("Target: {}", .{ options.target });
}
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Abi AI Framework β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π€ AI Agents π§ Neural Nets ποΈ Vector Database β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π SIMD Ops π Lock-free π Network Servers β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π Monitoring π Profiling π§ͺ Testing Suite β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π Plugin Sys π± CLI Interface π Platform Ops β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
zig buildzig build testzig build bench-allzig build docszig build analyzezig build cross-platform# Run all tests
zig build test
# Memory management tests
zig test tests/test_memory_management.zig
# Performance regression tests
zig test tests/test_performance_regression.zig
# CLI integration tests
zig test tests/test_cli_integration.zig
Start the web server and access REST endpoints:
abi web --port 8080
Available Endpoints:
GET /health - Health checkGET /api/status - System statusPOST /api/agent/query - Query AI agent (JSON: {"message": "your question"})POST /api/database/search - Search vectorsGET /api/database/info - Database informationWebSocket /ws - Real-time chat with AI agentCreate custom plugins for the framework:
// Example plugin
pub const ExamplePlugin = struct {
pub const name = "example_plugin";
pub const version = "1.0.0";
pub fn init(allocator: std.mem.Allocator) !*@This() {
// Plugin initialization
}
pub fn deinit(self: *@This()) void {
// Plugin cleanup
}
};
See the Module Organization guide and generated module reference for plugin entry points.
The framework includes production-ready deployment configurations:
See Production Deployment Guide for complete deployment instructions.
# Examples
zig build -Dtarget=x86_64-linux-gnu
zig build -Dtarget=aarch64-linux-gnu
zig build -Dtarget=x86_64-macos
zig build -Dtarget=aarch64-macos
zig build -Dtarget=wasm32-wasi
const builtin = @import("builtin");
pub fn main() void {
if (comptime builtin.os.tag == .windows) {
// Windows-specific code
} else if (comptime builtin.os.tag == .linux) {
// Linux-specific code
} else if (comptime builtin.os.tag == .macos) {
// macOS-specific code
}
}
zig build cross-platform # builds CLI for multiple targets into zig-out/cross/
zig build test-network (Windows only)fix_windows_networking.ps1We welcome contributions! Please read our Contributing Guide for details.
=======
08cbda559b270a4426611f5b6c970439485a216a
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using Zig 0.16
Last Updated: October 8, 2025
08cbda559b270a4426611f5b6c970439485a216a