Pijush2023 commited on
Commit
f993109
·
verified ·
1 Parent(s): 0f9e27e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -24
app.py CHANGED
@@ -1305,26 +1305,20 @@ def fetch_google_flights(departure_id="JFK", arrival_id="BHM", outbound_date=cur
1305
  # demo.queue()
1306
  # demo.launch(show_error=True)
1307
 
1308
-
1309
- import gradio as gr
1310
-
1311
- # List of example prompts
1312
  example_prompts = [
1313
- "What are some top restaurants in Birmingham?",
1314
- "Tell me about the weather today in Birmingham.",
1315
- "What events are happening in Birmingham today?",
1316
- "Can you suggest some hotels in Birmingham?",
1317
- "Give me information on flights from JFK to Birmingham."
1318
  ]
1319
 
1320
- # JavaScript to handle click event and insert the text into the input box
1321
- js_code = """
1322
- function insertPrompt(text) {
1323
- var inputBox = document.querySelector('#chat-input textarea');
1324
- inputBox.value = text;
1325
- }
1326
- """
1327
 
 
1328
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1329
  with gr.Row():
1330
  with gr.Column():
@@ -1339,15 +1333,11 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1339
 
1340
  gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
1341
 
1342
- # Example Prompts in a table format
1343
- example_prompts_html = "<h3>Example Prompts:</h3><table>"
1344
- for prompt in example_prompts:
1345
- example_prompts_html += f"<tr><td><a href='javascript:void(0);' onclick=\"insertPrompt('{prompt}');\">{prompt}</a></td></tr>"
1346
- example_prompts_html += "</table>"
1347
 
1348
- gr.HTML(example_prompts_html, elem_id="example-prompts")
1349
-
1350
- chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="Hey Radar...!!", elem_id="chat-input")
1351
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta"], value="Alpha")
1352
  retriever_button = gr.Button("Retriever")
1353
 
@@ -1391,3 +1381,5 @@ demo.queue()
1391
  demo.launch(show_error=True)
1392
 
1393
 
 
 
 
1305
  # demo.queue()
1306
  # demo.launch(show_error=True)
1307
 
1308
+ # Define example prompts
 
 
 
1309
  example_prompts = [
1310
+ ["What are the best restaurants in Birmingham?"],
1311
+ ["Can you suggest a good hotel in Birmingham for a family stay?"],
1312
+ ["What events are happening in Birmingham today?"],
1313
+ ["Tell me about some popular tourist spots in Birmingham."],
1314
+ ["What is the weather like in Birmingham today?"]
1315
  ]
1316
 
1317
+ # Function to handle the insertion of example prompts into the input textbox
1318
+ def insert_example_prompt(example):
1319
+ return gr.Textbox.update(value=example)
 
 
 
 
1320
 
1321
+ # Your existing Gradio Blocks interface
1322
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1323
  with gr.Row():
1324
  with gr.Column():
 
1333
 
1334
  gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
1335
 
1336
+ # Example prompts component
1337
+ gr.Markdown("<h2>Example Prompts</h2>")
1338
+ gr.Examples(examples=example_prompts, fn=insert_example_prompt, inputs=None, outputs="chat_input")
 
 
1339
 
1340
+ chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="Hey Radar...!!")
 
 
1341
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta"], value="Alpha")
1342
  retriever_button = gr.Button("Retriever")
1343
 
 
1381
  demo.launch(show_error=True)
1382
 
1383
 
1384
+
1385
+