yigitcanozdemir commited on
Commit
de2ae20
·
1 Parent(s): 5367bcd

Enhance recommendation API: make prediction wrapper asynchronous for improved performance

Browse files
Files changed (1) hide show
  1. components/gradio_ui.py +3 -2
components/gradio_ui.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from models.recommendation_engine import RecommendationEngine
3
  import pandas as pd
 
4
 
5
  pd.set_option("display.max_rows", 100)
6
  pd.set_option("display.max_columns", None)
@@ -59,8 +60,8 @@ def get_recommendations_api(message, engine):
59
 
60
 
61
  def create_interface(engine):
62
- def predict_wrapper(message):
63
- return get_recommendations_api(message, engine)
64
 
65
  iface = gr.Interface(
66
  fn=predict_wrapper,
 
1
  import gradio as gr
2
  from models.recommendation_engine import RecommendationEngine
3
  import pandas as pd
4
+ import asyncio
5
 
6
  pd.set_option("display.max_rows", 100)
7
  pd.set_option("display.max_columns", None)
 
60
 
61
 
62
  def create_interface(engine):
63
+ async def predict_wrapper(message):
64
+ return asyncio.to_thread(get_recommendations_api(message, engine))
65
 
66
  iface = gr.Interface(
67
  fn=predict_wrapper,