Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -403,6 +403,10 @@ def respond(message, history, model, temperature, num_calls, use_web_search, sel
|
|
403 |
if not message:
|
404 |
return history + [(None, "No query provided. Please try again.")]
|
405 |
|
|
|
|
|
|
|
|
|
406 |
logging.info(f"User Query: {message}")
|
407 |
logging.info(f"Model Used: {model}")
|
408 |
logging.info(f"Selected Documents: {selected_docs}")
|
@@ -646,7 +650,8 @@ def transcribe(audio_file):
|
|
646 |
def transcribe_and_respond(audio_file, history, model, temperature, num_calls, use_web_search, document_selector):
|
647 |
transcription = transcribe(audio_file)
|
648 |
logging.info(f"Transcription result: {transcription}")
|
649 |
-
|
|
|
650 |
return history + [(None, transcription)]
|
651 |
|
652 |
# Extract the actual transcribed text
|
@@ -656,16 +661,17 @@ def transcribe_and_respond(audio_file, history, model, temperature, num_calls, u
|
|
656 |
query = transcription.strip()
|
657 |
else:
|
658 |
return history + [(None, "Error: Unexpected transcription format")]
|
|
|
659 |
logging.info(f"Query extracted from transcription: {query}")
|
660 |
|
661 |
# Use the transcription as the query
|
662 |
new_history = list(respond(query, history, model, temperature, num_calls, use_web_search, document_selector))
|
663 |
|
|
|
|
|
664 |
# Ensure the query is properly displayed in the chat history
|
665 |
if new_history and new_history[-1][0] != query:
|
666 |
-
new_history
|
667 |
-
new_history[-2] = (None, new_history[-2][1]) # Remove duplicate response
|
668 |
-
logging.info(f"New history after response: {new_history}")
|
669 |
|
670 |
return new_history
|
671 |
|
|
|
403 |
if not message:
|
404 |
return history + [(None, "No query provided. Please try again.")]
|
405 |
|
406 |
+
# Remove any path-like prefixes from the message
|
407 |
+
message = message.split('/')[-1] if '/' in message else message
|
408 |
+
|
409 |
+
|
410 |
logging.info(f"User Query: {message}")
|
411 |
logging.info(f"Model Used: {model}")
|
412 |
logging.info(f"Selected Documents: {selected_docs}")
|
|
|
650 |
def transcribe_and_respond(audio_file, history, model, temperature, num_calls, use_web_search, document_selector):
|
651 |
transcription = transcribe(audio_file)
|
652 |
logging.info(f"Transcription result: {transcription}")
|
653 |
+
|
654 |
+
if transcription == "No audio recorded. Please speak into the microphone and try again.":
|
655 |
return history + [(None, transcription)]
|
656 |
|
657 |
# Extract the actual transcribed text
|
|
|
661 |
query = transcription.strip()
|
662 |
else:
|
663 |
return history + [(None, "Error: Unexpected transcription format")]
|
664 |
+
|
665 |
logging.info(f"Query extracted from transcription: {query}")
|
666 |
|
667 |
# Use the transcription as the query
|
668 |
new_history = list(respond(query, history, model, temperature, num_calls, use_web_search, document_selector))
|
669 |
|
670 |
+
logging.info(f"New history after response: {new_history}")
|
671 |
+
|
672 |
# Ensure the query is properly displayed in the chat history
|
673 |
if new_history and new_history[-1][0] != query:
|
674 |
+
new_history[-1] = (query, new_history[-1][1])
|
|
|
|
|
675 |
|
676 |
return new_history
|
677 |
|