rushan3101's picture
Initial Commit
db06fda
Raw
History Blame Contribute Delete
1.48 kB
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from pydantic import BaseModel
from typing import List
from main import run_conversation_pipeline
# =========================================================
# FastAPI App Initialization
# =========================================================
app = FastAPI(
title="SHL Assessment Recommendation Agent",
version="1.0.0"
)
# =========================================================
# Request Schemas
# =========================================================
class Message(BaseModel):
role: str
content: str
class ChatRequest(BaseModel):
messages: List[Message]
# =========================================================
# # Root Endpoint
# # =========================================================
@app.get("/", response_class=HTMLResponse)
async def root():
with open( "templates/home.html", "r", encoding="utf-8" ) as f:
return f.read()
# =========================================================
# Health Endpoint
# =========================================================
@app.get("/health")
async def health():
return {
"status": "ok"
}
# =========================================================
# Chat Endpoint
# =========================================================
@app.post("/chat")
async def chat(req: ChatRequest):
response = run_conversation_pipeline(
messages=req.messages
)
return response