Spaces:
Sleeping
Sleeping
Commit ·
1074e67
1
Parent(s): 95996d9
updated pacakages and gradio
Browse files
app.py
CHANGED
|
@@ -333,19 +333,13 @@ def chat_interface(message, history):
|
|
| 333 |
"""Handle chat interface with error handling"""
|
| 334 |
try:
|
| 335 |
# Handle input formatting
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
user_input = message[-1].get("content", "")
|
| 339 |
-
else:
|
| 340 |
-
user_input = message[-1]
|
| 341 |
-
else:
|
| 342 |
-
user_input = str(message)
|
| 343 |
-
|
| 344 |
# Prepare inputs
|
| 345 |
inputs = {
|
| 346 |
"query": user_input,
|
| 347 |
"all_queries": [user_input],
|
| 348 |
-
"all_texts":
|
| 349 |
"k_per_query": 3,
|
| 350 |
"alpha": 0.7,
|
| 351 |
"vectorstore": vectorstore,
|
|
@@ -411,7 +405,7 @@ with gr.Blocks(css="""
|
|
| 411 |
for chunk in chat_interface(message, chat_history):
|
| 412 |
bot_message = chunk
|
| 413 |
# Update last message in history
|
| 414 |
-
if chat_history:
|
| 415 |
chat_history[-1] = (message, bot_message)
|
| 416 |
else:
|
| 417 |
chat_history.append((message, bot_message))
|
|
@@ -441,5 +435,5 @@ if __name__ == "__main__":
|
|
| 441 |
print(f"Vectorstore type: {type(vectorstore)}")
|
| 442 |
print(f"All chunks count: {len(all_chunks)}")
|
| 443 |
|
| 444 |
-
# Launch
|
| 445 |
demo.launch(debug=True)
|
|
|
|
| 333 |
"""Handle chat interface with error handling"""
|
| 334 |
try:
|
| 335 |
# Handle input formatting
|
| 336 |
+
user_input = message
|
| 337 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
# Prepare inputs
|
| 339 |
inputs = {
|
| 340 |
"query": user_input,
|
| 341 |
"all_queries": [user_input],
|
| 342 |
+
"all_texts": all_texts,
|
| 343 |
"k_per_query": 3,
|
| 344 |
"alpha": 0.7,
|
| 345 |
"vectorstore": vectorstore,
|
|
|
|
| 405 |
for chunk in chat_interface(message, chat_history):
|
| 406 |
bot_message = chunk
|
| 407 |
# Update last message in history
|
| 408 |
+
if chat_history and len(chat_history) > 0:
|
| 409 |
chat_history[-1] = (message, bot_message)
|
| 410 |
else:
|
| 411 |
chat_history.append((message, bot_message))
|
|
|
|
| 435 |
print(f"Vectorstore type: {type(vectorstore)}")
|
| 436 |
print(f"All chunks count: {len(all_chunks)}")
|
| 437 |
|
| 438 |
+
# Launch the application
|
| 439 |
demo.launch(debug=True)
|