daniel-was-taken commited on
Commit
b4f6cc7
ยท
1 Parent(s): b73a785

Remove unnecessary GPU decorators from functions in app.py and clean up whitespace in server.py

Browse files
Files changed (2) hide show
  1. app.py +5 -5
  2. server.py +0 -3
app.py CHANGED
@@ -94,7 +94,7 @@ class LibraryManager:
94
  library.sort(key=lambda x: x.get('likes', 0), reverse=True)
95
  return [[b['title'], b['author'], b['genre'], b['likes'], b['id'], b.get('content', ''), b.get('pdf_filename', '')] for b in library]
96
 
97
- @spaces.GPU
98
  def create_typeset_pdf(title, author, raw_text):
99
  filename = f"novel_{uuid.uuid4().hex[:6]}.pdf"
100
  doc = SimpleDocTemplate(filename, pagesize=letter, rightMargin=72, leftMargin=72, topMargin=72, bottomMargin=72)
@@ -306,18 +306,18 @@ async def _ui_wrapper(*args):
306
  # --- SOCIAL FUNCTIONS ---
307
  lib_mgr = LibraryManager()
308
 
309
- @spaces.GPU
310
  def submit_novel_to_lib(user_title, user_author, auto_title, raw_text, pdf_path):
311
  if not raw_text: return "Error: No content to publish."
312
  final_title = user_title if user_title.strip() else auto_title
313
  final_author = user_author if user_author.strip() else "Anonymous"
314
  return lib_mgr.save_novel(final_title, final_author, "Mixed", raw_text, pdf_path)
315
 
316
- @spaces.GPU
317
  def refresh_library():
318
  return lib_mgr.get_leaderboard()
319
 
320
- @spaces.GPU
321
  def select_book_from_leaderboard(evt: gr.SelectData, current_data):
322
  # FIX: Use iloc for position-based access to avoid warnings
323
  row_data = current_data.iloc[evt.index[0]]
@@ -335,7 +335,7 @@ def select_book_from_leaderboard(evt: gr.SelectData, current_data):
335
 
336
  return pdf_path, novel_id, f"๐Ÿ“– Reading: {novel_title}"
337
 
338
- @spaces.GPU
339
  def vote_current_book(novel_id, liked_session, request: gr.Request):
340
  if not novel_id: return None, "No book selected!", None
341
  return lib_mgr.like_novel(novel_id, liked_session, request)
 
94
  library.sort(key=lambda x: x.get('likes', 0), reverse=True)
95
  return [[b['title'], b['author'], b['genre'], b['likes'], b['id'], b.get('content', ''), b.get('pdf_filename', '')] for b in library]
96
 
97
+
98
  def create_typeset_pdf(title, author, raw_text):
99
  filename = f"novel_{uuid.uuid4().hex[:6]}.pdf"
100
  doc = SimpleDocTemplate(filename, pagesize=letter, rightMargin=72, leftMargin=72, topMargin=72, bottomMargin=72)
 
306
  # --- SOCIAL FUNCTIONS ---
307
  lib_mgr = LibraryManager()
308
 
309
+
310
  def submit_novel_to_lib(user_title, user_author, auto_title, raw_text, pdf_path):
311
  if not raw_text: return "Error: No content to publish."
312
  final_title = user_title if user_title.strip() else auto_title
313
  final_author = user_author if user_author.strip() else "Anonymous"
314
  return lib_mgr.save_novel(final_title, final_author, "Mixed", raw_text, pdf_path)
315
 
316
+
317
  def refresh_library():
318
  return lib_mgr.get_leaderboard()
319
 
320
+
321
  def select_book_from_leaderboard(evt: gr.SelectData, current_data):
322
  # FIX: Use iloc for position-based access to avoid warnings
323
  row_data = current_data.iloc[evt.index[0]]
 
335
 
336
  return pdf_path, novel_id, f"๐Ÿ“– Reading: {novel_title}"
337
 
338
+
339
  def vote_current_book(novel_id, liked_session, request: gr.Request):
340
  if not novel_id: return None, "No book selected!", None
341
  return lib_mgr.like_novel(novel_id, liked_session, request)
server.py CHANGED
@@ -212,8 +212,6 @@ def fetch_elevenlabs_data_tool(api_key: str) -> str:
212
  return json.dumps({"Error": str(e)})
213
 
214
 
215
-
216
-
217
  fastapi_mcp_app = FastAPI(root_path=os.environ.get("SPACE_ROOT_PATH", ""))
218
 
219
 
@@ -229,7 +227,6 @@ fastapi_mcp_app.mount("/mcp", mcp_asgi_app)
229
 
230
  app = gr.mount_gradio_app(fastapi_mcp_app, demo, path="/")
231
 
232
-
233
  if __name__ == "__main__":
234
  port = int(os.getenv("PORT", 7860))
235
  print(f"running on http://0.0.0.0:{port}")
 
212
  return json.dumps({"Error": str(e)})
213
 
214
 
 
 
215
  fastapi_mcp_app = FastAPI(root_path=os.environ.get("SPACE_ROOT_PATH", ""))
216
 
217
 
 
227
 
228
  app = gr.mount_gradio_app(fastapi_mcp_app, demo, path="/")
229
 
 
230
  if __name__ == "__main__":
231
  port = int(os.getenv("PORT", 7860))
232
  print(f"running on http://0.0.0.0:{port}")