Code for a Telegram bot ? specialiced on Pytorch LLM powered
This project aims to simulate a text mesagge chatbot to chat about Pytorch
In this streamlined architecture, the Chatbot History serves as the central repository of the interaction history, supporting both the retrieval of historical context and the logging of new interactions, including full responses from the LLM. The Chatbot UI, Retriever, Vector Database, Prompt Storage, and LLM all play roles in a fluid conversation loop, providing the user a seamless chat experience.
+--------+--------+ (11)
| |
| Chatbot UI |
| |
+--------+--------+
^
|
(2) input|(10) output
v
+--------+-----------+
| | (9) response content
| Chatbot History +<-------------------------------+
| | |
+--------+-----------+ |
| |
| (3) message |
v ^
+-------------------+ +---------+------------+ (4) +---------+-----------+
| | | | | |
|Vector Database ? +---------->| Retriever ? | | requests History ? |
| | | | | |
+-------------------+ +---------+------------+ +---------+-----------+
| ^
| (5) Augmented message |
v |
+--------+---------+ (6) |
| | |
|Prompt Storage | |
| | |
+--------+---------+ |
| |
| (7) Augmented prompt with LLM params |
| |
v |
+--------+-----------+ |
| | |
| LLM ? | (8) Generated response |
| (Large Language +--------------------------------+
| Model) |
| |
+--------------------+
Before you begin, make sure you have the following prerequisites:
.env file it is not ignored on the repoFollow these steps to set up and run the project:
Clone the Repository:
git clone [email protected]:DLesmes/torchbot.git
cd torchbot
Set Up Python Virtual Environment with the requirements.txt:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
Run the Server:
python3 main.py
You can also debug it in your preferred IDE.
By default a history.json file will be created simulating a no-SQL database that can be develop for next versions this file its mind to be like this:
{
"<user_id>": [
{
"full_chat": [
{
"reply_id": srt, // reply id
"role": "system", // by default the first reply role is the "system"
"content": srt, // message content
"timestamp": int, // timestamp in milliseconds
},
{
"reply_id": str, // reply id
"role": "user", // by default the second reply role is the "user"
"content": srt, // message content
"timestamp": int, // timestamp in milliseconds
},
{
"reply_id": str, // reply id
"role": "assitant", // by default the third reply role is the "assistant"
"content": srt, // message content
"timestamp": int, // timestamp in milliseconds
},
{
"reply_id": str, // reply id
"role": str, // role of the user
"content": srt, // message content
"timestamp": int, // timestamp in milliseconds
}
]
}
]
}
By default a requests.json file will be created simulating a no-SQL database that can be develop for next versions this file its mind to be like this:
{
"<reply_id>": [
{
"user_id": srt, // reply id
"prompt": srt, // message content
"response": int, // timestamp in milliseconds
"timestamp": int, // timestamp in milliseconds
}
]
}
Feel free to contribute and make this chatbot project even better! We welcome contributions from the community! If you'd like to contribute, please follow these steps:
git checkout -b feature/YourFeatureNamegit commit -am 'Add some feature'git push origin feature/YourFeatureNameFor any questions or suggestions, feel free to reach out here is my profile