Spaces:
Paused
Paused
Update app/routes/llm_extraction.py
Browse files
app/routes/llm_extraction.py
CHANGED
|
@@ -14,7 +14,8 @@ UPLOAD_FOLDER = "uploads"
|
|
| 14 |
|
| 15 |
|
| 16 |
class ExtractRequest(BaseModel):
|
| 17 |
-
cleaned_text: str
|
|
|
|
| 18 |
file_id: Optional[str] = None
|
| 19 |
|
| 20 |
|
|
@@ -26,11 +27,12 @@ class HybridExtractRequest(BaseModel):
|
|
| 26 |
|
| 27 |
@router.post("/medical-data")
|
| 28 |
async def extract_medical_data(request: ExtractRequest, db: Session = Depends(get_db)):
|
| 29 |
-
"""Extract structured medical data from cleaned text using LLM
|
| 30 |
try:
|
| 31 |
extractor = LLMExtractor()
|
|
|
|
| 32 |
# --- Blocking: Groq HTTP call ---
|
| 33 |
-
result = await asyncio.to_thread(extractor.extract_from_text,
|
| 34 |
return result
|
| 35 |
except Exception as e:
|
| 36 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
class ExtractRequest(BaseModel):
|
| 17 |
+
cleaned_text: Optional[str] = None
|
| 18 |
+
raw_text: Optional[str] = None
|
| 19 |
file_id: Optional[str] = None
|
| 20 |
|
| 21 |
|
|
|
|
| 27 |
|
| 28 |
@router.post("/medical-data")
|
| 29 |
async def extract_medical_data(request: ExtractRequest, db: Session = Depends(get_db)):
|
| 30 |
+
"""Extract structured medical data from cleaned text using LLM"""
|
| 31 |
try:
|
| 32 |
extractor = LLMExtractor()
|
| 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))
|