Hamza4100 commited on
Commit
46bea22
·
verified ·
1 Parent(s): ba58c3e

Update app/routes/llm_extraction.py

Browse files
Files changed (1) hide show
  1. app/routes/llm_extraction.py +4 -0
app/routes/llm_extraction.py CHANGED
@@ -33,7 +33,11 @@ async def extract_medical_data(request: ExtractRequest, db: Session = Depends(ge
33
  text_to_process = request.cleaned_text or request.raw_text or ""
34
  # --- Blocking: Groq HTTP call ---
35
  result = await asyncio.to_thread(extractor.extract_from_text, text_to_process)
 
 
36
  return result
 
 
37
  except Exception as e:
38
  raise HTTPException(status_code=500, detail=str(e))
39
 
 
33
  text_to_process = request.cleaned_text or request.raw_text or ""
34
  # --- Blocking: Groq HTTP call ---
35
  result = await asyncio.to_thread(extractor.extract_from_text, text_to_process)
36
+ if result.get("status") == "error":
37
+ raise HTTPException(status_code=400, detail=result.get("message", "Invalid medical report document"))
38
  return result
39
+ except HTTPException:
40
+ raise
41
  except Exception as e:
42
  raise HTTPException(status_code=500, detail=str(e))
43