Skip to content

Commit 66753d7

Browse files
committed
Bug fix for latency display
1 parent f5bed56 commit 66753d7

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

fastrag/demo_ui.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def chat(chatbot_history):
5252
elapsed_time = end_time-start_time
5353
logger.info(f"Chat API executed in {elapsed_time:.4f} seconds")
5454

55-
return chatbot_history, f"## Latency of Last Response: {elapsed_time:.4f} seconds"
55+
yield chatbot_history, f"## Latency of Last Response: {elapsed_time:.4f} seconds"
5656

5757

5858
def get_conversation_history(collection_name: str="qna_collection", limit: int=10, max_retries: int=5, retry_delay: int=2):
@@ -110,7 +110,10 @@ def load_chatbot():
110110
history = get_conversation_history()
111111
return gr.update(value=history, visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=False)
112112

113-
113+
def dummy_return():
114+
return "## Generation Stopped by User"
115+
116+
114117
def run():
115118
with gr.Blocks() as demo:
116119
# Header with a professional title and subtitle
@@ -168,7 +171,7 @@ def run():
168171
outputs=[chatbot, latency_display]
169172
)
170173

171-
stop_btn.click(fn=lambda: "## Generation Stopped by User", inputs=None, outputs=latency_display, cancels=[click_event, submit_event])
174+
stop_btn.click(fn=dummy_return, outputs=[latency_display], cancels=[click_event, submit_event])
172175

173176

174177

fastrag/notebooks/qdrant_sandbox.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
40-
"qdrant_database.load_recent_responses(collection_name=collection_name, limit=10)"
40+
"qdrant_database.load_recent_responses(collection_name=collection_name, limit=20)"
4141
]
4242
},
4343
{
@@ -47,7 +47,7 @@
4747
"outputs": [],
4848
"source": [
4949
"# qdrant_database.add_response(collection_name, \"what are you doing?\", \"I am studying\")\n",
50-
"qdrant_database.add_response(collection_name, \"tell me about Nepal\", \"It is a beautiful country.\")"
50+
"qdrant_database.add_response(collection_name, \"tell me about Bib\", \"It is a country.\")"
5151
]
5252
},
5353
{

fastrag/utilities/qdrant_database.py

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def load_recent_responses(self, collection_name, limit: int=10):
5151
with_payload=True
5252
)[0]
5353

54+
print(len(search_results))
55+
5456
return [response.payload for response in search_results[-limit:]]
5557

5658
def delete_collection(self, collection_name):

0 commit comments

Comments
 (0)