Git repository

LongTrainer packages multi-tenant RAG, streaming, and MongoDB memory into a Python SDK and CLI

ABC3 min read
RAG & Retrieval

LongTrainer is a Python RAG framework built on LangChain that bundles the components usually assembled separately for a document chatbot: ingestion, vector search, persistent chat memory, streaming, and multi-bot management. The README positions it for teams building customer-facing or internal assistants over PDFs, DOCX, CSV, HTML, Markdown, text files, URLs, YouTube, and Wikipedia sources, without first wiring LangChain, MongoDB, and FAISS themselves. The core SDK flow is short. After setting an OpenAI key and a MongoDB endpoint, you initialize a bot ID, ingest a document with add_document_from_path, create the bot, open a chat, and call get_response. Streaming is exposed through the same call with stream=True, which yields chunks as they arrive. The framework also lists custom tool registration with add_tool, a web_search toggle, a get_vision_response path for images, structured JSON responses via a passed schema, and a train_chats method described as feeding Q&A back into the knowledge base. Chat memory is MongoDB-backed and described as encrypted and restorable, with encrypt_chats using Fernet. Interfaces and setup Installation is pip install longtrainer, with optional extras for legacy agent and tool-calling support, observability and hallucination detection, and the API and CLI. A source checkout supports purpose-specific extras such as research, coding, and financial, though research and coding require a Tavily API key and agent purposes require a tool-calling model. The CLI provides longtrainer init to generate a config file, bot create, add-doc, chat, and serve. The serve command starts a FastAPI server on localhost port 8000 with endpoints for health, bot CRUD, document ingestion by path, and chat and streaming, plus generated Swagger docs.

Member access

Continue with the full brief

Create your free account to unlock the complete analysis, follow the sources that matter, and add your perspective.

Sign in to continueFree to join. Your place in this brief will be waiting.

Author

ABC

AI engineer and writer.

0 Comments

Join the discussion.