from fastapi import FastAPI from pydantic import BaseModel import uvicorn # Import all your chatbot setup functions and initializations here from model_on_cli import qa_bot # Adjust this import based on your setup app = FastAPI() class UserQuestion(BaseModel): question: str qa_instance = qa_bot() @app.post("/ask/") async def ask_question(user_question: UserQuestion): response = qa_instance({'query': user_question.question}) return {"response": response['result']} # if __name__ == "__main__": # # Specify host as '0.0.0.0' to make the server accessible from other devices on the network # uvicorn.run("api:app", host="0.0.0.0", port=8001, reload=True)