sohamchitimali commited on
Commit
d75e69b
·
1 Parent(s): 99f672b
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -49,29 +49,24 @@ async def hackrx_run(
49
  if not isinstance(questions, list) or not all(isinstance(q, str) for q in questions):
50
  return JSONResponse(status_code=400, content={"error": "'questions' must be a list of strings"})
51
 
52
- # Kept this improved handling from your second version
53
  if isinstance(documents, list):
54
  document_url = documents[0]
55
  else:
56
  document_url = documents
57
 
58
- # --- Start of Missing Logic from First Snippet ---
59
-
60
- # ✅ Step 1: Process document (using the call from the first version)
61
- doc_result = hackathon_system.process_document_efficiently(document_url)
62
  if not doc_result.get("success"):
63
  return JSONResponse(content={"error": doc_result.get("error")}, status_code=500)
64
 
65
- # ✅ Step 2: Answer questions (using the call from the first version)
66
- batch_result = hackathon_system.process_batch_queries(questions)
67
  answers = batch_result.get("answers", [])
68
 
69
- # --- End of Missing Logic ---
70
-
71
  return JSONResponse(content={"answers": answers}, status_code=200)
72
 
73
  except Exception as e:
74
- # Kept the improved logging from your second version
75
  logger.error(f"API Error: {str(e)}")
76
  return JSONResponse(content={"error": str(e)}, status_code=500)
77
 
 
49
  if not isinstance(questions, list) or not all(isinstance(q, str) for q in questions):
50
  return JSONResponse(status_code=400, content={"error": "'questions' must be a list of strings"})
51
 
52
+ # Improved handling from your second version
53
  if isinstance(documents, list):
54
  document_url = documents[0]
55
  else:
56
  document_url = documents
57
 
58
+ # Step 1: Process document (FIXED - using enhanced_system instead of hackathon_system)
59
+ doc_result = enhanced_system.process_document_optimized(document_url)
 
 
60
  if not doc_result.get("success"):
61
  return JSONResponse(content={"error": doc_result.get("error")}, status_code=500)
62
 
63
+ # ✅ Step 2: Answer questions (FIXED - using enhanced_system instead of hackathon_system)
64
+ batch_result = enhanced_system.process_batch_queries_optimized(questions)
65
  answers = batch_result.get("answers", [])
66
 
 
 
67
  return JSONResponse(content={"answers": answers}, status_code=200)
68
 
69
  except Exception as e:
 
70
  logger.error(f"API Error: {str(e)}")
71
  return JSONResponse(content={"error": str(e)}, status_code=500)
72