AnshulS commited on
Commit
54fb047
·
verified ·
1 Parent(s): 8c87630

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -6,6 +6,7 @@ from fastapi.middleware.cors import CORSMiddleware
6
  import traceback
7
  from retriever import get_relevant_passages
8
  from reranker import rerank
 
9
 
10
  # Create FastAPI app
11
  app = FastAPI()
@@ -115,8 +116,20 @@ demo = gr.Interface(
115
  )
116
 
117
  # This is the pattern for Gradio 5.x
118
- app = gr.mount_gradio_app(app, demo, path="/")
119
-
 
 
 
 
 
 
 
 
 
 
 
 
120
  # Entry point
121
  if __name__ == "__main__":
122
  import uvicorn
 
6
  import traceback
7
  from retriever import get_relevant_passages
8
  from reranker import rerank
9
+ import os
10
 
11
  # Create FastAPI app
12
  app = FastAPI()
 
116
  )
117
 
118
  # This is the pattern for Gradio 5.x
119
+ #app = gr.mount_gradio_app(app, demo, path="/")
120
+ if os.getenv("SPACE_ID"):
121
+ # We're running on HF Spaces
122
+ app = gr.mount_gradio_app(
123
+ app,
124
+ demo,
125
+ path="/",
126
+ app_kwargs={
127
+ "root_path": ""
128
+ }
129
+ )
130
+ else:
131
+ # Local development
132
+ app = gr.mount_gradio_app(app, demo, path="/")
133
  # Entry point
134
  if __name__ == "__main__":
135
  import uvicorn