LongTrainer 1.0.0 — Production-Ready RAG Framework
Multi-tenant bots, streaming, tools, and persistent memory — all batteries included.
Welcome to LongTrainer 1.0.0
LongTrainer is a production-ready RAG framework that turns your documents into intelligent, multi-tenant chatbots with minimal code. Built on top of LangChain, it handles multi-bot isolation, persistent MongoDB memory, FAISS vector search, streaming responses, custom tool calling, chat encryption, and vision support.
Quick Start
Install LongTrainer and start building in minutes:
pip install longtrainer
RAG Mode (Default)
from longtrainer.trainer import LongTrainer
import os
os.environ["OPENAI_API_KEY"] = "sk-..."
trainer = LongTrainer(mongo_endpoint="mongodb://localhost:27017/")
bot_id = trainer.initialize_bot_id()
trainer.add_document_from_path("data.pdf", bot_id)
trainer.create_bot(bot_id)
chat_id = trainer.new_chat(bot_id)
answer, sources = trainer.get_response("What is this about?", bot_id, chat_id)
print(answer)
Agent Mode (With Tools)
from longtrainer.tools import web_search
from langchain_core.tools import tool
@tool
def calculate(expression: str) -> str:
"""Evaluate a math expression."""
return str(eval(expression))
trainer.add_tool(web_search, bot_id)
trainer.add_tool(calculate, bot_id)
trainer.create_bot(bot_id, agent_mode=True)
chat_id = trainer.new_chat(bot_id)
answer, _ = trainer.get_response("What is 42 * 17?", bot_id, chat_id)
What's New in 1.0.0
- Dual Mode: RAG (LCEL) for simple Q&A, Agent (LangGraph) for tool calling
- Streaming Responses: Sync and async out of the box
- Custom Tool Calling:
add_tool()with any LangChain@tool - Per-Bot Customization: Independent LLM, embeddings, and retrieval config per bot
- Chat Encryption: Fernet encryption for stored conversations
Upgrading from 0.3.4? See the Migration Guide.
Documentation
| Guide | Description |
|---|---|
| Installation | Install LongTrainer and system dependencies |
| Creating an Instance | Configure the LongTrainer class |
| Creating and Using a Bot | Bot lifecycle: create, load, chat |
| Agent Mode & Tools | Tool calling, streaming, agent configuration |
| Chat Management | Sessions, history, training on chats |
| Supported Formats | Document types and ingestion methods |
| Integrating LLMs | Use any LangChain-compatible LLM |
| Integrating Embeddings | Custom embedding models |
| Updating Bots | Add documents and reconfigure bots |
| Deleting Bots | Remove bots and associated data |
| Migration 0.3.4 → 1.0.0 | Breaking changes and upgrade path |