Uniaff commited on
Commit
8c0d8c9
·
verified ·
1 Parent(s): fa3a00b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -38,6 +38,18 @@ You are an assistant answering users' questions using the provided context. Your
38
  Question: {input}
39
  """
40
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  def upload_file_vdb(file):
42
  log_message("Загружаем файл")
43
  API_URL = f"{VECTOR_API_URL}/upload/"
@@ -138,6 +150,8 @@ with gr.Blocks() as demo:
138
  output_second = gr.Text()
139
  second_page_btn = gr.Button("Отправить файл")
140
  second_page_btn.click(upload_file_vdb, inputs=file_input, outputs=output_second)
 
 
141
 
142
  if __name__ == "__main__":
143
  demo.launch(
 
38
  Question: {input}
39
  """
40
 
41
+ def delete_faiss_index():
42
+ log_message("Удаляем FAISS индекс.")
43
+ response = requests.delete("http://213.219.228.90:8000/delete_index/")
44
+
45
+ if response.status_code == 200:
46
+ log_message("FAISS индекс успешно удален.")
47
+ return {"status": "success", "message": response.json().get("message", "FAISS индекс удален.")}
48
+ else:
49
+ log_message(f"Ошибка при удалении FAISS индекса: {response.json().get('detail')}")
50
+ return {"status": "error", "message": response.json().get("detail", "Ошибка при удалении FAISS индекса.")}
51
+
52
+
53
  def upload_file_vdb(file):
54
  log_message("Загружаем файл")
55
  API_URL = f"{VECTOR_API_URL}/upload/"
 
150
  output_second = gr.Text()
151
  second_page_btn = gr.Button("Отправить файл")
152
  second_page_btn.click(upload_file_vdb, inputs=file_input, outputs=output_second)
153
+ delete_btn = gr.Button("Удалить FAISS индекс")
154
+ delete_btn.click(delete_faiss_index, outputs=output_second)
155
 
156
  if __name__ == "__main__":
157
  demo.launch(