NCTCMumbai
commited on
Commit
•
1a697d9
1
Parent(s):
c16129d
Update app.py
Browse files
app.py
CHANGED
@@ -53,6 +53,7 @@ def bot(history, api_kind):
|
|
53 |
top_rerank = 15
|
54 |
top_k_rank = 8
|
55 |
query = history[-1][0]
|
|
|
56 |
|
57 |
if not query:
|
58 |
gr.Warning("Please submit a non-empty string as a prompt")
|
@@ -66,12 +67,12 @@ def bot(history, api_kind):
|
|
66 |
print(query)
|
67 |
query_vec_flat = [arr.flatten() for arr in query_vec]
|
68 |
logger.warning(f'Finished query vec')
|
69 |
-
|
70 |
|
71 |
|
72 |
|
73 |
logger.warning(f'Finished search')
|
74 |
-
documents = table.search(query_vec, vector_column_name=VECTOR_COLUMN_NAME).limit(top_rerank).to_list()
|
75 |
documents = [doc[TEXT_COLUMN_NAME] for doc in documents]
|
76 |
logger.warning(f'start cross encoder {len(documents)}')
|
77 |
# Retrieve documents relevant to query
|
@@ -151,10 +152,12 @@ with gr.Blocks() as demo:
|
|
151 |
|
152 |
# Turn it back on
|
153 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
158 |
|
159 |
# Turn it back on
|
160 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
|
|
53 |
top_rerank = 15
|
54 |
top_k_rank = 8
|
55 |
query = history[-1][0]
|
56 |
+
print('history[-1][0]',history[-1][0])
|
57 |
|
58 |
if not query:
|
59 |
gr.Warning("Please submit a non-empty string as a prompt")
|
|
|
67 |
print(query)
|
68 |
query_vec_flat = [arr.flatten() for arr in query_vec]
|
69 |
logger.warning(f'Finished query vec')
|
70 |
+
documents = table.search(query_vec_flat, vector_column_name=VECTOR_COLUMN_NAME).limit(top_k_rank).to_list()
|
71 |
|
72 |
|
73 |
|
74 |
logger.warning(f'Finished search')
|
75 |
+
#documents = table.search(query_vec, vector_column_name=VECTOR_COLUMN_NAME).limit(top_rerank).to_list()
|
76 |
documents = [doc[TEXT_COLUMN_NAME] for doc in documents]
|
77 |
logger.warning(f'start cross encoder {len(documents)}')
|
78 |
# Retrieve documents relevant to query
|
|
|
152 |
|
153 |
# Turn it back on
|
154 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
155 |
+
try:
|
156 |
+
# Turn off interactivity while generating if you hit enter
|
157 |
+
txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
|
158 |
+
bot, [chatbot, api_kind], [chatbot, prompt_html])
|
159 |
+
except Exception as e:
|
160 |
+
print ('Exception ' ,str(e))
|
161 |
|
162 |
# Turn it back on
|
163 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|