mery22 commited on
Commit
0eec04d
1 Parent(s): c6bf6d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -59
app.py CHANGED
@@ -8,7 +8,6 @@ from langchain.chains import LLMChain, RetrievalQA
8
  import gspread
9
  from oauth2client.service_account import ServiceAccountCredentials
10
  import json
11
-
12
  import gspread
13
  from oauth2client.service_account import ServiceAccountCredentials
14
  import json
@@ -22,6 +21,7 @@ service_account_info = json.loads(GOOGLE_SERVICE_ACCOUNT_JSON)
22
  creds = ServiceAccountCredentials.from_json_keyfile_dict(service_account_info, scope)
23
  client = gspread.authorize(creds)
24
  sheet = client.open("users feedback").sheet1 # Replace with your Google Sheet name
 
25
  # Function to save user feedback to Google Sheets
26
  def save_feedback(user_input, bot_response, rating, comment):
27
  feedback = [user_input, bot_response, rating, comment]
@@ -97,53 +97,16 @@ st.markdown("""
97
  .centered-text {
98
  text-align: center;
99
  }
100
- .stars {
101
- font-size: 24px;
102
- color: lightgray;
103
- cursor: pointer;
104
- }
105
- .stars:hover,
106
- .stars.selected {
107
- color: gold;
108
- }
109
- .stars.filled {
110
- color: gold;
111
  }
112
  </style>
113
  """, unsafe_allow_html=True)
114
 
115
- # Star rating system with JavaScript
116
- st.markdown("""
117
- <script>
118
- function setRating(starId) {
119
- const stars = document.querySelectorAll('.stars');
120
- stars.forEach(star => star.classList.remove('filled'));
121
- document.querySelectorAll('.stars').forEach(star => {
122
- if (star.dataset.rating <= starId) {
123
- star.classList.add('filled');
124
- }
125
- });
126
- document.getElementById('rating').value = starId;
127
- }
128
- document.addEventListener('DOMContentLoaded', (event) => {
129
- document.querySelectorAll('.stars').forEach(star => {
130
- star.addEventListener('click', () => {
131
- setRating(star.dataset.rating);
132
- });
133
- });
134
- });
135
- </script>
136
- """, unsafe_allow_html=True)
137
-
138
- # Display star rating
139
- st.markdown('<div class="stars" data-rating="1">&#9733;</div>', unsafe_allow_html=True)
140
- st.markdown('<div class="stars" data-rating="2">&#9733;</div>', unsafe_allow_html=True)
141
- st.markdown('<div class="stars" data-rating="3">&#9733;</div>', unsafe_allow_html=True)
142
- st.markdown('<div class="stars" data-rating="4">&#9733;</div>', unsafe_allow_html=True)
143
- st.markdown('<div class="stars" data-rating="5">&#9733;</div>', unsafe_allow_html=True)
144
-
145
- # Hidden input field to store the rating value
146
- st.markdown('<input type="hidden" id="rating" value="0">', unsafe_allow_html=True)
147
 
148
  # Input and button for user interaction
149
  user_input = st.text_input("You:", "")
@@ -158,27 +121,14 @@ if submit_button:
158
 
159
  # Feedback form
160
  st.markdown("### Rate the response:")
161
- st.markdown('<p>Please click on the stars to rate the response.</p>', unsafe_allow_html=True)
162
- st.markdown('<p id="rating-value">Rating: 0</p>', unsafe_allow_html=True)
163
 
164
  st.markdown("### Leave a comment:")
165
  comment = st.text_area("")
166
 
167
- # Update rating value on star click
168
- st.markdown("""
169
- <script>
170
- document.querySelectorAll('.stars').forEach(star => {
171
- star.addEventListener('click', function() {
172
- document.getElementById('rating-value').innerText = 'Rating: ' + this.dataset.rating;
173
- });
174
- });
175
- </script>
176
- """, unsafe_allow_html=True)
177
-
178
  # Feedback submission
179
  if st.button("Submit Feedback"):
180
- rating = st.text_input("Rating", value="0")
181
- if comment.strip() and rating != "0":
182
  save_feedback(user_input, bot_response, rating, comment)
183
  st.success("Thank you for your feedback!")
184
  else:
 
8
  import gspread
9
  from oauth2client.service_account import ServiceAccountCredentials
10
  import json
 
11
  import gspread
12
  from oauth2client.service_account import ServiceAccountCredentials
13
  import json
 
21
  creds = ServiceAccountCredentials.from_json_keyfile_dict(service_account_info, scope)
22
  client = gspread.authorize(creds)
23
  sheet = client.open("users feedback").sheet1 # Replace with your Google Sheet name
24
+
25
  # Function to save user feedback to Google Sheets
26
  def save_feedback(user_input, bot_response, rating, comment):
27
  feedback = [user_input, bot_response, rating, comment]
 
97
  .centered-text {
98
  text-align: center;
99
  }
100
+ .centered-orange-text {
101
+ text-align: center;
102
+ color: darkorange;
 
 
 
 
 
 
 
 
103
  }
104
  </style>
105
  """, unsafe_allow_html=True)
106
 
107
+ # Use the CSS classes to style the text
108
+ st.markdown('<h3 class="centered-text">🤖 AlteriaChat 🤖</h3>', unsafe_allow_html=True)
109
+ st.markdown('<p class="centered-orange-text">"Votre Réponse à Chaque Défi Méthodologique"</p>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  # Input and button for user interaction
112
  user_input = st.text_input("You:", "")
 
121
 
122
  # Feedback form
123
  st.markdown("### Rate the response:")
124
+ rating = st.slider("Select a rating:", min_value=1, max_value=5, value=1)
 
125
 
126
  st.markdown("### Leave a comment:")
127
  comment = st.text_area("")
128
 
 
 
 
 
 
 
 
 
 
 
 
129
  # Feedback submission
130
  if st.button("Submit Feedback"):
131
+ if comment.strip() and rating:
 
132
  save_feedback(user_input, bot_response, rating, comment)
133
  st.success("Thank you for your feedback!")
134
  else: