perfecXion.ai

Installation Guide

Install perfecX G-Rails SDKs and tools for your preferred platform and environment.

System Requirements

Python SDK

  • Python 3.8 or higher
  • pip 20.0+
  • 4GB RAM minimum
  • GPU recommended for real-time analysis

Node.js SDK

  • Node.js 16.0 or higher
  • npm 7+ or yarn 1.22+
  • 4GB RAM minimum
  • TypeScript 4.5+ (optional)

Python SDK Installation

Using pip

pip install perfecxion-g-rails

Using Poetry

poetry add perfecxion-g-rails

Using Conda

conda install -c perfecxion perfecxion-g-rails

Optional Dependencies

For GPU acceleration:

pip install "perfecxion-g-rails[gpu]"

For LangChain integration:

pip install "perfecxion-g-rails[langchain]"

For all integrations:

pip install "perfecxion-g-rails[all]"

Node.js SDK Installation

Using npm

npm install @perfecxion/g-rails

Using yarn

yarn add @perfecxion/g-rails

Using pnpm

pnpm add @perfecxion/g-rails

TypeScript Support

TypeScript definitions are included. No additional @types package needed.

// tsconfig.json
{
  "compilerOptions": {
    "types": ["@perfecxion/g-rails"]
  }
}

CLI Tool Installation

Global Installation

npm install -g @perfecxion/g-rails-cli

Verify Installation

grails --version
# Output: perfecX G-Rails CLI v1.0.0

grails --help
# Shows all available commands

grails test --help
# Shows guardrail testing options

Docker Installation

Pull the Docker Image

docker pull perfecxion/g-rails:latest

Run with Docker Compose

# docker-compose.yml
version: '3.8'
services:
  g-rails:
    image: perfecxion/g-rails:latest
    environment:
      - GRAILS_API_KEY=your-api-key
      - GRAILS_ENVIRONMENT=production
      - GRAILS_LOG_LEVEL=info
    ports:
      - "8080:8080"
      - "9090:9090"  # Metrics endpoint
    volumes:
      - ./config:/app/config
      - ./guardrails:/app/guardrails
      - ./logs:/app/logs
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 4G
        reservations:
          cpus: '1'
          memory: 2G
          
  # Optional: Local Redis for caching
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data

volumes:
  redis-data:

Kubernetes Deployment

Helm Chart Installation

# Add Helm repository
helm repo add perfecxion https://charts.perfecxion.ai
helm repo update

# Install G-Rails
helm install g-rails perfecxion/g-rails \
  --set apiKey=your-api-key \
  --set replicas=3 \
  --set resources.requests.memory=2Gi \
  --set resources.requests.cpu=1000m \
  --namespace g-rails \
  --create-namespace

Custom Values Configuration

# values.yaml
replicaCount: 3

image:
  repository: perfecxion/g-rails
  tag: "1.0.0"
  pullPolicy: IfNotPresent

service:
  type: LoadBalancer
  port: 80
  metricsPort: 9090

ingress:
  enabled: true
  className: nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
  hosts:
    - host: g-rails.your-domain.com
      paths:
        - path: /
          pathType: Prefix

autoscaling:
  enabled: true
  minReplicas: 3
  maxReplicas: 10
  targetCPUUtilizationPercentage: 70
  targetMemoryUtilizationPercentage: 80

guardrails:
  cache:
    enabled: true
    type: redis
    redis:
      host: redis-master
      port: 6379
      
monitoring:
  prometheus:
    enabled: true
    serviceMonitor:
      enabled: true

Environment Configuration

Environment Variables

# .env file
GRAILS_API_KEY=your-api-key-here
GRAILS_ENVIRONMENT=production
GRAILS_LOG_LEVEL=info
GRAILS_CACHE_ENABLED=true
GRAILS_CACHE_TTL=3600
GRAILS_METRICS_ENABLED=true
GRAILS_METRICS_PORT=9090
GRAILS_MAX_BATCH_SIZE=100
GRAILS_TIMEOUT_MS=5000

Configuration File

# g-rails.config.yaml
api:
  key: ${GRAILS_API_KEY}
  endpoint: https://api.perfecxion.ai/v1/g-rails
  timeout: 5s
  retries: 3

guardrails:
  default_action: "warn"
  strict_mode: false
  
  toxicity:
    enabled: true
    threshold: 0.7
    models: ["perspective", "detoxify"]
    
  bias:
    enabled: true
    protected_attributes: ["gender", "race", "age", "religion"]
    max_disparity: 0.05
    
  pii:
    enabled: true
    types: ["email", "phone", "ssn", "credit_card"]
    action: "redact"
    
  hallucination:
    enabled: true
    fact_check_api: "https://factcheck.api.com"
    confidence_threshold: 0.8

performance:
  cache:
    enabled: true
    ttl: 3600
    max_size: 1000
    
  batching:
    enabled: true
    max_batch_size: 100
    max_wait_ms: 100
    
monitoring:
  metrics:
    enabled: true
    port: 9090
    path: /metrics
    
  logging:
    level: info
    format: json
    output: stdout

Verify Your Installation

Python

import perfecxion_g_rails

# Check version
print(perfecxion_g_rails.__version__)

# Test connection
from perfecxion_g_rails import GRailsClient

client = GRailsClient(api_key="your-api-key")
status = client.health_check()
print(f"Connection status: {status.status}")
print(f"API version: {status.api_version}")
print(f"Available guardrails: {', '.join(status.guardrails)}")

Node.js

const { GRailsClient } = require('@perfecxion/g-rails');

// Check version
console.log(GRailsClient.VERSION);

// Test connection
const client = new GRailsClient({ apiKey: 'your-api-key' });
const status = await client.healthCheck();
console.log(`Connection status: ${status.status}`);
console.log(`API version: ${status.apiVersion}`);
console.log(`Available guardrails: ${status.guardrails.join(', ')}`);

CLI

# Test CLI connection
grails test-connection

# Run guardrail test
grails test --input "Sample text" --guardrails toxicity,bias

# Validate configuration
grails config validate

Performance Optimization

GPU Acceleration

For real-time guardrail processing at scale, GPU acceleration is recommended:

# Install with CUDA support
pip install "perfecxion-g-rails[gpu]"

# Verify GPU availability
import perfecxion_g_rails
print(perfecxion_g_rails.cuda_available())  # Should return True

# Configure GPU usage
client = GRailsClient(
    api_key="your-api-key",
    device="cuda:0",  # Use first GPU
    batch_size=32,    # Optimize for GPU
    fp16=True         # Use mixed precision
)

Common Installation Issues

SSL Certificate Errors

For corporate proxies: export NODE_TLS_REJECT_UNAUTHORIZED=0

Permission Denied

Use sudo for global installs or use a virtual environment

GPU Not Detected

Ensure CUDA drivers are installed and nvidia-smi works

Memory Issues

Reduce batch size or disable caching if running on limited resources