Skip to content

AI-powered transcript analysis microservice for the Jubal ecosystem. Provides multi-step profile-based processing with local and cloud LLM integration.

Notifications You must be signed in to change notification settings

arealicehole/grok

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Grok Intelligence Engine

Docker FastAPI Python Pydantic

AI-powered transcript analysis microservice for the Jubal Personal Operating System ecosystem.

Grok provides intelligent, multi-step profile-based processing of audio transcripts with support for both local (Ollama) and cloud (OpenRouter) LLM providers. Built with FastAPI and designed for containerized deployment in microservices architectures.

πŸš€ Quick Start

Prerequisites

  • Docker Desktop 4.0+
  • Docker Compose v2.0+
  • Shared Jubal Network (for service registry)

Run with Docker Compose

# Clone repository
git clone https://github.com/arealicehole/grok.git
cd grok

# Set up environment variables
cp .env.example .env
# Edit .env with your configuration

# Start the service
docker compose up -d

# Verify service health
curl http://localhost:8002/health

πŸ“‹ Current Status

βœ… Phase 3.1 Complete: LLM Provider Integration

Recent Accomplishments:

  • βœ… Local LLM Integration (Ollama): Full async provider with model listing and completions
  • βœ… Cloud LLM Integration (OpenRouter): Authentication, 10+ models, rate limiting
  • βœ… Provider Abstraction: Base classes with intelligent fallback strategies
  • βœ… Model Selection Engine: Smart provider selection with global overrides
  • βœ… Comprehensive Testing: Full unit test coverage for all providers
  • βœ… Docker Integration: Updated containers with new provider endpoints

πŸ—οΈ In Development: Phase 3.2 - Profile Processing Engine

Next Major Features:

  • πŸ”„ Multi-step Profile Processing Engine
  • πŸ”„ Built-in Analysis Profiles (Business, Project Planning, Personal)
  • πŸ”„ Profile Definition System with Pydantic schemas
  • πŸ”„ Step Execution Engine with data flow

πŸ”Œ API Endpoints

Service Management

Endpoint Method Description Status
/health GET Service health check βœ…
/capabilities GET Service capabilities declaration βœ…
/services GET List registered Jubal services βœ…
/providers/status GET LLM provider health and availability βœ…

Profile Management

Endpoint Method Description Status
/profiles GET List available processing profiles βœ…
/profiles/{id} GET Get specific profile details βœ…

Processing

Endpoint Method Description Status
/process POST Process transcript with specified profile βœ…

Example Usage

# Health check
curl http://localhost:8002/health

# List available profiles
curl http://localhost:8002/profiles | jq .

# Process a transcript
curl -X POST http://localhost:8002/process \
  -H "Content-Type: application/json" \
  -d '{
    "job_id": "meeting-001",
    "data": {
      "type": "text/plain",
      "content": "John: Welcome to our meeting. Jane: Thanks, lets discuss the API requirements.",
      "encoding": "utf-8"
    },
    "metadata": {
      "profile_id": "business_meeting"
    }
  }' | jq .

πŸ—οΈ Architecture

Container Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Jubal Network                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Jubal Core    β”‚  β”‚  Recall Adapter β”‚  β”‚   Grok   β”‚ β”‚
β”‚  β”‚    (8000)       β”‚  β”‚     (8001)      β”‚  β”‚  (8002)  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚             β”‚                   β”‚               β”‚       β”‚
β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                                 β”‚                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Redis Registry β”‚β†β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚  Supabase    β”‚ β”‚
β”‚  β”‚     (6379)      β”‚                     β”‚ (54325+)     β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Application Structure

grok/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py                 # FastAPI application entry
β”‚   β”œβ”€β”€ config.py               # Settings management
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ jubal.py           # Jubal service contracts
β”‚   β”‚   └── profile.py         # Processing profile schemas
β”‚   └── services/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ registry.py        # Redis service registry
β”‚       └── processor.py       # Profile processing engine
β”œβ”€β”€ profiles/                   # Processing profile definitions
β”œβ”€β”€ docs/                      # Project documentation
β”œβ”€β”€ Dockerfile                 # Container definition
β”œβ”€β”€ docker-compose.yml         # Service orchestration
β”œβ”€β”€ requirements.txt           # Python dependencies
└── .env.example               # Environment configuration template

πŸ”§ Configuration

Environment Variables

# Service Configuration
GROK_SERVICE_PORT=8002
GROK_DEBUG=true

# Jubal Integration
GROK_JUBAL_CORE_URL=http://jubal-core:8000
GROK_REDIS_URL=redis://jubal-redis:6379/0

# LLM Providers
GROK_OLLAMA_URL=http://host.docker.internal:11434
GROK_OPENROUTER_API_KEY=your_openrouter_api_key_here
GROK_OPENROUTER_APP_NAME=grok-intelligence-engine
GROK_OPENROUTER_APP_URL=

# Default Models
GROK_DEFAULT_MODEL_PROVIDER=local
GROK_DEFAULT_LOCAL_MODEL=llama3.1:8b
GROK_DEFAULT_OPENROUTER_MODEL=openai/gpt-4o-mini

