DocUA commited on
Commit
ddee4e6
·
1 Parent(s): 7ef6bed

Fix input detection: prioritize URL input even when method state is incorrect

Browse files
Files changed (1) hide show
  1. interface.py +15 -4
interface.py CHANGED
@@ -187,6 +187,7 @@ async def process_input(
187
  input_type = "text"
188
  input_text = ""
189
 
 
190
  if input_method == "Завантаження файлу":
191
  if not file_input:
192
  return "❌ Помилка: Будь ласка, завантажте файл", None, session_id
@@ -200,11 +201,16 @@ async def process_input(
200
  input_type = "url"
201
  input_text = url_input
202
  else:
203
- input_text = text_input
 
 
 
 
 
204
 
205
  # Check if input is empty and provide specific error message
206
  if not input_text or not input_text.strip():
207
- if input_method == "URL посилання":
208
  return "❌ Помилка: Будь ласка, введіть URL посилання на судове рішення", None, session_id
209
  elif input_method == "Текстовий ввід":
210
  return "❌ Помилка: Будь ласка, введіть текст судового рішення", None, session_id
@@ -261,6 +267,7 @@ async def process_raw_text_search(text, url, file, method, state_lp_json):
261
  """Process raw text search and update necessary states."""
262
  try:
263
  input_text = ""
 
264
  if method == "Завантаження файлу":
265
  if not file:
266
  return "❌ Помилка: Будь ласка, завантажте файл", None, state_lp_json
@@ -273,11 +280,15 @@ async def process_raw_text_search(text, url, file, method, state_lp_json):
273
  elif method == "URL посилання":
274
  input_text = url
275
  else:
276
- input_text = text
 
 
 
 
277
 
278
  # Check if input is empty and provide specific error message
279
  if not input_text or not input_text.strip():
280
- if method == "URL посилання":
281
  return "❌ Помилка: Будь ласка, введіть URL посилання на судове рішення", None, state_lp_json
282
  elif method == "Текстовий ввід":
283
  return "❌ Помилка: Будь ласка, введіть текст судового рішення", None, state_lp_json
 
187
  input_type = "text"
188
  input_text = ""
189
 
190
+ # Determine which input source has actual content
191
  if input_method == "Завантаження файлу":
192
  if not file_input:
193
  return "❌ Помилка: Будь ласка, завантажте файл", None, session_id
 
201
  input_type = "url"
202
  input_text = url_input
203
  else:
204
+ # Default to text input, but check if URL is provided instead
205
+ if url_input and url_input.strip():
206
+ input_type = "url"
207
+ input_text = url_input
208
+ else:
209
+ input_text = text_input
210
 
211
  # Check if input is empty and provide specific error message
212
  if not input_text or not input_text.strip():
213
+ if input_method == "URL посилання" or (url_input and url_input.strip()):
214
  return "❌ Помилка: Будь ласка, введіть URL посилання на судове рішення", None, session_id
215
  elif input_method == "Текстовий ввід":
216
  return "❌ Помилка: Будь ласка, введіть текст судового рішення", None, session_id
 
267
  """Process raw text search and update necessary states."""
268
  try:
269
  input_text = ""
270
+ # Determine which input source has actual content
271
  if method == "Завантаження файлу":
272
  if not file:
273
  return "❌ Помилка: Будь ласка, завантажте файл", None, state_lp_json
 
280
  elif method == "URL посилання":
281
  input_text = url
282
  else:
283
+ # Default to text input, but check if URL is provided instead
284
+ if url and url.strip():
285
+ input_text = url
286
+ else:
287
+ input_text = text
288
 
289
  # Check if input is empty and provide specific error message
290
  if not input_text or not input_text.strip():
291
+ if method == "URL посилання" or (url and url.strip()):
292
  return "❌ Помилка: Будь ласка, введіть URL посилання на судове рішення", None, state_lp_json
293
  elif method == "Текстовий ввід":
294
  return "❌ Помилка: Будь ласка, введіть текст судового рішення", None, state_lp_json