Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,6 +45,7 @@ phi_agent = create_phi_agent()
|
|
| 45 |
|
| 46 |
# Response Generation
|
| 47 |
def retrieve_and_generate_response(query, cross_encoder_choice, history=None):
|
|
|
|
| 48 |
top_rerank = 25
|
| 49 |
top_k_rank = 20
|
| 50 |
|
|
@@ -54,6 +55,7 @@ def retrieve_and_generate_response(query, cross_encoder_choice, history=None):
|
|
| 54 |
try:
|
| 55 |
start_time = perf_counter()
|
| 56 |
query_vec = retriever.encode(query)
|
|
|
|
| 57 |
documents = table.search(query_vec, vector_column_name="vector").limit(top_rerank).to_list()
|
| 58 |
documents = [doc["text"] for doc in documents]
|
| 59 |
|
|
@@ -135,6 +137,7 @@ with gr.Blocks(title="Science Chatbot", theme='gradio/soft') as chatbot_app:
|
|
| 135 |
clear = gr.Button("Clear")
|
| 136 |
|
| 137 |
def chatbot_func(query, cross_encoder, history=[]):
|
|
|
|
| 138 |
if not query.strip():
|
| 139 |
gr.Warning("Please submit a non-empty question")
|
| 140 |
return "", history
|
|
@@ -147,10 +150,8 @@ with gr.Blocks(title="Science Chatbot", theme='gradio/soft') as chatbot_app:
|
|
| 147 |
return "", history
|
| 148 |
|
| 149 |
submit_btn.click(
|
| 150 |
-
chatbot_func,
|
| 151 |
-
|
| 152 |
-
outputs=[query, chatbot],
|
| 153 |
-
queue=False
|
| 154 |
)
|
| 155 |
# query.submit(
|
| 156 |
# chatbot_func,
|
|
|
|
| 45 |
|
| 46 |
# Response Generation
|
| 47 |
def retrieve_and_generate_response(query, cross_encoder_choice, history=None):
|
| 48 |
+
print('hitry ', history)
|
| 49 |
top_rerank = 25
|
| 50 |
top_k_rank = 20
|
| 51 |
|
|
|
|
| 55 |
try:
|
| 56 |
start_time = perf_counter()
|
| 57 |
query_vec = retriever.encode(query)
|
| 58 |
+
print('query vector ', query_vec)
|
| 59 |
documents = table.search(query_vec, vector_column_name="vector").limit(top_rerank).to_list()
|
| 60 |
documents = [doc["text"] for doc in documents]
|
| 61 |
|
|
|
|
| 137 |
clear = gr.Button("Clear")
|
| 138 |
|
| 139 |
def chatbot_func(query, cross_encoder, history=[]):
|
| 140 |
+
print('function called')
|
| 141 |
if not query.strip():
|
| 142 |
gr.Warning("Please submit a non-empty question")
|
| 143 |
return "", history
|
|
|
|
| 150 |
return "", history
|
| 151 |
|
| 152 |
submit_btn.click(
|
| 153 |
+
chatbot_func,[query, cross_encoder, chatbot],[query, chatbot],
|
| 154 |
+
#queue=False
|
|
|
|
|
|
|
| 155 |
)
|
| 156 |
# query.submit(
|
| 157 |
# chatbot_func,
|