Spaces:
Sleeping
Sleeping
Upload 12 files
Browse files- .gitattributes +1 -0
- .gitignore +29 -0
- .streamlit/config.toml +7 -0
- .streamlit/secrets.toml +9 -0
- README.md +54 -13
- chat_history.db +0 -0
- chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/data_level0.bin +3 -0
- chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/header.bin +3 -0
- chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/length.bin +3 -0
- chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/link_lists.bin +3 -0
- chroma_db/chroma.sqlite3 +3 -0
- main.py +148 -0
- requirements.txt +8 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
chroma_db/chroma.sqlite3 filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Fichiers et dossiers spécifiques à Streamlit
|
2 |
+
.streamlit/secrets.toml
|
3 |
+
|
4 |
+
# Fichiers Python compilés
|
5 |
+
__pycache__/
|
6 |
+
*.py[cod]
|
7 |
+
|
8 |
+
# Environnements virtuels
|
9 |
+
venv/
|
10 |
+
env/
|
11 |
+
.env
|
12 |
+
|
13 |
+
# Fichiers système
|
14 |
+
.DS_Store
|
15 |
+
Thumbs.db
|
16 |
+
|
17 |
+
# Fichiers de logs
|
18 |
+
*.log
|
19 |
+
|
20 |
+
# Fichiers de distribution
|
21 |
+
dist/
|
22 |
+
build/
|
23 |
+
*.egg-info/
|
24 |
+
/.venv
|
25 |
+
/envLLM
|
26 |
+
/chroma_db
|
27 |
+
chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/length.bin
|
28 |
+
chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/length.bin
|
29 |
+
meal_plan.csv
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="light"
|
3 |
+
primaryColor="#6A5ACD" # Un violet bleuté élégant
|
4 |
+
backgroundColor="#F0F8FF" # Un bleu clair doux
|
5 |
+
secondaryBackgroundColor="#D8BFD8" # Un violet pastel
|
6 |
+
textColor="#333333" # Un gris foncé pour le texte
|
7 |
+
font="serif"
|
.streamlit/secrets.toml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Secrets pour la base de données
|
2 |
+
DB_NAME = "postgres_llm"
|
3 |
+
DB_HOST = "localhost"
|
4 |
+
DB_USER = "postgres"
|
5 |
+
DB_PASSWORD = "ScorpionSQL"
|
6 |
+
DB_PORT = "5432"
|
7 |
+
|
8 |
+
# Clés API
|
9 |
+
MISTRAL_API_KEY = "RXjfbTO7wkOU0RwrwP7XpFfcj1K5eq40"
|
README.md
CHANGED
@@ -1,13 +1,54 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Nutrigénie
|
2 |
+
|
3 |
+
**Nutrigénie** est un assistant nutritionnel intelligent conçu pour aider les utilisateurs à adopter une alimentation saine et personnalisée. Basé sur des technologies de pointe en traitement du langage naturel et un système de **Retrieval-Augmented Generation (RAG)**, Nutrigénie fournit des conseils nutritionnels personnalisés et des recettes de cuisine adaptées aux besoins individuels.
|
4 |
+
|
5 |
+
## 🌟 Fonctionnalités principales
|
6 |
+
|
7 |
+
- **Chatbot interactif** : Engage des conversations fluides et naturelles sur la nutrition.
|
8 |
+
- **Recommandation de recettes** : Suggère des recettes de cuisine basées sur les préférences alimentaires et les besoins nutritionnels.
|
9 |
+
- **Conseils personnalisés** : Fournit des recommandations sur les habitudes alimentaires et le mode de vie.
|
10 |
+
- **Analyse des habitudes de vie** : Pose des questions ciblées pour mieux comprendre les besoins de l'utilisateur.
|
11 |
+
|
12 |
+
## 🚀 Démo en ligne
|
13 |
+
|
14 |
+
Accédez à Nutrigénie ici : [Nutrigénie sur Hugging Face Spaces](https://huggingface.co/spaces/Sahm269/NutrigenieLLM)
|
15 |
+
|
16 |
+
## 📁 Installation locale (optionnel)
|
17 |
+
|
18 |
+
Si vous souhaitez cloner et exécuter le projet en local :
|
19 |
+
|
20 |
+
```bash
|
21 |
+
# Clonez le dépôt
|
22 |
+
git clone https://github.com/Sahm269/LLM_project.git
|
23 |
+
cd LLM_project
|
24 |
+
|
25 |
+
# Créez un environnement virtuel
|
26 |
+
python -m venv venv
|
27 |
+
source venv/bin/activate # Sous Windows : venv\Scripts\activate
|
28 |
+
|
29 |
+
# Installez les dépendances
|
30 |
+
pip install -r requirements.txt
|
31 |
+
|
32 |
+
# Lancez l'application
|
33 |
+
streamlit run main.py
|
34 |
+
```
|
35 |
+
|
36 |
+
## 🌐 Utilisation
|
37 |
+
|
38 |
+
1. Accédez à l'application via le lien fourni ou lancez-la en local.
|
39 |
+
2. Engagez une conversation avec Nutrigénie en posant des questions sur la nutrition.
|
40 |
+
3. Recevez des conseils personnalisés et des suggestions de recettes.
|
41 |
+
|
42 |
+
|
43 |
+
## 👾 Technologies utilisées
|
44 |
+
|
45 |
+
- **Python** : Langage principal pour la logique de l'application.
|
46 |
+
- **Streamlit** : Framework pour créer des applications web interactives.
|
47 |
+
- **Hugging Face Spaces** : Hébergement de l'application.
|
48 |
+
- **PostGreSQL/ChromaDB** : Gestion de la base de données pour les conversations et les recettes.
|
49 |
+
- **RAG (Retrieval-Augmented Generation)** : Pour améliorer la précision des réponses.
|
50 |
+
|
51 |
+
---
|
52 |
+
|
53 |
+
**Nutrigénie** — Votre assistant personnel pour une alimentation saine et équilibrée !
|
54 |
+
|
chat_history.db
ADDED
Binary file (41 kB). View file
|
|
chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a13e72541800c513c73dccea69f79e39cf4baef4fa23f7e117c0d6b0f5f99670
|
3 |
+
size 3212000
|
chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:928a34c5420f079af12864733d4e7cde0edcc401eb6941777faddc06487af630
|
3 |
+
size 4000
|
chroma_db/3830e5c3-90f9-4a9b-b952-e3cfb8b8dc26/link_lists.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
3 |
+
size 0
|
chroma_db/chroma.sqlite3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9f415c864646dc2a45e6bdbf5cd0b1bd24db1f89dcfaae4859e38af4e9910872
|
3 |
+
size 2355200
|
main.py
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# data_link = https://github.com/Sahm269/LLM_project/tree/souraya/data
|
2 |
+
import streamlit as st
|
3 |
+
# from streamlit_option_menu import option_menu
|
4 |
+
# from client.pages.home import home_page
|
5 |
+
# from projects.LLM_project.client.pages.nutri_old import nutri_page
|
6 |
+
# from client.pages.dashboard import dashboard_page
|
7 |
+
# from client.pages.about import about_page
|
8 |
+
from client.pages.sign_in import sign_in
|
9 |
+
from client.pages.sign_up import sign_up
|
10 |
+
from server.db.dbmanager import get_db_manager
|
11 |
+
|
12 |
+
APP_TITLE = "Nutrigénie"
|
13 |
+
|
14 |
+
st.set_page_config(
|
15 |
+
page_title=APP_TITLE,
|
16 |
+
page_icon="client/assets/avatar_bot_small.jpg",
|
17 |
+
layout="wide",
|
18 |
+
initial_sidebar_state="expanded"
|
19 |
+
)
|
20 |
+
|
21 |
+
# with st.sidebar:
|
22 |
+
# st.image("client/assets/avatar_bot_medium.jpg")
|
23 |
+
|
24 |
+
# selected = option_menu(
|
25 |
+
# menu_title='',
|
26 |
+
# options=["Accueil", "Nutrigénie", "Tableau de bord", "A propos"],
|
27 |
+
# icons=["house", "patch-question", "bar-chart", "info-circle"],
|
28 |
+
# default_index=0,
|
29 |
+
# # orientation="horizontal",
|
30 |
+
# )
|
31 |
+
|
32 |
+
# if selected == "Accueil":
|
33 |
+
# home_page()
|
34 |
+
# elif selected == "Nutrigénie":
|
35 |
+
# nutri_page()
|
36 |
+
# elif selected == "Tableau de bord":
|
37 |
+
# dashboard_page()
|
38 |
+
# elif selected == "A propos":
|
39 |
+
# about_page()
|
40 |
+
|
41 |
+
# Initialiser DBManager dans st.session_state si non défini
|
42 |
+
if "db_manager" not in st.session_state:
|
43 |
+
st.session_state["db_manager"] = get_db_manager()
|
44 |
+
|
45 |
+
# Initialisation de la session utilisateur
|
46 |
+
if "logged_in" not in st.session_state:
|
47 |
+
st.session_state["logged_in"] = False
|
48 |
+
if "current_page" not in st.session_state:
|
49 |
+
st.session_state["current_page"] = "connexion"
|
50 |
+
if "user" not in st.session_state:
|
51 |
+
st.session_state["user"] = None
|
52 |
+
|
53 |
+
# Fonction de navigation
|
54 |
+
def navigate_to(page_name):
|
55 |
+
st.session_state["current_page"] = page_name
|
56 |
+
st.rerun()
|
57 |
+
|
58 |
+
# Gestion de la déconnexion
|
59 |
+
def logout_user():
|
60 |
+
keys_to_clear = ["logged_in", "user", "current_page"]
|
61 |
+
for key in keys_to_clear:
|
62 |
+
if key in st.session_state:
|
63 |
+
del st.session_state[key]
|
64 |
+
navigate_to("connexion")
|
65 |
+
|
66 |
+
# Gestion centralisée de la navigation
|
67 |
+
def handle_navigation():
|
68 |
+
if not st.session_state["logged_in"]:
|
69 |
+
# Redirection vers connexion si non connecté
|
70 |
+
if st.session_state["current_page"] not in ["connexion", "inscription"]:
|
71 |
+
st.session_state["current_page"] = "connexion"
|
72 |
+
st.rerun()
|
73 |
+
else:
|
74 |
+
# Gestion des pages disponibles pour les utilisateurs connectés
|
75 |
+
available_pages = ["accueil", "chatbot", "dashboard", "user"]
|
76 |
+
if st.session_state["current_page"] not in available_pages:
|
77 |
+
st.session_state["current_page"] = "accueil"
|
78 |
+
st.rerun()
|
79 |
+
|
80 |
+
# Définition des pages disponibles
|
81 |
+
PAGES = {
|
82 |
+
"accueil": {"file": "client/pages/home.py", "title": "🏠 Accueil"},
|
83 |
+
"chatbot": {"file": "client/pages/nutri.py", "title": "🤖 Chat Bot"},
|
84 |
+
"dashboard": {"file": "client/pages/dashboard.py", "title": "📊 Tableau de Bord"},
|
85 |
+
"user": {"file": "client/pages/user.py", "title": lambda: f"👤 Mon Compte {st.session_state.get('user', '')}"}
|
86 |
+
}
|
87 |
+
|
88 |
+
# Fonction principale
|
89 |
+
def main():
|
90 |
+
|
91 |
+
st.markdown(
|
92 |
+
"""
|
93 |
+
<style>
|
94 |
+
|
95 |
+
|
96 |
+
.stButton > button {
|
97 |
+
background-color: #6A5ACD;
|
98 |
+
color: white;
|
99 |
+
font-size: 18px;
|
100 |
+
padding: 10px;
|
101 |
+
border-radius: 8px;
|
102 |
+
border: none;
|
103 |
+
cursor: pointer;
|
104 |
+
transition: 0.3s;
|
105 |
+
}
|
106 |
+
|
107 |
+
.stButton > button:hover {
|
108 |
+
background-color: #388E3C;
|
109 |
+
box-shadow: 0px 0px 1px 1px;
|
110 |
+
color: white;
|
111 |
+
}
|
112 |
+
|
113 |
+
</style>
|
114 |
+
""",
|
115 |
+
unsafe_allow_html=True
|
116 |
+
)
|
117 |
+
|
118 |
+
# Gestion de la navigation
|
119 |
+
handle_navigation()
|
120 |
+
|
121 |
+
# Si l'utilisateur est connecté
|
122 |
+
if st.session_state["logged_in"]:
|
123 |
+
pages = []
|
124 |
+
for page_name, page_info in PAGES.items():
|
125 |
+
title = page_info["title"]
|
126 |
+
if callable(title): # Si le titre est une fonction
|
127 |
+
title = title()
|
128 |
+
pages.append(st.Page(page_info["file"], title=title))
|
129 |
+
|
130 |
+
# Afficher la barre latérale et gérer la déconnexion
|
131 |
+
with st.sidebar:
|
132 |
+
if st.button("Déconnexion"):
|
133 |
+
logout_user()
|
134 |
+
|
135 |
+
# Navigation entre les pages
|
136 |
+
pg = st.navigation(pages)
|
137 |
+
pg.run()
|
138 |
+
|
139 |
+
else:
|
140 |
+
# Ne pas afficher la barre de navigation
|
141 |
+
if st.session_state["current_page"] == "connexion":
|
142 |
+
sign_in(navigate_to)
|
143 |
+
|
144 |
+
elif st.session_state["current_page"] == "inscription":
|
145 |
+
sign_up(navigate_to)
|
146 |
+
|
147 |
+
if __name__ == "__main__":
|
148 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pysqlite3-wheels
|
3 |
+
mistralai
|
4 |
+
requests
|
5 |
+
python-dotenv
|
6 |
+
psycopg2-binary
|
7 |
+
streamlit_option_menu
|
8 |
+
langdetect
|