Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,26 +69,18 @@ qa = RetrievalQA.from_chain_type(
|
|
69 |
retriever=retriever,
|
70 |
chain_type_kwargs={"prompt": prompt},
|
71 |
)
|
72 |
-
import streamlit as st
|
73 |
-
import pandas as pd
|
74 |
-
import os
|
75 |
|
76 |
-
|
77 |
-
try:
|
78 |
-
from streamlit_star_rating import st_star_rating
|
79 |
-
except ImportError:
|
80 |
-
st.write("Installing required package: streamlit-star-rating")
|
81 |
-
!pip install streamlit-star-rating
|
82 |
-
from streamlit_star_rating import st_star_rating
|
83 |
|
84 |
# Streamlit interface with improved aesthetics
|
85 |
st.set_page_config(page_title="Alter-IA Chat", page_icon="🤖")
|
86 |
|
87 |
# Define function to handle user input and display chatbot response
|
88 |
def chatbot_response(user_input):
|
89 |
-
response =
|
90 |
return response
|
91 |
|
|
|
92 |
# Create columns for logos
|
93 |
col1, col2, col3 = st.columns([2, 3, 2])
|
94 |
|
@@ -97,13 +89,21 @@ with col1:
|
|
97 |
|
98 |
with col3:
|
99 |
st.image("Altereo logo 2023 original - eau et territoires durables.png", width=150, use_column_width=True) # Adjust image path and size as needed
|
100 |
-
|
101 |
-
#
|
|
|
102 |
st.markdown("""
|
103 |
<style>
|
104 |
.centered-text {
|
105 |
text-align: center;
|
106 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
.centered-orange-text {
|
108 |
text-align: center;
|
109 |
color: darkorange;
|
@@ -111,10 +111,9 @@ st.markdown("""
|
|
111 |
</style>
|
112 |
""", unsafe_allow_html=True)
|
113 |
|
114 |
-
#
|
115 |
-
|
116 |
st.markdown('<p class="centered-orange-text">"Votre Réponse à Chaque Défi Méthodologique "</p>', unsafe_allow_html=True)
|
117 |
-
|
118 |
# Input and button for user interaction
|
119 |
user_input = st.text_input("You:", "")
|
120 |
submit_button = st.button("Ask 📨")
|
@@ -124,40 +123,11 @@ if submit_button:
|
|
124 |
if user_input.strip() != "":
|
125 |
bot_response = chatbot_response(user_input)
|
126 |
st.markdown("### Bot:")
|
127 |
-
st.text_area("", value=bot_response, height=
|
128 |
else:
|
129 |
st.warning("⚠️ Please enter a message.")
|
130 |
|
131 |
# Motivational quote at the bottom
|
132 |
st.markdown("---")
|
133 |
-
st.markdown("
|
134 |
-
|
135 |
-
# Star rating system
|
136 |
-
st.markdown("### Évaluez notre service :")
|
137 |
-
rating = st_star_rating('Rate the response', 5, 0)
|
138 |
-
|
139 |
-
# Save rating to a file
|
140 |
-
ratings_file = "user_ratings.csv"
|
141 |
-
|
142 |
-
if rating > 0:
|
143 |
-
if not os.path.exists(ratings_file):
|
144 |
-
# Create a new file with headers if it doesn't exist
|
145 |
-
df = pd.DataFrame(columns=["User Input", "Bot Response", "Rating"])
|
146 |
-
df.to_csv(ratings_file, index=False)
|
147 |
-
|
148 |
-
# Append new rating to the file
|
149 |
-
new_rating = {"User Input": user_input, "Bot Response": bot_response, "Rating": rating}
|
150 |
-
df = pd.read_csv(ratings_file)
|
151 |
-
df = df.append(new_rating, ignore_index=True)
|
152 |
-
df.to_csv(ratings_file, index=False)
|
153 |
-
st.success("Thank you for your feedback!")
|
154 |
-
|
155 |
-
# Display the contents of the ratings file
|
156 |
-
st.markdown("### User Ratings:")
|
157 |
-
if os.path.exists(ratings_file):
|
158 |
-
df = pd.read_csv(ratings_file)
|
159 |
-
st.write(df)
|
160 |
-
else:
|
161 |
-
st.write("No ratings yet.")
|
162 |
-
|
163 |
|
|
|
69 |
retriever=retriever,
|
70 |
chain_type_kwargs={"prompt": prompt},
|
71 |
)
|
|
|
|
|
|
|
72 |
|
73 |
+
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
# Streamlit interface with improved aesthetics
|
76 |
st.set_page_config(page_title="Alter-IA Chat", page_icon="🤖")
|
77 |
|
78 |
# Define function to handle user input and display chatbot response
|
79 |
def chatbot_response(user_input):
|
80 |
+
response = qa.run(user_input)
|
81 |
return response
|
82 |
|
83 |
+
|
84 |
# Create columns for logos
|
85 |
col1, col2, col3 = st.columns([2, 3, 2])
|
86 |
|
|
|
89 |
|
90 |
with col3:
|
91 |
st.image("Altereo logo 2023 original - eau et territoires durables.png", width=150, use_column_width=True) # Adjust image path and size as needed
|
92 |
+
# Streamlit components
|
93 |
+
# Ajouter un peu de CSS pour centrer le texte
|
94 |
+
# Ajouter un peu de CSS pour centrer le texte et le colorer en orange foncé
|
95 |
st.markdown("""
|
96 |
<style>
|
97 |
.centered-text {
|
98 |
text-align: center;
|
99 |
}
|
100 |
+
</style>
|
101 |
+
""", unsafe_allow_html=True)
|
102 |
+
|
103 |
+
# Utiliser la classe CSS pour centrer et colorer le texte
|
104 |
+
st.markdown('<h3 class="centered-text">🤖 AlteriaChat 🤖 </h3>', unsafe_allow_html=True)
|
105 |
+
st.markdown("""
|
106 |
+
<style>
|
107 |
.centered-orange-text {
|
108 |
text-align: center;
|
109 |
color: darkorange;
|
|
|
111 |
</style>
|
112 |
""", unsafe_allow_html=True)
|
113 |
|
114 |
+
# Centrer le texte principal
|
115 |
+
# Centrer et colorer en orange foncé le texte spécifique
|
116 |
st.markdown('<p class="centered-orange-text">"Votre Réponse à Chaque Défi Méthodologique "</p>', unsafe_allow_html=True)
|
|
|
117 |
# Input and button for user interaction
|
118 |
user_input = st.text_input("You:", "")
|
119 |
submit_button = st.button("Ask 📨")
|
|
|
123 |
if user_input.strip() != "":
|
124 |
bot_response = chatbot_response(user_input)
|
125 |
st.markdown("### Bot:")
|
126 |
+
st.text_area("", value=bot_response, height=600)
|
127 |
else:
|
128 |
st.warning("⚠️ Please enter a message.")
|
129 |
|
130 |
# Motivational quote at the bottom
|
131 |
st.markdown("---")
|
132 |
+
st.markdown("La collaboration est la clé du succès. Chaque question trouve sa réponse, chaque défi devient une opportunité.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|