This project implements a custom knowledge chatbot integrated with a Telegram bot. You can easily add PDF or text documents to a dedicated folder within the repository. During application initialization, these documents will be processed and embedded into a vector database for efficient querying. Once set up, you can chat with the Telegram bot and receive responses generated by the LLM (Large Language Model) based on the custom knowledge you've provided.
Clone the repository
git clone https://github.com/KLxLee/LLM_chatbot
Change the directory
cd LLM_chatbot
Create the .env
file for environment variables:
touch .env
To reduce server hardware requirements, a local AI model is not implemented in this project.
- Create an OpenAI account and obtain the API key. You can find the instructions here:
How to Get OpenAI Access Token. - Define your OpenAI API key in the
.env
file with the variable nameOPENAI_API_KEY
:echo 'OPENAI_API_KEY=<your_key>' >> .env
NGROK is a cross-platform tool that allows developers to expose a local development server to the internet easily.
For users who prefer not to set up a cloud server, NGROK can be used to expose a public port.
- Set up a free NGROK account.
- Define your NGROK authentication key in the
.env
file with the variable nameNGROK_AUTH_TOKEN
:echo 'NGROK_AUTH_TOKEN=<your_token>' >> .env
- Create a Telegram bot and obtain the bot authentication key. Follow these tutorials:
- Define your Telegram Bot API key in the
.env
file with the variable nameTELEGRAM_API_KEY
:echo 'TELEGRAM_API_KEY=<your_key>' >> .env
- Under the
LLM_chatbot/knowledge_docs
directory, there are two folders:pdf_docs
andtxt_docs
. - Add your text and PDF documents to the corresponding folders.
- You can skip this step if you do not want to add any documents for custom knowledge.
- Build and run the containers:
or
docker compose up
docker-compose up
- It may take some time to build the containers and embed the data into the vector store.
- After the application is running, you can start chatting with the Telegram bot and ask questions based on the custom knowledge provided.
- If you use the example knowledge files provided, you can ask questions like:
- "Summary about The Adventures of Sir Aldric"
- "Moral of the story The Tale of Prince John"
- "Please tell me about the IKEA light manual"
- Conversation History: Keep track of the conversation history with the bot.
- Custom System Prompt: Implement custom system prompts for better conversation control.
- Fixed the spelling of Preresique to Prerequisites.
- Added consistency with how environment variables are defined in
.env
file (>>
for appending). - Minor rephrasing for better readability and clarity.