Skip to content

leebeanbin/beanllm

Repository files navigation

🇰🇷 한국어

beanllm

Unified LLM framework supporting reasoning models, VLM-OCR, GraphRAG, and agentic workflows — 8 providers, 80% test coverage

PyPI version Python 3.10+ License: MIT Tests Coverage 80%


Why beanllm?

LangChain LlamaIndex beanllm
Architecture Flat chain Index-centric Clean Architecture (Facade → Handler → Service → Domain)
Reasoning Models Manual config Manual config thinking_budget native support
VLM-OCR Not supported Not supported 11 engines + Qwen3-VL / GLM-OCR / DeepSeek-VL2
GraphRAG Plugin Plugin KnowledgeGraph Facade built-in
Test Coverage 80% (6,340 tests)
ORPO Fine-tuning Not supported Not supported Native support (50% less memory than DPO)
Providers OpenAI-heavy OpenAI-heavy 8 providers including Grok/xAI

Used in Production

beanllm is the AI infrastructure layer for careerOS, a production career platform (Spring Boot 3.3, 14 domains, 415 tests):

Use Case Model Volume
Resume structured extraction gpt-4o-mini Per upload
Job posting normalization gpt-4o-mini Batch, 7 collectors
Advisor skill-gap report gpt-4o On-demand
Match narrative generation gpt-4o Daily digest
Candidate graph embeddings text-embedding-3-small (1536-dim) Per graph rebuild

careerOS routes all AI calls through beanllm's unified interface. Setting app.ai.provider: mock swaps in stub responses — enabling all 415 tests to run without any live API calls.


Quick Start

pip install beanllm[openai]        # or [anthropic], [gemini], [all]
import asyncio
from beanllm import Client

async def main():
    client = Client(model="gpt-4o")
    response = await client.chat(
        messages=[{"role": "user", "content": "Explain quantum computing"}]
    )
    print(response.content)

asyncio.run(main())
from beanllm import RAGChain

rag = RAGChain.from_documents("docs/")
result = await rag.query("What is this about?", include_sources=True)

Providers

Provider Install Env var
OpenAI beanllm[openai] OPENAI_API_KEY
Claude (Anthropic) beanllm[anthropic] ANTHROPIC_API_KEY
Gemini (Google) beanllm[gemini] GEMINI_API_KEY
Grok / xAI beanllm[all] XAI_API_KEY
DeepSeek beanllm[all] DEEPSEEK_API_KEY
Perplexity beanllm[all] PERPLEXITY_API_KEY
Ollama (local) beanllm (built-in) OLLAMA_HOST (optional)
HuggingFace beanllm[all] HUGGINGFACE_API_KEY

Provider auto-selection, CircuitBreaker, and rate limiting: wiki/providers.md


Capabilities

Module Highlights
LLM Providers 8 providers, unified interface, ModelParameterStrategy auto-adapts per-model params
Reasoning Models Native thinking_budget for Claude/OpenAI o-series; <thinking> token filtering
RAG Pipeline Document loaders, 8 vector stores, hybrid search, HyDE, MultiQuery, rerankers
GraphRAG KnowledgeGraph Facade — NER, relation extraction, Neo4j, relationship-aware retrieval
VLM-OCR 11 engines (PaddleOCR, Qwen3-VL, GLM-OCR, DeepSeek-VL2); 3-layer PDF processing
Fine-tuning LoRA/QLoRA, DPO, ORPO (50% less memory vs DPO), KTO
Multi-Agent Sequential, parallel, hierarchical, debate patterns; DAG graph workflows
MCP Server Model Context Protocol server for tool integration

Documentation

Architecture Clean Architecture layers, request flow diagram
Providers Setup, CircuitBreaker state machine, rate limiting
Facade API Client, RAGChain, Agent usage guide
API Reference Full endpoint specs (client, agent, models, RAG)
Decision Log 3 architectural decisions
Playbooks CircuitBreaker / rate limit incident runbooks

About

Production-ready LLM toolkit with unified interface for multiple providers (OpenAI, Anthropic, Google, Ollama)

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors