Spaces:
Runtime error
Runtime error
added timeout and concurrency
Browse files
app.py
CHANGED
|
@@ -30,12 +30,13 @@ async def predict(input, history):
|
|
| 30 |
"""
|
| 31 |
Gradio Blocks low-level API that allows to create custom web applications (here our chat app)
|
| 32 |
"""
|
| 33 |
-
with gr.Blocks() as
|
| 34 |
-
logger.info("Starting
|
| 35 |
chatbot = gr.Chatbot(label="Allofresh Assistant")
|
| 36 |
state = gr.State([])
|
| 37 |
with gr.Row():
|
| 38 |
txt = gr.Textbox(show_label=False, placeholder="Enter text, then press enter").style(container=False)
|
| 39 |
txt.submit(predict, [txt, state], [chatbot, state])
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
| 30 |
"""
|
| 31 |
Gradio Blocks low-level API that allows to create custom web applications (here our chat app)
|
| 32 |
"""
|
| 33 |
+
with gr.Blocks() as app:
|
| 34 |
+
logger.info("Starting app...")
|
| 35 |
chatbot = gr.Chatbot(label="Allofresh Assistant")
|
| 36 |
state = gr.State([])
|
| 37 |
with gr.Row():
|
| 38 |
txt = gr.Textbox(show_label=False, placeholder="Enter text, then press enter").style(container=False)
|
| 39 |
txt.submit(predict, [txt, state], [chatbot, state])
|
| 40 |
|
| 41 |
+
app.queue(concurrency_count=4)
|
| 42 |
+
app.launch()
|
utils.py
CHANGED
|
@@ -7,7 +7,10 @@ load_dotenv()
|
|
| 7 |
ALLOFRESH_SEARCH_API_BASE = os.getenv("ALLOFRESH_SEARCH_API_BASE")
|
| 8 |
|
| 9 |
def search_allo_api(query, limit=3):
|
| 10 |
-
response = requests.get(
|
|
|
|
|
|
|
|
|
|
| 11 |
return json.loads(response.text)
|
| 12 |
|
| 13 |
def lctool_search_allo_api(queries):
|
|
|
|
| 7 |
ALLOFRESH_SEARCH_API_BASE = os.getenv("ALLOFRESH_SEARCH_API_BASE")
|
| 8 |
|
| 9 |
def search_allo_api(query, limit=3):
|
| 10 |
+
response = requests.get(
|
| 11 |
+
f'{ALLOFRESH_SEARCH_API_BASE}?keyword={query}&limit={limit}&p=1',
|
| 12 |
+
timeout=120
|
| 13 |
+
)
|
| 14 |
return json.loads(response.text)
|
| 15 |
|
| 16 |
def lctool_search_allo_api(queries):
|