bardd commited on
Commit
6eb1f69
·
verified ·
1 Parent(s): 9ce5a85
Files changed (1) hide show
  1. main.py +45 -6
main.py CHANGED
@@ -1,21 +1,34 @@
1
- # main.py
2
  from fastapi import FastAPI
 
3
  from data_models.models import SearchQuery
4
  from services import SearchService
5
  from data.data_loader import load_data
6
 
7
- #Initiating FastAPI
8
- app = FastAPI()
9
 
10
- #Initaiting SearchService
11
  search_service = SearchService()
12
 
13
- #Loading data from serialized file
14
  embd_id = load_data()
15
 
16
- #Ingesting data into VectorDB
17
  search_service.ingest_data(embd_id)
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  @app.post("/search")
20
  async def search(query: SearchQuery):
21
  return search_service.search(query.user_search_query)
@@ -23,3 +36,29 @@ async def search(query: SearchQuery):
23
  if __name__ == "__main__":
24
  import uvicorn
25
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
+ from fastapi.openapi.docs import get_swagger_ui_html
3
  from data_models.models import SearchQuery
4
  from services import SearchService
5
  from data.data_loader import load_data
6
 
7
+ app = FastAPI(docs_url=None, redoc_url=None)
 
8
 
9
+ # Initiating SearchService
10
  search_service = SearchService()
11
 
12
+ # Loading data from serialized file
13
  embd_id = load_data()
14
 
15
+ # Ingesting data into VectorDB
16
  search_service.ingest_data(embd_id)
17
 
18
+ @app.get("/")
19
+ async def root():
20
+ return {"message": "Welcome to the Search API"}
21
+
22
+ @app.get("/docs", include_in_schema=False)
23
+ async def custom_swagger_ui_html():
24
+ return get_swagger_ui_html(
25
+ openapi_url="/openapi.json",
26
+ title="API Docs",
27
+ oauth2_redirect_url=None,
28
+ swagger_js_url="https://unpkg.com/[email protected]/swagger-ui-bundle.js",
29
+ swagger_css_url="https://unpkg.com/[email protected]/swagger-ui.css",
30
+ )
31
+
32
  @app.post("/search")
33
  async def search(query: SearchQuery):
34
  return search_service.search(query.user_search_query)
 
36
  if __name__ == "__main__":
37
  import uvicorn
38
  uvicorn.run(app, host="0.0.0.0", port=7860)
39
+
40
+ # # main.py
41
+ # from fastapi import FastAPI
42
+ # from data_models.models import SearchQuery
43
+ # from services import SearchService
44
+ # from data.data_loader import load_data
45
+
46
+ # #Initiating FastAPI
47
+ # app = FastAPI()
48
+
49
+ # #Initaiting SearchService
50
+ # search_service = SearchService()
51
+
52
+ # #Loading data from serialized file
53
+ # embd_id = load_data()
54
+
55
+ # #Ingesting data into VectorDB
56
+ # search_service.ingest_data(embd_id)
57
+
58
+ # @app.post("/search")
59
+ # async def search(query: SearchQuery):
60
+ # return search_service.search(query.user_search_query)
61
+
62
+ # if __name__ == "__main__":
63
+ # import uvicorn
64
+ # uvicorn.run(app, host="0.0.0.0", port=7860)