JirasakJo commited on
Commit
1476d7a
·
verified ·
1 Parent(s): b345613

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -69
app.py CHANGED
@@ -191,74 +191,6 @@ def save_feedback_to_json():
191
  except Exception as e:
192
  st.error(f"Error saving feedback: {str(e)}")
193
  return None
194
-
195
- def save_feedback_to_repo(file_path):
196
- """Commit and push feedback_data.json to GitHub repository"""
197
- try:
198
- # Add file to Git
199
- subprocess.run(["git", "add", file_path], check=True)
200
-
201
- # Commit changes
202
- commit_message = "feedback_data.json"
203
- subprocess.run(["git", "commit", "-m", commit_message], check=True)
204
-
205
- # Push to remote repository
206
- subprocess.run(["git", "push"], check=True)
207
-
208
- st.success("Feedback file successfully committed and pushed to the repository!")
209
- except subprocess.CalledProcessError as e:
210
- st.error(f"Git operation failed: {str(e)})")
211
-
212
- def save_feedback_to_repo(file_path):
213
- """Commit and push feedback_data.json to GitHub repository with improved error handling"""
214
- if not os.path.exists(file_path):
215
- st.error("Feedback file does not exist")
216
- return False
217
-
218
- try:
219
- # Check if git is installed
220
- try:
221
- subprocess.run(["git", "--version"], check=True, capture_output=True)
222
- except (subprocess.CalledProcessError, FileNotFoundError):
223
- st.error("Git is not installed or not accessible")
224
- return False
225
-
226
- # Check if directory is a git repository
227
- try:
228
- subprocess.run(["git", "rev-parse", "--is-inside-work-tree"],
229
- check=True, capture_output=True)
230
- except subprocess.CalledProcessError:
231
- st.error("Not a git repository")
232
- return False
233
-
234
- # Add file to Git
235
- result = subprocess.run(["git", "add", file_path],
236
- capture_output=True, text=True)
237
- if result.returncode != 0:
238
- st.error(f"Failed to add file: {result.stderr}")
239
- return False
240
-
241
- # Commit changes
242
- commit_message = "Add/update feedback_data.json"
243
- result = subprocess.run(["git", "commit", "-m", commit_message],
244
- capture_output=True, text=True)
245
- if result.returncode != 0:
246
- st.error(f"Failed to commit: {result.stderr}")
247
- return False
248
-
249
- # Push to remote repository
250
- result = subprocess.run(["git", "push"],
251
- capture_output=True, text=True)
252
- if result.returncode != 0:
253
- st.error(f"Failed to push: {result.stderr}")
254
- return False
255
-
256
- st.success("Feedback successfully saved and pushed to repository")
257
- return True
258
-
259
- except Exception as e:
260
- st.error(f"Unexpected error during git operations: {str(e)}")
261
- return False
262
 
263
  def add_feedback(query: str, answer: str, is_correct: bool):
264
  """Add feedback entry to session state and save to JSON and GitHub"""
@@ -328,7 +260,7 @@ def main():
328
 
329
  # Initialize pipeline
330
  if st.session_state.pipeline is None:
331
- with st.spinner("Initializing system..."):
332
  st.session_state.pipeline = initialize_pipeline()
333
 
334
  chat_col, info_col = st.columns([7, 3])
 
191
  except Exception as e:
192
  st.error(f"Error saving feedback: {str(e)}")
193
  return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
  def add_feedback(query: str, answer: str, is_correct: bool):
196
  """Add feedback entry to session state and save to JSON and GitHub"""
 
260
 
261
  # Initialize pipeline
262
  if st.session_state.pipeline is None:
263
+ with st.spinner("กำลังเริ่มต้นระบบ..."):
264
  st.session_state.pipeline = initialize_pipeline()
265
 
266
  chat_col, info_col = st.columns([7, 3])