Kode untuk bot telegram? Khusus di Pytorch LLM bertenaga
Proyek ini bertujuan untuk mensimulasikan chatbot mesagge teks untuk mengobrol tentang pytorch
Dalam arsitektur yang ramping ini, sejarah chatbot berfungsi sebagai gudang utama dari sejarah interaksi, mendukung pengambilan konteks historis dan penebangan interaksi baru, termasuk respons penuh dari LLM. Chatbot UI, Retriever, Vector Database, Storage Prompt, dan LLM semuanya memainkan peran dalam loop percakapan yang cair, memberikan pengguna pengalaman obrolan yang mulus.
+--------+--------+ (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) |
| |
+--------------------+
Sebelum Anda mulai, pastikan Anda memiliki prasyarat berikut:
.env itu tidak diabaikan di repo Ikuti langkah -langkah ini untuk mengatur dan menjalankan proyek:
Klon Repositori:
git clone [email protected]:DLesmes/torchbot.git
cd torchbot
Mengatur lingkungan virtual Python dengan persyaratan.txt:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
Jalankan server:
python3 main.py
Anda juga dapat men -debug di IDE pilihan Anda.
Secara default file history.json akan dibuat mensimulasikan database no-sql yang dapat dikembangkan untuk versi berikutnya file ini pikirannya seperti ini:
{
"<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
}
]
}
]
}
Secara default file requests.json akan dibuat mensimulasikan database no-sql yang dapat dikembangkan untuk versi berikutnya file ini pikirannya seperti ini:
{
"<reply_id>": [
{
"user_id": srt, // reply id
"prompt": srt, // message content
"response": int, // timestamp in milliseconds
"timestamp": int, // timestamp in milliseconds
}
]
}
Jangan ragu untuk berkontribusi dan membuat proyek chatbot ini menjadi lebih baik! Kami menyambut kontribusi dari komunitas! Jika Anda ingin berkontribusi, ikuti langkah -langkah ini:
git checkout -b feature/YourFeatureNamegit commit -am 'Add some feature'git push origin feature/YourFeatureNameUntuk pertanyaan atau saran, jangan ragu untuk menjangkau di sini adalah profil saya