Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -404,7 +404,6 @@ def summarize_web_results(query: str, search_results: List[Dict[str, str]], conv
|
|
| 404 |
|
| 405 |
def process_input(message, history, audio, model, temperature, num_calls, use_web_search, selected_docs):
|
| 406 |
if audio is not None:
|
| 407 |
-
# If audio input is provided, transcribe it
|
| 408 |
try:
|
| 409 |
transcribed_text = transcribe(audio)
|
| 410 |
print(f"Transcribed audio: {transcribed_text}")
|
|
@@ -413,11 +412,10 @@ def process_input(message, history, audio, model, temperature, num_calls, use_we
|
|
| 413 |
print(f"Error transcribing audio: {str(e)}")
|
| 414 |
return f"Error transcribing audio: {str(e)}", history
|
| 415 |
|
| 416 |
-
# Now call the existing respond function with the message (either text or transcribed audio)
|
| 417 |
return respond(message, history, model, temperature, num_calls, use_web_search, selected_docs)
|
| 418 |
|
| 419 |
-
# Modify the existing respond function to handle both PDF and web search
|
| 420 |
def respond(message, history, model, temperature, num_calls, use_web_search, selected_docs):
|
|
|
|
| 421 |
logging.info(f"User Query: {message}")
|
| 422 |
logging.info(f"Model Used: {model}")
|
| 423 |
logging.info(f"Selected Documents: {selected_docs}")
|
|
@@ -699,6 +697,13 @@ with gr.Blocks() as demo:
|
|
| 699 |
gr.CheckboxGroup(label="Select documents to query"),
|
| 700 |
audio_input
|
| 701 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
title="AI-powered PDF Chat and Web Search Assistant",
|
| 703 |
description="Chat with your PDFs, use web search to answer questions, or speak your query.",
|
| 704 |
theme=gr.themes.Soft(
|
|
@@ -729,16 +734,7 @@ with gr.Blocks() as demo:
|
|
| 729 |
cache_examples=False,
|
| 730 |
analytics_enabled=False,
|
| 731 |
textbox=gr.Textbox(placeholder="Ask a question about the uploaded PDFs or any topic", container=False, scale=7),
|
| 732 |
-
chatbot = gr.Chatbot(
|
| 733 |
-
show_copy_button=True,
|
| 734 |
-
likeable=True,
|
| 735 |
-
layout="bubble",
|
| 736 |
-
height=400,
|
| 737 |
-
value=initial_conversation()
|
| 738 |
-
)
|
| 739 |
)
|
| 740 |
-
# Add file upload functionality
|
| 741 |
-
# Add file upload functionality
|
| 742 |
with demo:
|
| 743 |
gr.Markdown("## Upload and Manage PDF Documents")
|
| 744 |
with gr.Row():
|
|
|
|
| 404 |
|
| 405 |
def process_input(message, history, audio, model, temperature, num_calls, use_web_search, selected_docs):
|
| 406 |
if audio is not None:
|
|
|
|
| 407 |
try:
|
| 408 |
transcribed_text = transcribe(audio)
|
| 409 |
print(f"Transcribed audio: {transcribed_text}")
|
|
|
|
| 412 |
print(f"Error transcribing audio: {str(e)}")
|
| 413 |
return f"Error transcribing audio: {str(e)}", history
|
| 414 |
|
|
|
|
| 415 |
return respond(message, history, model, temperature, num_calls, use_web_search, selected_docs)
|
| 416 |
|
|
|
|
| 417 |
def respond(message, history, model, temperature, num_calls, use_web_search, selected_docs):
|
| 418 |
+
|
| 419 |
logging.info(f"User Query: {message}")
|
| 420 |
logging.info(f"Model Used: {model}")
|
| 421 |
logging.info(f"Selected Documents: {selected_docs}")
|
|
|
|
| 697 |
gr.CheckboxGroup(label="Select documents to query"),
|
| 698 |
audio_input
|
| 699 |
],
|
| 700 |
+
chatbot=gr.Chatbot(
|
| 701 |
+
show_copy_button=True,
|
| 702 |
+
likeable=True,
|
| 703 |
+
layout="bubble",
|
| 704 |
+
height=400,
|
| 705 |
+
value=initial_conversation()
|
| 706 |
+
),
|
| 707 |
title="AI-powered PDF Chat and Web Search Assistant",
|
| 708 |
description="Chat with your PDFs, use web search to answer questions, or speak your query.",
|
| 709 |
theme=gr.themes.Soft(
|
|
|
|
| 734 |
cache_examples=False,
|
| 735 |
analytics_enabled=False,
|
| 736 |
textbox=gr.Textbox(placeholder="Ask a question about the uploaded PDFs or any topic", container=False, scale=7),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 737 |
)
|
|
|
|
|
|
|
| 738 |
with demo:
|
| 739 |
gr.Markdown("## Upload and Manage PDF Documents")
|
| 740 |
with gr.Row():
|