Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,6 +83,17 @@ def update_count_html():
|
|
| 83 |
</div>
|
| 84 |
""")
|
| 85 |
return count_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
def add_text(history, text):
|
| 88 |
history = [] if history is None else history
|
|
@@ -120,6 +131,7 @@ def bot(history, cross_encoder):
|
|
| 120 |
history[-1][1] = character
|
| 121 |
print('Final history is ',history)
|
| 122 |
yield history, prompt_html
|
|
|
|
| 123 |
else:
|
| 124 |
# Retrieve documents relevant to query
|
| 125 |
document_start = perf_counter()
|
|
@@ -162,6 +174,7 @@ def bot(history, cross_encoder):
|
|
| 162 |
history[-1][1] = character
|
| 163 |
print('Final history is ',history)
|
| 164 |
yield history, prompt_html
|
|
|
|
| 165 |
|
| 166 |
|
| 167 |
with gr.Blocks(theme='Insuz/SimpleIndigo') as demo:
|
|
|
|
| 83 |
</div>
|
| 84 |
""")
|
| 85 |
return count_html
|
| 86 |
+
|
| 87 |
+
def store_message(db,query,answer,cross_encoder):
|
| 88 |
+
new_completion = db.collection('Nirvachana').document('chatlogs')
|
| 89 |
+
new_completion.set({
|
| 90 |
+
'query': query,
|
| 91 |
+
'answer':answer,
|
| 92 |
+
'created_time': firestore.SERVER_TIMESTAMP,
|
| 93 |
+
'embedding': cross_encoder,
|
| 94 |
+
'title': 'Expenditure observer bot'
|
| 95 |
+
})
|
| 96 |
+
|
| 97 |
|
| 98 |
def add_text(history, text):
|
| 99 |
history = [] if history is None else history
|
|
|
|
| 131 |
history[-1][1] = character
|
| 132 |
print('Final history is ',history)
|
| 133 |
yield history, prompt_html
|
| 134 |
+
store_message(db,history[-1][0],history[-1][1],cross_encoder)
|
| 135 |
else:
|
| 136 |
# Retrieve documents relevant to query
|
| 137 |
document_start = perf_counter()
|
|
|
|
| 174 |
history[-1][1] = character
|
| 175 |
print('Final history is ',history)
|
| 176 |
yield history, prompt_html
|
| 177 |
+
store_message(db,history[-1][0],history[-1][1],cross_encoder)
|
| 178 |
|
| 179 |
|
| 180 |
with gr.Blocks(theme='Insuz/SimpleIndigo') as demo:
|