Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -400,6 +400,9 @@ def summarize_web_results(query: str, search_results: List[Dict[str, str]], conv
|
|
400 |
|
401 |
# Modify the existing respond function to handle both PDF and web search
|
402 |
def respond(message, history, model, temperature, num_calls, use_web_search, selected_docs):
|
|
|
|
|
|
|
403 |
logging.info(f"User Query: {message}")
|
404 |
logging.info(f"Model Used: {model}")
|
405 |
logging.info(f"Selected Documents: {selected_docs}")
|
@@ -645,8 +648,22 @@ def transcribe_and_respond(audio_file, history, model, temperature, num_calls, u
|
|
645 |
if transcription.startswith("Error in transcription:"):
|
646 |
return history + [(None, transcription)]
|
647 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
648 |
# Use the transcription as the query
|
649 |
-
new_history = respond(
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
return new_history
|
651 |
|
652 |
def vote(data: gr.LikeData):
|
|
|
400 |
|
401 |
# Modify the existing respond function to handle both PDF and web search
|
402 |
def respond(message, history, model, temperature, num_calls, use_web_search, selected_docs):
|
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}")
|
|
|
648 |
if transcription.startswith("Error in transcription:"):
|
649 |
return history + [(None, transcription)]
|
650 |
|
651 |
+
# Extract the actual transcribed text
|
652 |
+
if isinstance(transcription, dict) and "text" in transcription:
|
653 |
+
query = transcription["text"].strip()
|
654 |
+
elif isinstance(transcription, str):
|
655 |
+
query = transcription.strip()
|
656 |
+
else:
|
657 |
+
return history + [(None, "Error: Unexpected transcription format")]
|
658 |
+
|
659 |
# Use the transcription as the query
|
660 |
+
new_history = list(respond(query, history, model, temperature, num_calls, use_web_search, document_selector))
|
661 |
+
|
662 |
+
# Ensure the query is properly displayed in the chat history
|
663 |
+
if new_history and new_history[-1][0] != query:
|
664 |
+
new_history.append((query, new_history[-1][1]))
|
665 |
+
new_history[-2] = (None, new_history[-2][1]) # Remove duplicate response
|
666 |
+
|
667 |
return new_history
|
668 |
|
669 |
def vote(data: gr.LikeData):
|