arihant18 commited on
Commit
54c21ab
·
1 Parent(s): be54e4b

Added request error handeling.

Browse files
Files changed (1) hide show
  1. streamlit_app/app.py +15 -3
streamlit_app/app.py CHANGED
@@ -77,18 +77,30 @@ def upload_pdf_to_backend(file):
77
  f"{API_BASE_URL}/data_ingestion/pdf",
78
  files={"file": (file.name, file, file.type)}
79
  )
80
- return response.json()
 
 
 
 
81
 
82
  def upload_url_to_backend(url):
83
  response = requests.post(
84
  f"{API_BASE_URL}/data_ingestion/urls",
85
  params = {"urls": [url]}
86
  )
87
- return response.json()
 
 
 
 
 
88
 
89
  def delete_vector_store():
90
  response = requests.get(f"{API_BASE_URL}/data_ingestion/delete_vectordb")
91
- return response.json()
 
 
 
92
 
93
 
94
 
 
77
  f"{API_BASE_URL}/data_ingestion/pdf",
78
  files={"file": (file.name, file, file.type)}
79
  )
80
+ if response.status_code == 200:
81
+ st.info("pdf added successfully.")
82
+ return response.json()
83
+ else:
84
+ st.error("Unable to added the pdf.")
85
 
86
  def upload_url_to_backend(url):
87
  response = requests.post(
88
  f"{API_BASE_URL}/data_ingestion/urls",
89
  params = {"urls": [url]}
90
  )
91
+ if response.status_code == 200:
92
+ st.info("Url added successfully.")
93
+ return response.json()
94
+ else:
95
+ st.error("Unable to added the Url")
96
+
97
 
98
  def delete_vector_store():
99
  response = requests.get(f"{API_BASE_URL}/data_ingestion/delete_vectordb")
100
+ if response.status_code == 200:
101
+ return response.json()
102
+ else:
103
+ st.error("Unable to Delete the vector store.")
104
 
105
 
106