Falko Victor Habel febdf30355 | ||
---|---|---|
config | ||
scripts | ||
tests | ||
theme | ||
.gitignore | ||
LICENSE | ||
README.md | ||
project.py | ||
requirements.txt | ||
test_project.py |
README.md
Fabelous-Ai-Chat
Video Demo: https://youtu.be/A5mtqQLF000
Description:
This is my Final Project for CS50P. A implementation of a RAG System using Chroma DB and Ollama for the backend, along with customtkinter for the frontend.
Features
- Custom GUI built with customtkinter and standard tkinter user interface.
- optional
terminal
mode, with nice colors provided by thetermcolor
libary
- optional
- RAG system to retrieve and process files from various sources (CSV, HTML, MD, PDF and Webpages) using ChromaDB.
- Seamless integration with Ollama API for generating responses based on the input text.
- Supports both context-based and context-free conversations.
- Code Highlighting: Either highlighted in red within the
terminal
or displayed in a separate widget using theGUI
, this improves the readability and understanding of code snippets
Installation
- Clone the repository or download the project files from:
https://gitea.fabelous.app/fabel/Fabelous-Ai-Chat
- Install required dependencies by running:
pip install -r requirements.txt
- To run this project properly, you will need to ensure that the Python 3 and Tkinter libraries arei nstalled.
- For MacOS users who have installed Python 3 via Homebrew, use the following command in your terminal:
brew install python-tk
- For Linux users, execute the following command in your terminal:
apt-get install python3-tk
Configuration
Please note that you need access to an Ollama instance with both embeddings model and chat model to use this interface effectively. Ensure that you have set up your instance accordingly before configuring this application.
To configure the Fabelous-Ai-Chat, run the following command and answer the prompts accordingly:
python project.py --config
If you just want to switch for example from GUI
to terminal
version type:
python project.py -m terminal
During configuration, you'll be prompted to enter the following information:
- Mode:
gui
orterminal
- Base Ollama URL for the LLM e.g.:
http://localhost:11434
- Base Ollama URL for embeddings e.g.:
http://localhost:11434
- The base model name e.g:
mistral
- The base embeddings model name e.g:
mxbai-embed-large
- Authentication headers for base and embeddings models (if required)
- a Authentication could look like this:
{"Authorization": "Token xzy"}
- a Authentication could look like this:
After providing this information, your configuration file will be saved in the config
folder as config.json
.
Usage in Terminal Mode
To use the Fabelous-Ai-Chat in terminal mode, run the following command and provide a prompt:
python project.py -p "Your prompt here"
You can also provide an input file/link using the -f option:
python project.py -p "Your prompt here" -f "path/to/yourfile.csv"
Usage in GUI Mode
To use the Fabelous-Ai-Chat in GUI mode, simply run the following command:
python project.py
Supported files
You can provide the following files / links as context to Ollama:
- .csv
- .html
- .md
- links (Note that only SSL-secured websites are supported)
How the Rag is working in the GUI:
The RAG is designed to create conversational agents that leverage external sources for more accurate responses. The Rag
class in Rag.py
plays a crucial role in this process. When a user submits a message through the chat interface, the get_response_from_ollama
method comes into play. This method checks for any context associated with the message and processes it if required.
If necessary, it calls the receive_data
method of the Rag
instance to handle new context and fetch relevant data using the get_file
method. The fetched content is then added to a database, which is not persistent. If you close it, you will lose the data. Following that, the get_request
method of the Rag instance is called with the user's message as input. It generates a response, utilizing the contents of the Chroma DB for better accuracy, with the selected model from the Ollama instance.
For better results, the last five responses are featured in the context, if no other context is provided.
Difference to terminal mode:
In terminal
mode, context is provided through command-line arguments as a single file. This approach has its limitations, as it only allows for a single context file during a conversation, restricting versatility when dealing with diverse contexts.
License
Fabelous-Ai-Chat
is made available under the MIT license. For more details, please refer to the LICENSE file included in the distribution.
This project uses the models from Mistral AI and Mixedbread.ai as standard, which are made available under the Apache 2.0 license. For more details, check out there model pages on Ollama: Mistral and mxbai-embed-large. This project also uses ChromaDB as the vector database. It is also available under the Apache 2.0 License. For more information checkout it's GitHub Page.