Package: libre-chat
Libre ChatEasily configure and deploy afully self-hosted chatbot web servicebased on open source Large Language Models (LLMs), such asMixtralorLlama 2, without the need for knowledge in machine learning.🌐 Free and Open Source chatbot web service with UI and API🏡 Fully self-hosted, not tied to any service, and offline capable. Forget about API keys! Models and embeddings can be pre-downloaded, and the training and inference processes can run off-line if necessary.🔌 Web API described using OpenAPI specs: GET/POST operations, websocket for streaming response🪶 Chat web UI (Gradio-based, or custom HTML) working well on desktop and mobile, with streaming response, and markdown rendering🚀 Easy to setup, no need to program, just configure the service with aYAMLfile, and start it with 1 command📦 Available as apippackage 🐍, ordockerimage 🐳🐌 No need for GPU, this will work even on your laptop CPU! That said, just running on CPUs can be quite slow (up to 1min to answer a documents-base question on recent laptops).🦜 Powered byLangChainandllama.cppto perform inference locally.🤖 Various types of agents can be deployed:💬 Generic conversation: do not need any additional training, just configure settings such as the template prompt📚 Documents-based question answering(experimental): automatically build similarity vectors from documents uploaded through the API UI, the chatbot will use them to answer your question, and return which documents were used to generate the answer (PDF, CSV, HTML, JSON, markdown, and more supported).🔍 Readable logs to understand what is going on📖 DocumentationFor more details on how to use Libre Chat check the documentation atvemonet.github.io/libre-chat🏗️ Work in progress⚠️ This project is a work in progress, use it with cautionThose checkpoints are features we plan to work on in the future, feel free to let us know in the issues if you have any comment or request.Stream response to the websocket to show words as they are generatedAdd button to let the user stop the chatbot generationAdd an admin dashboard web UI to enable users to upload/inspect/delete documents for QA, see/edit the config of the chatbot. Migrate to solidjs or svelte with config retrieved from API?Kubernetes deployment (Helm chart?)Add authentication mechanisms? (OAuth/OpenID Connect)🐳 Deploy with dockerIf you just want to quickly deploy it using the pre-trained modelMixtral-8x7B-Instruct, you can use docker:dockerrun-it-p8000:8000ghcr.io/vemonet/libre-chat:mainYou can configure the deployment using environment variables. For this using adocker composeand a.envfile is easier, first create thedocker-compose.ymlfile:version:"3"services:libre-chat:image:ghcr.io/vemonet/libre-chat:mainvolumes:# ⚠️ Share folders from the current directory to the /data dir in the container-./chat.yml:/data/chat.yml-./models:/data/models-./documents:/data/documents-./embeddings:/data/embeddings-./vectorstore:/data/vectorstoreports:-8000:8000And create achat.ymlfile with your configuration in the same folder as thedocker-compose.yml:llm:model_path:./models/mixtral-8x7b-instruct-v0.1.Q2_K.ggufmodel_download:https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/resolve/main/mixtral-8x7b-instruct-v0.1.Q2_K.gguftemperature:0.01# Config how creative, but also potentially wrong, the model can be. 0 is safe, 1 is adventurousmax_new_tokens:1024# Max number of words the LLM can generateprompt:# Always use input for the human input variable with a generic agentvariables:[input,history]template:|Your are an assistant, please help me{history}User: {input}AI Assistant:vector:vector_path:null# Path to the vectorstore to do QA retrieval, e.g. ./vectorstore/db_faiss# Set to null to deploy a generic conversational agentvector_download:nullembeddings_path:./embeddings/all-MiniLM-L6-v2# Path to embeddings used to generate the vectors, or use directly from HuggingFace: sentence-transformers/all-MiniLM-L6-v2embeddings_download:https://public.ukp.informatik.tu-darmstadt.de/reimers/sentence-transformers/v0.2/all-MiniLM-L6-v2.zipdocuments_path:./documents# Path to documents to vectorizechunk_size:500# Maximum size of chunks, in terms of number of characterschunk_overlap:50# Overlap in characters between chunkschain_type:stuff# Or: map_reduce, reduce, map_rerank. More details: https://docs.langchain.com/docs/components/chains/index_related_chainssearch_type:similarity# Or: similarity_score_threshold, mmr. More details: https://python.langchain.com/docs/modules/data_connection/retrievers/vectorstorereturn_sources_count:2# Number of sources to return when generating an answerscore_threshold:null# If using the similarity_score_threshold search type. Between 0 and 1info:title:"LibreChat"version:"0.1.0"description:|Open source and free chatbot powered by [LangChain](https://python.langchain.com) and [llama.cpp](https://github.com/ggerganov/llama.cpp)See also: [📡 API](/docs) | [🖥️ Alternative UI](/ui)examples:-What is the capital of the Netherlands?-Which drugs are approved by the FDA to mitigate Alzheimer symptoms?-How can I create a logger with timestamp using python logging?favicon:https://raw.github.com/vemonet/libre-chat/main/docs/docs/assets/logo.pngrepository_url:https://github.com/vemonet/libre-chatpublic_url:https://chat.semanticscience.orgcontact:name:Vincent Emonetemail:vincent.emonet@gmail.comlicense_info:name:MIT licenseurl:https://raw.github.com/vemonet/libre-chat/main/LICENSE.txtFinally start your chat service with:dockercomposeup📦️ Usage with pipThis package requires Python >=3.8, simply install it withpipxorpip:pipinstalllibre-chat⌨️ Use as a command-line interfaceYou can easily start a new chat web service including UI and API using your terminal:libre-chatstartProvide a specific config file:libre-chatstartconfig/chat-vectorstore-qa.ymlFor re-build of the vectorstore:libre-chatbuild--vectorvectorstore/db_faiss--documentsdocumentsGet a full rundown of the available options with:libre-chat--help🐍 Use with pythonOr you can use this package in python scripts:importloggingimportuvicornfromlibre_chatimportChatConf,ChatEndpoint,Llmlogging.basicConfig(level=logging.getLevelName("INFO"))conf=ChatConf(model_path="./models/mixtral-8x7b-instruct-v0.1.Q2_K.gguf",vector_path=None)llm=Llm(conf=conf)print(llm.query("What is the capital of the Netherlands?"))# Create and deploy a FastAPI app based on your LLMapp=ChatEndpoint(llm=llm,conf=conf)uvicorn.run(app)🤝 CreditsInspired by:https://github.com/kennethleungty/Llama-2-Open-Source-LLM-CPU-Inferencehttps://github.com/lm-sys/FastChathttps://github.com/liltom-eth/llama2-webuiLlama icons created by Freepik - Flaticon