File size: 437 Bytes
9bf33d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from fastapi import FastAPI, Request
from pydantic import BaseModel
from langgraph_chain import create_graph
from fastapi import Form

app = FastAPI()
graph = create_graph()

class Query(BaseModel):
    question: str

@app.get("/")
def read_root():
    return {"Hello": "World"}

@app.post("/ask")
def ask_q(question: str = Form(...)):
    result = graph.invoke({"question": question})
    return {"response": result}