Spaces:
Sleeping
Sleeping
Commit ·
940d242
1
Parent(s): b0b5ccd
suppression spinner
Browse files- src/streamlit_app.py +3 -14
src/streamlit_app.py
CHANGED
|
@@ -33,26 +33,15 @@ similarity_threshold = st.sidebar.slider(
|
|
| 33 |
step=5
|
| 34 |
)
|
| 35 |
|
| 36 |
-
# Chargement des embeddings et de la base vectorielle au démarrage
|
| 37 |
-
if "embeddings" not in st.session_state or "db" not in st.session_state:
|
| 38 |
-
with st.spinner("Chargement initial de la base de données vectorielle, merci de patienter..."):
|
| 39 |
-
try:
|
| 40 |
-
st.session_state["embeddings"] = get_local_embeddings()
|
| 41 |
-
# Utilisation stricte de la base vectorielle locale
|
| 42 |
-
db_path = os.path.abspath("./data/db")
|
| 43 |
-
st.session_state["db"] = Chroma(persist_directory=db_path, embedding_function=st.session_state["embeddings"])
|
| 44 |
-
except Exception as e:
|
| 45 |
-
st.error(f"❌ Erreur lors du chargement de la base vectorielle : {e}")
|
| 46 |
-
st.stop()
|
| 47 |
-
|
| 48 |
# Saisie de l'utilisateur
|
| 49 |
user_input = st.text_area("✉️ Votre question :", height=200)
|
| 50 |
|
| 51 |
# Bouton d'envoi de la question
|
| 52 |
if st.button("📤 Envoyer") and user_input.strip():
|
| 53 |
with st.spinner("Recherche et génération de la réponse..."):
|
| 54 |
-
embeddings =
|
| 55 |
-
|
|
|
|
| 56 |
retriever = db.as_retriever(search_kwargs={"k": max_docs})
|
| 57 |
docs_and_scores = retriever.vectorstore.similarity_search_with_score(user_input, k=max_docs)
|
| 58 |
threshold_value = similarity_threshold / 100
|
|
|
|
| 33 |
step=5
|
| 34 |
)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Saisie de l'utilisateur
|
| 37 |
user_input = st.text_area("✉️ Votre question :", height=200)
|
| 38 |
|
| 39 |
# Bouton d'envoi de la question
|
| 40 |
if st.button("📤 Envoyer") and user_input.strip():
|
| 41 |
with st.spinner("Recherche et génération de la réponse..."):
|
| 42 |
+
embeddings = get_local_embeddings()
|
| 43 |
+
db_path = os.path.abspath("./data/db")
|
| 44 |
+
db = Chroma(persist_directory=db_path, embedding_function=embeddings)
|
| 45 |
retriever = db.as_retriever(search_kwargs={"k": max_docs})
|
| 46 |
docs_and_scores = retriever.vectorstore.similarity_search_with_score(user_input, k=max_docs)
|
| 47 |
threshold_value = similarity_threshold / 100
|