Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1208,125 +1208,47 @@ def fetch_google_flights(departure_id="JFK", arrival_id="BHM", outbound_date=cur
|
|
1208 |
return flight_info
|
1209 |
|
1210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1211 |
|
|
|
|
|
1212 |
|
1213 |
-
# with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
1214 |
-
# with gr.Row():
|
1215 |
-
# with gr.Column():
|
1216 |
-
# state = gr.State()
|
1217 |
-
|
1218 |
-
# chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
1219 |
-
# choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
1220 |
-
# retrieval_mode = gr.Radio(label="Retrieval Mode", choices=["VDB", "KGF"], value="VDB")
|
1221 |
-
# model_choice = gr.Dropdown(label="Choose Model", choices=["LM-1", "LM-2"], value="LM-1")
|
1222 |
-
|
1223 |
-
# # Link the dropdown change to handle_model_choice_change
|
1224 |
-
# model_choice.change(fn=handle_model_choice_change, inputs=model_choice, outputs=[retrieval_mode, choice, choice])
|
1225 |
-
|
1226 |
-
# gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
1227 |
-
|
1228 |
-
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="Hey Radar...!!")
|
1229 |
-
# tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta"], value="Alpha")
|
1230 |
-
# retriever_button = gr.Button("Retriever")
|
1231 |
-
|
1232 |
-
# clear_button = gr.Button("Clear")
|
1233 |
-
# clear_button.click(lambda: [None, None], outputs=[chat_input, state])
|
1234 |
-
|
1235 |
-
# gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
1236 |
-
# location_output = gr.HTML()
|
1237 |
-
# audio_output = gr.Audio(interactive=False, autoplay=True)
|
1238 |
-
|
1239 |
-
# def stop_audio():
|
1240 |
-
# audio_output.stop()
|
1241 |
-
# return None
|
1242 |
-
|
1243 |
-
|
1244 |
-
# # retriever_sequence = (
|
1245 |
-
# # retriever_button.click(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording")
|
1246 |
-
# # .then(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory")
|
1247 |
-
# # .then(fn=bot, inputs=[chatbot, choice, tts_choice, retrieval_mode, model_choice], outputs=[chatbot, audio_output], api_name="api_askchatbot_then_generateaudio")
|
1248 |
-
# # .then(fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details")
|
1249 |
-
# # .then(fn=clear_textbox, inputs=[], outputs=[chat_input],api_name="api_clear_textbox")
|
1250 |
-
# # )
|
1251 |
-
|
1252 |
-
# retriever_sequence = (
|
1253 |
-
# retriever_button.click(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording")
|
1254 |
-
# .then(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory")
|
1255 |
-
# # First, generate the bot response
|
1256 |
-
# .then(fn=generate_bot_response, inputs=[chatbot, choice, retrieval_mode, model_choice], outputs=[chatbot], api_name="api_generate_bot_response")
|
1257 |
-
# # Then, generate the TTS response based on the bot's response
|
1258 |
-
# .then(fn=generate_tts_response, inputs=[chatbot, tts_choice], outputs=[audio_output], api_name="api_generate_tts_response")
|
1259 |
-
# .then(fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details")
|
1260 |
-
# .then(fn=clear_textbox, inputs=[], outputs=[chat_input], api_name="api_clear_textbox")
|
1261 |
-
# )
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
# # chat_input.submit(fn=stop_audio, inputs=[], outputs=[audio_output],api_name="api_stop_audio_recording")
|
1269 |
-
# # chat_input.submit(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory").then(
|
1270 |
-
# # fn=bot, inputs=[chatbot, choice, tts_choice, retrieval_mode, model_choice], outputs=[chatbot, audio_output], api_name="api_askchatbot_then_generateaudio"
|
1271 |
-
# # ).then(
|
1272 |
-
# # fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details"
|
1273 |
-
# # ).then(
|
1274 |
-
# # fn=clear_textbox, inputs=[], outputs=[chat_input],api_name="api_clear_textbox"
|
1275 |
-
# # )
|
1276 |
-
|
1277 |
-
# chat_input.submit(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording").then(
|
1278 |
-
# fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory"
|
1279 |
-
# ).then(
|
1280 |
-
# # First, generate the bot response
|
1281 |
-
# fn=generate_bot_response, inputs=[chatbot, choice, retrieval_mode, model_choice], outputs=[chatbot], api_name="api_generate_bot_response"
|
1282 |
-
# ).then(
|
1283 |
-
# # Then, generate the TTS response based on the bot's response
|
1284 |
-
# fn=generate_tts_response, inputs=[chatbot, tts_choice], outputs=[audio_output], api_name="api_generate_tts_response"
|
1285 |
-
# ).then(
|
1286 |
-
# fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details"
|
1287 |
-
# ).then(
|
1288 |
-
# fn=clear_textbox, inputs=[], outputs=[chat_input], api_name="api_clear_textbox"
|
1289 |
-
# )
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy', every=0.1)
|
1298 |
-
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="api_voice_to_text")
|
1299 |
-
|
1300 |
-
# with gr.Column():
|
1301 |
-
# weather_output = gr.HTML(value=fetch_local_weather())
|
1302 |
-
# news_output = gr.HTML(value=fetch_local_news())
|
1303 |
-
# events_output = gr.HTML(value=fetch_local_events())
|
1304 |
-
|
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 the best restaurants in Birmingham?",
|
1314 |
-
"Tell me about the weather in Birmingham today.",
|
1315 |
-
"What events are happening in Birmingham this weekend?",
|
1316 |
-
"Can you recommend a hotel in Birmingham?",
|
1317 |
-
"What flights are available from JFK to Birmingham?",
|
1318 |
-
"Give me a list of the top attractions in Birmingham.",
|
1319 |
-
"What's the best time to visit Birmingham?",
|
1320 |
-
"Tell me about the history of Birmingham, Alabama.",
|
1321 |
-
"What are some outdoor activities in Birmingham?",
|
1322 |
-
"Can you suggest a good coffee shop in Birmingham?"
|
1323 |
-
]
|
1324 |
|
1325 |
-
# Function to insert the selected prompt into the input textbox
|
1326 |
-
def insert_prompt(selected_prompt):
|
1327 |
-
return gr.Textbox.update(value=selected_prompt)
|
1328 |
|
1329 |
-
# Gradio interface
|
1330 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
1331 |
with gr.Row():
|
1332 |
with gr.Column():
|
@@ -1337,6 +1259,7 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
1337 |
retrieval_mode = gr.Radio(label="Retrieval Mode", choices=["VDB", "KGF"], value="VDB")
|
1338 |
model_choice = gr.Dropdown(label="Choose Model", choices=["LM-1", "LM-2"], value="LM-1")
|
1339 |
|
|
|
1340 |
model_choice.change(fn=handle_model_choice_change, inputs=model_choice, outputs=[retrieval_mode, choice, choice])
|
1341 |
|
1342 |
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
@@ -1345,11 +1268,6 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
1345 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta"], value="Alpha")
|
1346 |
retriever_button = gr.Button("Retriever")
|
1347 |
|
1348 |
-
# Example Prompts Table
|
1349 |
-
gr.Markdown("<h2 style='color: blue;'>Helpful Prompts</h2>")
|
1350 |
-
for prompt in example_prompts:
|
1351 |
-
gr.Button(prompt).click(fn=insert_prompt, inputs=prompt, outputs=chat_input)
|
1352 |
-
|
1353 |
clear_button = gr.Button("Clear")
|
1354 |
clear_button.click(lambda: [None, None], outputs=[chat_input, state])
|
1355 |
|
@@ -1361,20 +1279,47 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
1361 |
audio_output.stop()
|
1362 |
return None
|
1363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1364 |
retriever_sequence = (
|
1365 |
retriever_button.click(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording")
|
1366 |
.then(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory")
|
|
|
1367 |
.then(fn=generate_bot_response, inputs=[chatbot, choice, retrieval_mode, model_choice], outputs=[chatbot], api_name="api_generate_bot_response")
|
|
|
1368 |
.then(fn=generate_tts_response, inputs=[chatbot, tts_choice], outputs=[audio_output], api_name="api_generate_tts_response")
|
1369 |
.then(fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details")
|
1370 |
.then(fn=clear_textbox, inputs=[], outputs=[chat_input], api_name="api_clear_textbox")
|
1371 |
)
|
1372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1373 |
chat_input.submit(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording").then(
|
1374 |
fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory"
|
1375 |
).then(
|
|
|
1376 |
fn=generate_bot_response, inputs=[chatbot, choice, retrieval_mode, model_choice], outputs=[chatbot], api_name="api_generate_bot_response"
|
1377 |
).then(
|
|
|
1378 |
fn=generate_tts_response, inputs=[chatbot, tts_choice], outputs=[audio_output], api_name="api_generate_tts_response"
|
1379 |
).then(
|
1380 |
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details"
|
@@ -1382,9 +1327,17 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
1382 |
fn=clear_textbox, inputs=[], outputs=[chat_input], api_name="api_clear_textbox"
|
1383 |
)
|
1384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1385 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy', every=0.1)
|
1386 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="api_voice_to_text")
|
1387 |
|
|
|
|
|
1388 |
with gr.Column():
|
1389 |
weather_output = gr.HTML(value=fetch_local_weather())
|
1390 |
news_output = gr.HTML(value=fetch_local_news())
|
@@ -1396,3 +1349,6 @@ demo.launch(show_error=True)
|
|
1396 |
|
1397 |
|
1398 |
|
|
|
|
|
|
|
|
1208 |
return flight_info
|
1209 |
|
1210 |
|
1211 |
+
examples = [
|
1212 |
+
[
|
1213 |
+
"What are the concerts in Birmingham?",
|
1214 |
+
],
|
1215 |
+
[
|
1216 |
+
"what are some of the upcoming matches of crimson tide?",
|
1217 |
+
],
|
1218 |
+
[
|
1219 |
+
"where from i will get a Hamburger?",
|
1220 |
+
],
|
1221 |
+
[
|
1222 |
+
"What are some of the hotels at birmingham?",
|
1223 |
+
],
|
1224 |
+
[
|
1225 |
+
"how can i connect the alexa to the radio?"
|
1226 |
+
],
|
1227 |
+
[
|
1228 |
+
"What are some of the good clubs at birmingham?"
|
1229 |
+
],
|
1230 |
+
[
|
1231 |
+
"How do I call the radio station?",
|
1232 |
+
],
|
1233 |
+
[
|
1234 |
+
"What’s the spread?"
|
1235 |
+
],
|
1236 |
+
[
|
1237 |
+
"What time is Crimson Tide Rewind?"
|
1238 |
+
],
|
1239 |
+
[
|
1240 |
+
"What time is Alabama kick-off?"
|
1241 |
+
],
|
1242 |
+
[
|
1243 |
+
"who are some of the popular players of crimson tide?"
|
1244 |
+
]
|
1245 |
+
]
|
1246 |
|
1247 |
+
def insert_prompt(prompt):
|
1248 |
+
return prompt[0]
|
1249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1250 |
|
|
|
|
|
|
|
1251 |
|
|
|
1252 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
1253 |
with gr.Row():
|
1254 |
with gr.Column():
|
|
|
1259 |
retrieval_mode = gr.Radio(label="Retrieval Mode", choices=["VDB", "KGF"], value="VDB")
|
1260 |
model_choice = gr.Dropdown(label="Choose Model", choices=["LM-1", "LM-2"], value="LM-1")
|
1261 |
|
1262 |
+
# Link the dropdown change to handle_model_choice_change
|
1263 |
model_choice.change(fn=handle_model_choice_change, inputs=model_choice, outputs=[retrieval_mode, choice, choice])
|
1264 |
|
1265 |
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
|
|
1268 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta"], value="Alpha")
|
1269 |
retriever_button = gr.Button("Retriever")
|
1270 |
|
|
|
|
|
|
|
|
|
|
|
1271 |
clear_button = gr.Button("Clear")
|
1272 |
clear_button.click(lambda: [None, None], outputs=[chat_input, state])
|
1273 |
|
|
|
1279 |
audio_output.stop()
|
1280 |
return None
|
1281 |
|
1282 |
+
|
1283 |
+
# retriever_sequence = (
|
1284 |
+
# retriever_button.click(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording")
|
1285 |
+
# .then(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory")
|
1286 |
+
# .then(fn=bot, inputs=[chatbot, choice, tts_choice, retrieval_mode, model_choice], outputs=[chatbot, audio_output], api_name="api_askchatbot_then_generateaudio")
|
1287 |
+
# .then(fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details")
|
1288 |
+
# .then(fn=clear_textbox, inputs=[], outputs=[chat_input],api_name="api_clear_textbox")
|
1289 |
+
# )
|
1290 |
+
|
1291 |
retriever_sequence = (
|
1292 |
retriever_button.click(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording")
|
1293 |
.then(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory")
|
1294 |
+
# First, generate the bot response
|
1295 |
.then(fn=generate_bot_response, inputs=[chatbot, choice, retrieval_mode, model_choice], outputs=[chatbot], api_name="api_generate_bot_response")
|
1296 |
+
# Then, generate the TTS response based on the bot's response
|
1297 |
.then(fn=generate_tts_response, inputs=[chatbot, tts_choice], outputs=[audio_output], api_name="api_generate_tts_response")
|
1298 |
.then(fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details")
|
1299 |
.then(fn=clear_textbox, inputs=[], outputs=[chat_input], api_name="api_clear_textbox")
|
1300 |
)
|
1301 |
|
1302 |
+
|
1303 |
+
|
1304 |
+
|
1305 |
+
|
1306 |
+
|
1307 |
+
# chat_input.submit(fn=stop_audio, inputs=[], outputs=[audio_output],api_name="api_stop_audio_recording")
|
1308 |
+
# chat_input.submit(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory").then(
|
1309 |
+
# fn=bot, inputs=[chatbot, choice, tts_choice, retrieval_mode, model_choice], outputs=[chatbot, audio_output], api_name="api_askchatbot_then_generateaudio"
|
1310 |
+
# ).then(
|
1311 |
+
# fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details"
|
1312 |
+
# ).then(
|
1313 |
+
# fn=clear_textbox, inputs=[], outputs=[chat_input],api_name="api_clear_textbox"
|
1314 |
+
# )
|
1315 |
+
|
1316 |
chat_input.submit(fn=stop_audio, inputs=[], outputs=[audio_output], api_name="api_stop_audio_recording").then(
|
1317 |
fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="api_addprompt_chathistory"
|
1318 |
).then(
|
1319 |
+
# First, generate the bot response
|
1320 |
fn=generate_bot_response, inputs=[chatbot, choice, retrieval_mode, model_choice], outputs=[chatbot], api_name="api_generate_bot_response"
|
1321 |
).then(
|
1322 |
+
# Then, generate the TTS response based on the bot's response
|
1323 |
fn=generate_tts_response, inputs=[chatbot, tts_choice], outputs=[audio_output], api_name="api_generate_tts_response"
|
1324 |
).then(
|
1325 |
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="api_show_map_details"
|
|
|
1327 |
fn=clear_textbox, inputs=[], outputs=[chat_input], api_name="api_clear_textbox"
|
1328 |
)
|
1329 |
|
1330 |
+
|
1331 |
+
|
1332 |
+
|
1333 |
+
|
1334 |
+
|
1335 |
+
|
1336 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy', every=0.1)
|
1337 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="api_voice_to_text")
|
1338 |
|
1339 |
+
gr.Examples(examples=example_prompts, fn=insert_prompt, inputs=[], outputs=chat_input)
|
1340 |
+
|
1341 |
with gr.Column():
|
1342 |
weather_output = gr.HTML(value=fetch_local_weather())
|
1343 |
news_output = gr.HTML(value=fetch_local_news())
|
|
|
1349 |
|
1350 |
|
1351 |
|
1352 |
+
|
1353 |
+
|
1354 |
+
|