Spaces:
Sleeping
Sleeping
File size: 778 Bytes
8630e6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from src.chatbot import handle_query # now safe
class ChatRequest(BaseModel):
query: str
class ChatResponse(BaseModel):
answer: str
cards: list = []
app = FastAPI(title="NoBrokerage Chatbot")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.post("/chat", response_model=ChatResponse)
def chat(request: ChatRequest):
result = handle_query(request.query)
return ChatResponse(answer=result.get("summary"), cards=result.get("cards", []))
@app.get("/")
def root():
return {"message": "✅ NoBrokerage running"}
|