summarize / app.py
Pasindu599's picture
Add CORS middleware to FastAPI app and update summarize endpoint to accept multiple input fields (urls, codes, notes). Enhance graph logic to process new input structure and return detailed summary response.
948e715
raw
history blame
668 Bytes
from fastapi import FastAPI
from langgraph.agents.summarize_agent.graph import graph
from fastapi import Request
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
# cors
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def greet_json():
return {"Hello": "World!"}
@app.post("/summarize")
async def summarize(request: Request):
data = await request.json()
urls = data.get("urls")
codes = data.get("codes")
notes = data.get("notes")
return graph.invoke({"urls": urls, "codes": codes, "notes": notes})