Shreyas094 commited on
Commit
bb5e4b6
·
verified ·
1 Parent(s): c5fdf7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -40
app.py CHANGED
@@ -243,7 +243,7 @@ def retry_last_response(history, use_web_search, model, temperature, num_calls):
243
 
244
  return chatbot_interface(last_user_msg, history, use_web_search, model, temperature, num_calls)
245
 
246
- def respond(message, history, model, temperature, num_calls, use_web_search, selected_docs):
247
  logging.info(f"User Query: {message}")
248
  logging.info(f"Model Used: {model}")
249
  logging.info(f"Search Type: {'Web Search' if use_web_search else 'PDF Search'}")
@@ -481,47 +481,50 @@ document_selector = gr.CheckboxGroup(label="Select documents to query")
481
 
482
  use_web_search = gr.Checkbox(label="Use Web Search", value=True)
483
 
484
- demo = gr.ChatInterface(
485
- respond,
486
- additional_inputs=[
487
- gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[3]),
488
- gr.Slider(minimum=0.1, maximum=1.0, value=0.2, step=0.1, label="Temperature"),
489
- gr.Slider(minimum=1, maximum=5, value=1, step=1, label="Number of API Calls"),
490
- use_web_search,
491
- document_selector # Add the document selector to the chat interface
492
- ],
493
- title="AI-powered Web Search and PDF Chat Assistant",
494
- description="Chat with your PDFs or use web search to answer questions (Please use toggle under Additional Inputs to swithc between PDF and Web Search, Default Value Web Search)",
495
- theme=gr.themes.Soft(
496
- primary_hue="orange",
497
- secondary_hue="amber",
498
- neutral_hue="gray",
499
- font=[gr.themes.GoogleFont("Exo"), "ui-sans-serif", "system-ui", "sans-serif"]
500
- ).set(
501
- body_background_fill_dark="#0c0505",
502
- block_background_fill_dark="#0c0505",
503
- block_border_width="1px",
504
- block_title_background_fill_dark="#1b0f0f",
505
- input_background_fill_dark="#140b0b",
506
- button_secondary_background_fill_dark="#140b0b",
507
- border_color_accent_dark="#1b0f0f",
508
- border_color_primary_dark="#1b0f0f",
509
- background_fill_secondary_dark="#0c0505",
510
- color_accent_soft_dark="transparent",
511
- code_background_fill_dark="#140b0b"
512
- ),
513
- css=css,
514
- examples=[
515
- ["Tell me about the contents of the uploaded PDFs."],
516
- ["What are the main topics discussed in the documents?"],
517
- ["Can you summarize the key points from the PDFs?"]
518
- ],
519
- cache_examples=False,
520
- analytics_enabled=False,
521
- )
522
 
523
- # Add file upload functionality
524
  with demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  gr.Markdown("## Upload PDF Documents")
526
 
527
  with gr.Row():
 
243
 
244
  return chatbot_interface(last_user_msg, history, use_web_search, model, temperature, num_calls)
245
 
246
+ def respond(message, history, model, temperature, num_calls, selected_docs, use_web_search):
247
  logging.info(f"User Query: {message}")
248
  logging.info(f"Model Used: {model}")
249
  logging.info(f"Search Type: {'Web Search' if use_web_search else 'PDF Search'}")
 
481
 
482
  use_web_search = gr.Checkbox(label="Use Web Search", value=True)
483
 
484
+ demo = gr.Blocks()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
 
 
486
  with demo:
487
+ chatbot = gr.ChatInterface(
488
+ respond,
489
+ additional_inputs=[
490
+ gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[3]),
491
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.2, step=0.1, label="Temperature"),
492
+ gr.Slider(minimum=1, maximum=5, value=1, step=1, label="Number of API Calls"),
493
+ document_selector # Add the document selector to the chat interface
494
+ ],
495
+ title="AI-powered Web Search and PDF Chat Assistant",
496
+ description="Chat with your PDFs or use web search to answer questions",
497
+ theme=gr.themes.Soft(
498
+ primary_hue="orange",
499
+ secondary_hue="amber",
500
+ neutral_hue="gray",
501
+ font=[gr.themes.GoogleFont("Exo"), "ui-sans-serif", "system-ui", "sans-serif"]
502
+ ).set(
503
+ body_background_fill_dark="#0c0505",
504
+ block_background_fill_dark="#0c0505",
505
+ block_border_width="1px",
506
+ block_title_background_fill_dark="#1b0f0f",
507
+ input_background_fill_dark="#140b0b",
508
+ button_secondary_background_fill_dark="#140b0b",
509
+ border_color_accent_dark="#1b0f0f",
510
+ border_color_primary_dark="#1b0f0f",
511
+ background_fill_secondary_dark="#0c0505",
512
+ color_accent_soft_dark="transparent",
513
+ code_background_fill_dark="#140b0b"
514
+ ),
515
+ css=css,
516
+ examples=[
517
+ ["Tell me about the contents of the uploaded PDFs."],
518
+ ["What are the main topics discussed in the documents?"],
519
+ ["Can you summarize the key points from the PDFs?"]
520
+ ],
521
+ cache_examples=False,
522
+ analytics_enabled=False,
523
+ )
524
+
525
+ use_web_search = gr.Checkbox(label="Use Web Search", value=True)
526
+
527
+ # Add file upload functionality
528
  gr.Markdown("## Upload PDF Documents")
529
 
530
  with gr.Row():