Spaces:
Sleeping
Sleeping
Update routers/textProcessing.py
Browse files- routers/textProcessing.py +25 -27
routers/textProcessing.py
CHANGED
@@ -1,27 +1,25 @@
|
|
1 |
-
from usecase.workflow import langgraphPipeline
|
2 |
-
from data.schemaClass import TextInput
|
3 |
-
from fastapi import APIRouter, HTTPException
|
4 |
-
from fastapi.responses import JSONResponse
|
5 |
-
|
6 |
-
router = APIRouter()
|
7 |
-
|
8 |
-
@router.post("/process_text")
|
9 |
-
def process_text(input_data:TextInput):
|
10 |
-
try:
|
11 |
-
pipeline_app = langgraphPipeline()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
"
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
-
except Exception as e:
|
27 |
-
raise HTTPException(status_code=500,detail=str(e))
|
|
|
1 |
+
from usecase.workflow import langgraphPipeline
|
2 |
+
from data.schemaClass import TextInput
|
3 |
+
from fastapi import APIRouter, HTTPException
|
4 |
+
from fastapi.responses import JSONResponse
|
5 |
+
|
6 |
+
router = APIRouter()
|
7 |
+
|
8 |
+
@router.post("/process_text")
|
9 |
+
def process_text(input_data:TextInput):
|
10 |
+
try:
|
11 |
+
pipeline_app = langgraphPipeline()
|
12 |
+
|
13 |
+
state_input = {"text":input_data.text}
|
14 |
+
|
15 |
+
result = pipeline_app.invoke(state_input)
|
16 |
+
|
17 |
+
return JSONResponse(
|
18 |
+
content={
|
19 |
+
"classification": result.get("classification", ""),
|
20 |
+
"entities": result.get("entities", []),
|
21 |
+
"summary": result.get("summary", "")
|
22 |
+
}
|
23 |
+
)
|
24 |
+
except Exception as e:
|
25 |
+
raise HTTPException(status_code=500,detail=str(e))
|
|
|
|