tahamehboob281 commited on
Commit
8117946
·
verified ·
1 Parent(s): be6b751

Update routers/textProcessing.py

Browse files
Files changed (1) hide show
  1. 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
- import streamlit as st
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
- state_input = {"text":"hi"}
15
-
16
- # print(f"{input_data.text} type is {type(input_data.text)}")
17
- result = pipeline_app.invoke(state_input)
18
-
19
- return JSONResponse(
20
- content={
21
- "classification": result.get("classification", ""),
22
- "entities": result.get("entities", []),
23
- "summary": result.get("summary", "")
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))