jorpier / src /api /jewel_mirror.py
puzan789's picture
add:updated
0870bc8
from fastapi.routing import APIRouter
from fastapi.requests import Request
from src.jewel_mirror.jewel_langgraph import JewelGraphApp
from src.utils.error_handling import create_success_response, raise_http_exception
from src.models.apis_models import JewelQueryRequest
from src import logging as logger
jewel_api_router=APIRouter(tags=["jewelchatbot"])
@jewel_api_router.post("/answer_jewel_query")
async def answer_query(request:JewelQueryRequest):
logger.info(f">>>answer_jewel_query API Triggered <<<")
try:
jewel_app = JewelGraphApp(request.vectorstore)
output, followup_questions= jewel_app.get_response(query=request.query)
response = create_success_response(200, data={"output": output, "follow_up_questions": followup_questions,
"source": None})
logger.info(f">>>Query answered successfully for .<<<")
return response
except Exception as e:
logger.error(f">>>Error in answer_query: {e} for {request.vectorstore}.<<<")
# raise HTTPException(status_code=500, detail="Internal Server Error")
raise e