Guillaumedbx commited on
Commit
baeaaf2
·
1 Parent(s): 03947a1

Add user input and prompt customization fields in the sidebar

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +13 -3
src/streamlit_app.py CHANGED
@@ -97,11 +97,22 @@ st.sidebar.markdown("🧠 **Modèle d'embedding :** `paraphrase-multilingual-mpn
97
  st.sidebar.markdown("🗂️ **Base vectorielle :** `Chroma`")
98
  st.sidebar.markdown("💬 **Modèle LLM :** `google/flan-t5-small` (text-generation, multilingue, open source)")
99
 
100
- # Saisie de l'utilisateur
101
- user_input = st.text_area("✉️ Votre question :", height=200)
 
 
 
 
 
 
 
 
 
102
 
103
  # Bouton d'envoi de la question
104
  if st.button("📤 Envoyer") and user_input.strip():
 
 
105
  def distance_to_percent(score, max_dist=10.0):
106
  score = max(0, min(score, max_dist))
107
  return round((1 - score / max_dist) * 100)
@@ -111,7 +122,6 @@ if st.button("📤 Envoyer") and user_input.strip():
111
  db_path = os.path.abspath("./db")
112
  db = Chroma(persist_directory=db_path, embedding_function=embeddings)
113
  retriever = db.as_retriever(search_kwargs={"k": max_docs})
114
- # Filtrage par types de bases sélectionnées (multi-choix)
115
  docs_and_scores = [
116
  (doc, score)
117
  for doc, score in retriever.vectorstore.similarity_search_with_score(user_input, k=30)
 
97
  st.sidebar.markdown("🗂️ **Base vectorielle :** `Chroma`")
98
  st.sidebar.markdown("💬 **Modèle LLM :** `google/flan-t5-small` (text-generation, multilingue, open source)")
99
 
100
+ # Saisie de l'utilisateur et personnalisation du prompt en même temps
101
+ col1, col2 = st.columns([2, 3])
102
+ with col1:
103
+ user_input = st.text_area("✉️ Votre question :", height=200, key="user_question")
104
+ with col2:
105
+ user_prompt_intro = st.text_area(
106
+ "Début du prompt (modifiable)",
107
+ value="Vous êtes un assistant juridique spécialisé en droit français.\nVotre tâche est de proposer une réponse synthétique et argumentée à la question suivante, en vous appuyant uniquement sur les extraits de documents fournis, classés par pertinence. Indiquez clairement si la réponse est incertaine ou partielle. Répondez en français.",
108
+ height=120,
109
+ key="prompt_intro"
110
+ )
111
 
112
  # Bouton d'envoi de la question
113
  if st.button("📤 Envoyer") and user_input.strip():
114
+ user_input = st.session_state["user_question"]
115
+ user_prompt_intro = st.session_state["prompt_intro"]
116
  def distance_to_percent(score, max_dist=10.0):
117
  score = max(0, min(score, max_dist))
118
  return round((1 - score / max_dist) * 100)
 
122
  db_path = os.path.abspath("./db")
123
  db = Chroma(persist_directory=db_path, embedding_function=embeddings)
124
  retriever = db.as_retriever(search_kwargs={"k": max_docs})
 
125
  docs_and_scores = [
126
  (doc, score)
127
  for doc, score in retriever.vectorstore.similarity_search_with_score(user_input, k=30)