# Processing Configuration
GROK_MAX_CONCURRENT_JOBS=5
GROK_DEFAULT_TEMPERATURE=0.2
GROK_DEFAULT_MAX_TOKENS=2000

# File Management
GROK_PROFILES_DIR=./profiles
GROK_AUTO_PROCESS_NEW_FILES=false

Docker Compose Services

  • grok-adapter: Main application service (port 8002)
  • External Dependencies:
    • jubal-redis: Service registry (shared)
    • jubal-network: Service communication network (shared)

πŸ“Š Processing Profiles

Grok uses multi-step processing profiles to analyze transcripts. Each profile defines a sequence of LLM operations with specific prompts and model configurations.

Available Profiles

Profile ID Description Steps Estimated Tokens
business_meeting Extract entities, decisions, action items 3 4,500
project_planning Analyze requirements, timelines, risks 4 5,200
personal_notes Process notes for organization 3 3,000

Profile Structure

{
  "profile_id": "business_meeting",
  "name": "Business Meeting Analysis",
  "description": "Extract entities, decisions, and action items from business meetings",
  "steps": [
    {
      "step_id": "extract_entities",
      "name": "Extract Key Entities",
      "prompt_template": "Extract people, companies, and dates from: {transcript}",
      "llm_config": {
        "provider": "local",
        "model": "llama3.1:8b",
        "temperature": 0.1
      },
      "output_format": "json"
    }
  ]
}

πŸ§ͺ Development

Local Development Setup

# 1. Clone repository
git clone https://github.com/arealicehole/grok.git
cd grok

# 2. Set up Python environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

# 3. Configure environment
cp .env.example .env
# Edit .env with your configuration

# 4. Start dependencies (Redis, Supabase)
# Note: Use shared Jubal infrastructure

# 5. Run application
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8002

Testing

# Install test dependencies
pip install pytest pytest-asyncio httpx

# Run unit tests
pytest tests/

# Integration testing with curl
./scripts/test_endpoints.sh

# End-to-end testing with sample data
curl -X POST http://localhost:8002/process -d @test_data/business_meeting.json

Docker Development

# Build container
docker compose build grok-adapter

# Start services
docker compose up -d

# View logs
docker compose logs grok-adapter -f

# Rebuild and restart
docker compose up grok-adapter --build --force-recreate

πŸ”Œ Jubal Integration

Service Registration

Grok automatically registers with the Redis service registry on startup:

{
  "service": "grok-adapter",
  "version": "1.0.0",
  "host": "grok-adapter",
  "port": 8002,
  "health_endpoint": "/health",
  "capabilities": ["analyze", "extract", "summarize"]
}

Jubal Envelope Format

All processing requests follow the Jubal envelope contract:

{
  "job_id": "unique-job-identifier",
  "pipeline_id": "optional-pipeline-id",
  "data": {
    "type": "text/plain",
    "content": "transcript content here",
    "encoding": "utf-8"
  },
  "metadata": {
    "profile_id": "business_meeting",
    "overrides": {}
  },
  "trace": {}
}

Response Format

{
  "job_id": "unique-job-identifier",
  "status": "completed",
  "data": {
    "type": "application/json",
    "content": {
      "entities": {"people": ["John", "Jane"], "companies": ["Acme Corp"]},
      "summary": {"key_points": ["API requirements discussed"]},
      "processing_metadata": {"steps_completed": 3, "total_tokens": 150}
    },
    "encoding": "utf-8"
  },
  "error": null,
  "metadata": {
    "profile_id": "business_meeting",
    "timestamp": "2025-09-15T22:41:55.057669+00:00"
  }
}

πŸš€ Deployment

Production Deployment

# Build production image
docker compose build grok-adapter

# Deploy with resource limits
docker compose -f docker-compose.prod.yml up -d

# Health check
curl https://your-domain.com/health

Akash Network Deployment

(Coming in Phase 7)

# deploy.yml for Akash Network
version: "2.0"
services:
  grok:
    image: grok-adapter:latest
    expose:
      - port: 8002
        as: 80
        to:
          - global: true
profiles:
  compute:
    grok:
      resources:
        cpu:
          units: 1.0
        memory:
          size: 2Gi
        storage:
          size: 5Gi
  placement:
    akash:
      attributes:
        host: akash
      signedBy:
        anyOf:
          - "akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63"
      pricing:
        grok:
          denom: uakt
          amount: 1000
deployment:
  grok:
    akash:
      profile: grok
      count: 1

πŸ“š Documentation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

πŸ“„ License

This project is part of the Jubal Personal Operating System ecosystem. See the Jubal repository for licensing information.

πŸ”— Related Projects

  • Jubal Core - Personal Operating System framework
  • Recall - Audio processing and transcription adapter

πŸ“ž Support

For support and questions:

  • Open an issue in this repository
  • Check the Jubal documentation
  • Join the community discussions

Built with ❀️ for the Jubal ecosystem

About

AI-powered transcript analysis microservice for the Jubal ecosystem. Provides multi-step profile-based processing with local and cloud LLM integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •