libre-chat
ðĶ Free and Open Source Large Language Model (LLM) chatbot web UI and API. Self-hosted, offline capable and easy to setup.
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
âCITATION.cff file
Found CITATION.cff file -
âcodemeta.json file
Found codemeta.json file -
â.zenodo.json file
Found .zenodo.json file -
âDOI references
-
âAcademic publication links
Links to: science.org -
âCommitters with academic emails
-
âInstitutional organization owner
-
âJOSS paper metadata
-
âScientific vocabulary similarity
Low similarity (16.4%) to scientific vocabulary
Keywords
Repository
ðĶ Free and Open Source Large Language Model (LLM) chatbot web UI and API. Self-hosted, offline capable and easy to setup.
Basic Info
- Host: GitHub
- Owner: vemonet
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://vemonet.github.io/libre-chat
- Size: 4.32 MB
Statistics
- Stars: 161
- Watchers: 5
- Forks: 21
- Open Issues: 6
- Releases: 6
Topics
Metadata Files
README.md
- ð 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 working well on desktop and mobile, with streaming response, and markdown rendering. Alternative gradio-based UI also available.
- ð Easy to setup, no need to program, just configure the service with a YAML file, and start it with 1 command
- ðĶ Available as a
pippackage ð, 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 by
LangChainandllama.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.
ð Documentation
For more details on how to use Libre Chat check the documentation at vemonet.github.io/libre-chat


ðïļ Work in progress
[!WARNING] This project is a work in progress, use it with caution.
Those 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.
- [x] Stream response to the websocket to show words as they are generated
- [ ] Add button to let the user stop the chatbot generation
- [ ] Add authentication mechanisms? (OAuth/OpenID Connect) https://github.com/vemonet/libre-chat/issues/5
- [ ] Add conversational history? https://milvus.io/blog/conversational-memory-in-langchain.md
- [ ] Add an admin dashboard web UI to enable users to upload/inspect/delete documents for QA, see/edit the config of the chatbot.
- [ ] Kubernetes deployment (Helm chart?)
ðģ Deploy with docker
If you just want to quickly deploy it using the pre-trained model Mixtral-8x7B-Instruct, you can use docker:
bash
docker run -it -p 8000:8000 ghcr.io/vemonet/libre-chat:main
You can configure the deployment using environment variables. For this using a docker compose and a .env file is easier, first create the docker-compose.yml file:
yaml
version: "3"
services:
libre-chat:
image: ghcr.io/vemonet/libre-chat:main
volumes:
# â ïļ 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/vectorstore
ports:
- 8000:8000
And create a chat.yml file with your configuration in the same folder as the docker-compose.yml:
```yaml llm: modelpath: ./models/mixtral-8x7b-instruct-v0.1.Q2K.gguf modeldownload: https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/resolve/main/mixtral-8x7b-instruct-v0.1.Q2K.gguf temperature: 0.01 # Config how creative, but also potentially wrong, the model can be. 0 is safe, 1 is adventurous maxnewtokens: 1024 # Max number of words the LLM can generate # Always use input for the human input variable with a generic agent promptvariables: [input, history] prompttemplate: | Your are an assistant, please help me
{history}
User: {input}
AI Assistant:
vector: vectorpath: null # Path to the vectorstore to do QA retrieval, e.g. ./vectorstore/dbfaiss # Set to null to deploy a generic conversational agent vectordownload: null embeddingspath: ./embeddings/all-MiniLM-L6-v2 # Path to embeddings used to generate the vectors, or use directly from HuggingFace: sentence-transformers/all-MiniLM-L6-v2 embeddingsdownload: https://public.ukp.informatik.tu-darmstadt.de/reimers/sentence-transformers/v0.2/all-MiniLM-L6-v2.zip documentspath: ./documents # Path to documents to vectorize chunksize: 500 # Maximum size of chunks, in terms of number of characters chunkoverlap: 50 # Overlap in characters between chunks chaintype: stuff # Or: mapreduce, reduce, maprerank. More details: https://docs.langchain.com/docs/components/chains/indexrelatedchains searchtype: similarity # Or: similarityscorethreshold, mmr. More details: https://python.langchain.com/docs/modules/dataconnection/retrievers/vectorstore returnsourcescount: 2 # Number of sources to return when generating an answer scorethreshold: null # If using the similarityscorethreshold search type. Between 0 and 1
info: title: "Libre Chat" version: "0.1.0" description: | Open source and free chatbot powered by LangChain and llama.cpp 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.png repositoryurl: https://github.com/vemonet/libre-chat publicurl: https://chat.semanticscience.org contact: name: Vincent Emonet email: vincent.emonet@gmail.com license_info: name: MIT license url: https://raw.github.com/vemonet/libre-chat/main/LICENSE.txt ```
Finally start your chat service with:
bash
docker compose up
ðĶïļ Usage with pip
This package requires Python >=3.8, simply install it with pipx or pip:
bash
pip install libre-chat
âĻïļ Use as a command-line interface
You can easily start a new chat web service including UI and API using your terminal:
bash
libre-chat start
Provide a specific config file:
bash
libre-chat start config/chat-vectorstore-qa.yml
For re-build of the vectorstore:
bash
libre-chat build --vector vectorstore/db_faiss --documents documents
Get a full rundown of the available options with:
bash
libre-chat --help
ð Use with python
Or you can use this package in python scripts:
```python import logging
import uvicorn from libre_chat import ChatConf, ChatEndpoint, Llm
logging.basicConfig(level=logging.getLevelName("INFO")) conf = ChatConf( modelpath="./models/mixtral-8x7b-instruct-v0.1.Q2K.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 LLM
app = ChatEndpoint(llm=llm, conf=conf) uvicorn.run(app) ```
ðĪ Credits
Inspired by:
- https://github.com/kennethleungty/Llama-2-Open-Source-LLM-CPU-Inference
- https://github.com/lm-sys/FastChat
- https://github.com/liltom-eth/llama2-webui
Owner
- Name: Vincent Emonet
- Login: vemonet
- Kind: user
- Location: Maastricht, Netherlands
- Company: @MaastrichtU-IDS
- Website: https://vemonet.github.io
- Repositories: 203
- Profile: https://github.com/vemonet
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- orcid: https://orcid.org/0000-0002-1501-1082
email: vincent.emonet@gmail.com
given-names: Vincent Emonet
# affiliation: Institute of Data Science, Maastricht University
title: "Libre Chat"
repository-code: https://github.com/vemonet/libre-chat
date-released: 2023-07-26
url: https://pypi.org/project/libre-chat
# doi: 10.48550/arXiv.2206.13787
GitHub Events
Total
- Issues event: 1
- Watch event: 34
- Issue comment event: 2
- Push event: 1
- Pull request event: 1
- Fork event: 5
Last Year
- Issues event: 1
- Watch event: 34
- Issue comment event: 2
- Push event: 1
- Pull request event: 1
- Fork event: 5
Committers
Last synced: 6 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Vincent Emonet | v****t@g****m | 232 |
| jxfzzzt | 1****5@q****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 9
- Total pull requests: 1
- Average time to close issues: 2 months
- Average time to close pull requests: 4 months
- Total issue authors: 9
- Total pull request authors: 1
- Average comments per issue: 1.67
- Average comments per pull request: 2.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 1
- Average time to close issues: 4 months
- Average time to close pull requests: 4 months
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 2.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- GuoqiangJia (1)
- bw-Deejee (1)
- develperbayman (1)
- djhaskin987 (1)
- MrBean2016 (1)
- barshag (1)
- jxfzzzt (1)
- de-illusionist (1)
- bolavefasfas (1)
Pull Request Authors
- jxfzzzt (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 86 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
- Total advisories: 1
pypi.org: libre-chat
Free and Open Source Large Language Model (LLM) chatbot web UI and API. Self-hosted, offline capable and easy to setup. Powered by LangChain and Llama 2.
- Homepage: https://github.com/vemonet/libre-chat
- Documentation: https://github.com/vemonet/libre-chat
- License: MIT License Copyright (c) 2023-present Vincent Emonet <vincent.emonet@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 0.0.6
published about 2 years ago
Rankings
Maintainers (1)
Advisories (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- coverallsapp/github-action v2 composite
- github/codeql-action/analyze v2 composite
- github/codeql-action/autobuild v2 composite
- github/codeql-action/init v2 composite
- ${BASE_IMAGE} latest build
- ctransformers >=0.2.5
- faiss-cpu >=1.7.4
- fastapi *
- gradio *
- gunicorn *
- langchain *
- sentence_transformers *
- typer >=0.6.0
- uvicorn *
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- @fontsource/fira-mono ^4.5.10 development
- @neoconfetti/svelte ^1.0.0 development
- @playwright/test ^1.28.1 development
- @sveltejs/adapter-auto ^2.0.0 development
- @sveltejs/adapter-static ^2.0.3 development
- @sveltejs/kit ^1.20.4 development
- @types/cookie ^0.5.1 development
- @typescript-eslint/eslint-plugin ^5.45.0 development
- @typescript-eslint/parser ^5.45.0 development
- autoprefixer ^10.4.14 development
- eslint ^8.28.0 development
- eslint-config-prettier ^8.5.0 development
- eslint-plugin-svelte ^2.30.0 development
- postcss ^8.4.27 development
- prettier ^2.8.0 development
- prettier-plugin-svelte ^2.10.1 development
- svelte ^4.0.5 development
- svelte-check ^3.4.3 development
- tailwindcss ^3.3.3 development
- tslib ^2.4.1 development
- typescript ^5.0.0 development
- vite ^4.4.2 development
- vitest ^0.32.2 development
- @fortawesome/fontawesome-free ^6.4.2
- marked ^7.0.0
- 123 dependencies
- 924 dependencies