Universal LLM adapter service for Sekha AI - Multi-provider bridge supporting 100+ LLMs via LiteLLM
Project description
Sekha LLM Bridge
Universal LLM Adapter - The Bridge Between Memory and Intelligence
๐ฏ What is Sekha LLM Bridge?
LLM-Bridge is a REQUIRED component of the Sekha ecosystem. It acts as the universal adapter layer that enables the Sekha Controller to work with any LLM provider - from local Ollama to cloud services like OpenAI, Anthropic, and Google.
Why is it Required?
The Controller (Rust) focuses on memory orchestration, storage, and retrieval. LLM-Bridge (Python) handles all LLM-specific operations, providing:
- Provider Abstraction: Switch between Ollama, GPT-4, Claude, Gemini without changing Controller code
- Universal Compatibility: Powered by LiteLLM for 100+ LLM providers
- Async Processing: Celery-based task queue for expensive LLM operations
- Retry Logic: Automatic retries with exponential backoff for reliability
- Type Safety: Pydantic models for request/response validation
๐๏ธ Architecture Role
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Sekha Controller (Rust) โ
โ โข Memory Orchestration โ
โ โข Context Assembly โ
โ โข Storage (SQLite + Chroma) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP Calls
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LLM-Bridge (Python) โ YOU ARE HERE โ
โ โข Universal LLM Adapter โ
โ โข Embedding Generation โ
โ โข Summarization โ
โ โข Entity Extraction โ
โ โข Importance Scoring โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LiteLLM
โผ
โโโโโโโโโโโโดโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ
โ Ollama โ โ OpenAI โ
โ (Local) โ โ GPT-4 โ
โโโโโโโโโโโ โโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ
โAnthropicโ โ Google โ
โ Claude โ โ Gemini โ
โโโโโโโโโโโ โโโโโโโโโโโโ
Multi-LLM Workflow Example:
- Morning: Use Claude for code review โ Sekha captures via Bridge
- Afternoon: Switch to ChatGPT for docs โ Bridge forwards to OpenAI
- Evening: Use Ollama locally for planning โ Bridge uses local LLM
- All stored in unified sekha.db regardless of which LLM was used!
โจ Features
Core Services
| Endpoint | Purpose | Used By |
|---|---|---|
POST /embed |
Generate embeddings for semantic search | Controller (on conversation storage) |
POST /summarize |
Hierarchical summarization (daily/weekly/monthly) | Controller orchestrator |
POST /extract |
Extract entities from conversations | Controller (future: auto-labeling) |
POST /score |
Score conversation importance (1-10) | Controller pruning engine |
POST /v1/chat/completions |
OpenAI-compatible chat endpoint | Proxy (optional component) |
Current Capabilities
- โ Ollama Integration: Full support for local LLMs
- โ LiteLLM Powered: Ready for 100+ providers (OpenAI, Anthropic, etc.)
- โ Async Processing: Celery task queue for background jobs
- โ Retry Logic: 3 retries with exponential backoff
- โ
Health Monitoring:
/healthendpoint with model availability checks - โ
Prometheus Metrics:
/metricsfor observability
Supported LLM Providers (via LiteLLM)
Currently Tested:
- Ollama (nomic-embed-text, llama3.1, etc.)
Ready to Enable:
- OpenAI (GPT-4, GPT-3.5-turbo, text-embedding-ada-002)
- Anthropic (Claude 3 Opus, Sonnet, Haiku)
- Google (Gemini Pro, Gemini Flash)
- Cohere (Command, Embed)
- Azure OpenAI
- AWS Bedrock
- 100+ more via LiteLLM
๐ Quick Start
Installation
# From PyPI (recommended)
pip install sekha-llm-bridge
# Or from source
git clone https://github.com/sekha-ai/sekha-llm-bridge.git
cd sekha-llm-bridge
pip install -e .
With Docker (Full Stack)
LLM-Bridge is included in the full Sekha stack:
git clone https://github.com/sekha-ai/sekha-docker.git
cd sekha-docker/docker
cp .env.example .env
# Edit .env to configure your LLM provider
nano .env
docker compose -f docker-compose.prod.yml up -d
Standalone Development
# Configure (copy and edit)
cp .env.example .env
# Start Redis (required for Celery)
docker run -d -p 6379:6379 redis:7-alpine
# Run
python -m sekha_llm_bridge.main
โ๏ธ Configuration
Environment Variables
# Server
HOST=0.0.0.0
PORT=5001
# Ollama (local LLMs)
OLLAMA_URL=http://localhost:11434
EMBEDDING_MODEL=nomic-embed-text:latest
SUMMARIZATION_MODEL=llama3.1:8b
# Redis (Celery task queue)
REDIS_URL=redis://localhost:6379/0
# Cloud Providers (optional)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
# Logging
LOG_LEVEL=INFO
Using Different LLM Providers
Switch to OpenAI:
EMBEDDING_MODEL=text-embedding-3-small
SUMMARIZATION_MODEL=gpt-4o-mini
OPENAI_API_KEY=sk-...
Switch to Claude:
SUMMARIZATION_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_API_KEY=sk-ant-...
LiteLLM automatically routes to the correct provider based on model name!
๐ก API Reference
POST /embed
Generate embedding for text.
Request:
{
"text": "What is the meaning of life?",
"model": "nomic-embed-text:latest" // optional
}
Response:
{
"embedding": [0.123, -0.456, ...], // 768-dim vector
"model": "nomic-embed-text:latest",
"dimension": 768,
"tokens_used": 42
}
POST /summarize
Generate hierarchical summary.
Request:
{
"messages": [
"User discussed Python best practices",
"Assistant recommended type hints"
],
"level": "daily", // daily | weekly | monthly
"model": "llama3.1:8b", // optional
"max_words": 200
}
Response:
{
"summary": "Discussed Python type hints and best practices...",
"level": "daily",
"model": "llama3.1:8b",
"message_count": 2,
"tokens_used": 156
}
POST /v1/chat/completions
OpenAI-compatible chat endpoint.
Request:
{
"model": "llama3.1:8b",
"messages": [
{"role": "user", "content": "Hello!"}
]
}
Response: Standard OpenAI format
๐ง Development
Setup
# Install dev dependencies
pip install -e ".[dev]"
# Or with Poetry
poetry install --with dev
Testing
# Run tests
pytest
# With coverage
pytest --cov=sekha_llm_bridge --cov-report=html
# Type checking
mypy src/
# Linting
ruff check .
black --check .
Project Structure
sekha-llm-bridge/
โโโ src/
โ โโโ sekha_llm_bridge/
โ โโโ main.py # FastAPI app
โ โโโ config.py # Settings
โ โโโ models.py # Pydantic models
โ โโโ tasks.py # Celery tasks
โ โโโ services/
โ โ โโโ embedding_service.py
โ โ โโโ summarization_service.py
โ โ โโโ entity_extraction_service.py
โ โ โโโ importance_scorer.py
โ โโโ utils/
โ โโโ llm_client.py # LiteLLM wrapper
โโโ tests/
โโโ requirements.txt
โโโ pyproject.toml
๐ค Integration with Controller
The Controller calls LLM-Bridge for:
-
Embedding Generation: When storing new conversations
let embedding = llm_bridge.embed_text(&message_content).await?;
-
Summarization: For hierarchical summaries
let summary = llm_bridge.summarize(messages, "daily").await?;
-
Importance Scoring: For pruning decisions
let score = llm_bridge.score_importance(&message).await?;
All operations are async and include automatic retries.
๐ Monitoring
Health Check
curl http://localhost:5001/health
Response:
{
"status": "healthy",
"timestamp": "2026-01-25T20:00:00Z",
"ollama_status": {
"status": "healthy",
"models_available": ["nomic-embed-text:latest", "llama3.1:8b"]
}
}
Prometheus Metrics
curl http://localhost:5001/metrics
๐ Changelog
See CHANGELOG.md for full release history.
๐บ๏ธ Roadmap
Q1 2026
- Ollama integration
- LiteLLM foundation
- OpenAI production testing
- Anthropic Claude integration
- Google Gemini support
Q2 2026
- Multi-provider load balancing
- Cost tracking per provider
- Custom model fine-tuning support
- Streaming responses
๐ Related Projects
- sekha-controller - Memory orchestration (Rust)
- sekha-proxy - Transparent LLM proxy (optional)
- sekha-mcp - MCP server for Claude Desktop
- sekha-docker - Full stack deployment
๐ Documentation
Full docs: docs.sekha.dev
๐ License
AGPL-3.0-or-later - License Details
๐ Support
- Issues: GitHub Issues
- Discord: Join our Discord
- Email: dev@sekha-ai.dev
Built with โค๏ธ by the Sekha AI team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sekha_llm_bridge-0.2.0.tar.gz.
File metadata
- Download URL: sekha_llm_bridge-0.2.0.tar.gz
- Upload date:
- Size: 55.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7992488681e093e428656db207f84645f17a5ec3e8f24234ebdccec3f16376a3
|
|
| MD5 |
36ee17dd39cee37cc700f5e32ff104e0
|
|
| BLAKE2b-256 |
5d8d14dc5204b6e01c0959fae1088a0e622212a37135de6900fcef4f6eb75d6d
|
Provenance
The following attestation bundles were made for sekha_llm_bridge-0.2.0.tar.gz:
Publisher:
pypi-release.yml on sekha-ai/sekha-llm-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sekha_llm_bridge-0.2.0.tar.gz -
Subject digest:
7992488681e093e428656db207f84645f17a5ec3e8f24234ebdccec3f16376a3 - Sigstore transparency entry: 955947099
- Sigstore integration time:
-
Permalink:
sekha-ai/sekha-llm-bridge@b276c05562135d95c6ef2a98d2ee9dd169cef587 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/sekha-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@b276c05562135d95c6ef2a98d2ee9dd169cef587 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sekha_llm_bridge-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sekha_llm_bridge-0.2.0-py3-none-any.whl
- Upload date:
- Size: 64.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d79beb71d7640576fb529dde536345b4aeb6b7736ed581114dcb232e5047057c
|
|
| MD5 |
5e69a2765770a87400bb4558c5a8ca4c
|
|
| BLAKE2b-256 |
9d079e4f4dc54575875011b237dbde197458aa566c919d1bbaa6108767526b45
|
Provenance
The following attestation bundles were made for sekha_llm_bridge-0.2.0-py3-none-any.whl:
Publisher:
pypi-release.yml on sekha-ai/sekha-llm-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sekha_llm_bridge-0.2.0-py3-none-any.whl -
Subject digest:
d79beb71d7640576fb529dde536345b4aeb6b7736ed581114dcb232e5047057c - Sigstore transparency entry: 955947107
- Sigstore integration time:
-
Permalink:
sekha-ai/sekha-llm-bridge@b276c05562135d95c6ef2a98d2ee9dd169cef587 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/sekha-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@b276c05562135d95c6ef2a98d2ee9dd169cef587 -
Trigger Event:
push
-
Statement type: