from fastapi import FastAPI from fastapi.openapi.docs import get_swagger_ui_html from data_models.models import SearchQuery from services import SearchService from data.data_loader import load_data app = FastAPI(docs_url=None, redoc_url=None) # Initiating SearchService search_service = SearchService() # Loading data from serialized file embd_id = load_data() # Ingesting data into VectorDB search_service.ingest_data(embd_id) @app.get("/") async def root(): return {"message": "Welcome to the Search API"} @app.get("/docs", include_in_schema=False) async def custom_swagger_ui_html(): return get_swagger_ui_html( openapi_url="/openapi.json", title="API Docs", oauth2_redirect_url=None, swagger_js_url="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js", swagger_css_url="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css", ) @app.post("/search") async def search(query: SearchQuery): return search_service.search(query.user_search_query) if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=7860) # # main.py # from fastapi import FastAPI # from data_models.models import SearchQuery # from services import SearchService # from data.data_loader import load_data # #Initiating FastAPI # app = FastAPI() # #Initaiting SearchService # search_service = SearchService() # #Loading data from serialized file # embd_id = load_data() # #Ingesting data into VectorDB # search_service.ingest_data(embd_id) # @app.post("/search") # async def search(query: SearchQuery): # return search_service.search(query.user_search_query) # if __name__ == "__main__": # import uvicorn # uvicorn.run(app, host="0.0.0.0", port=7860)