Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -335,21 +335,6 @@ def initialize_agent_with_prompt(prompt_template):
|
|
| 335 |
)
|
| 336 |
return agent
|
| 337 |
|
| 338 |
-
# def generate_answer(message, choice):
|
| 339 |
-
# logging.debug(f"generate_answer called with prompt_choice: {choice}")
|
| 340 |
-
|
| 341 |
-
# if choice == "Details":
|
| 342 |
-
# agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_1)
|
| 343 |
-
# elif choice == "Conversational":
|
| 344 |
-
# agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_2)
|
| 345 |
-
# else:
|
| 346 |
-
# logging.error(f"Invalid prompt_choice: {choice}. Defaulting to 'Conversational'")
|
| 347 |
-
# agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_2)
|
| 348 |
-
# response = agent(message)
|
| 349 |
-
|
| 350 |
-
# addresses = extract_addresses(response['output'])
|
| 351 |
-
# return response['output'], addresses
|
| 352 |
-
|
| 353 |
def generate_answer(message, choice):
|
| 354 |
logging.debug(f"generate_answer called with prompt_choice: {choice}")
|
| 355 |
|
|
@@ -363,29 +348,9 @@ def generate_answer(message, choice):
|
|
| 363 |
response = agent(message)
|
| 364 |
|
| 365 |
addresses = extract_addresses(response['output'])
|
| 366 |
-
return
|
| 367 |
|
| 368 |
-
# def bot(history, choice, tts_choice):
|
| 369 |
-
# if not history:
|
| 370 |
-
# return history
|
| 371 |
-
# response_pair, addresses = generate_answer(history[-1][0], choice)
|
| 372 |
-
# history[-1] = response_pair # Update bot response correctly
|
| 373 |
|
| 374 |
-
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 375 |
-
# if tts_choice == "Alpha":
|
| 376 |
-
# audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
|
| 377 |
-
# elif tts_choice == "Beta":
|
| 378 |
-
# audio_future = executor.submit(generate_audio_parler_tts, response_pair[1])
|
| 379 |
-
# elif tts_choice == "Gamma":
|
| 380 |
-
# audio_future = executor.submit(generate_audio_mars5, response_pair[1])
|
| 381 |
-
|
| 382 |
-
# for character in response_pair[1]:
|
| 383 |
-
# history[-1][1] += character
|
| 384 |
-
# time.sleep(0.05)
|
| 385 |
-
# yield history, None
|
| 386 |
-
|
| 387 |
-
# audio_path = audio_future.result()
|
| 388 |
-
# yield history, audio_path
|
| 389 |
|
| 390 |
def bot(history, choice, tts_choice):
|
| 391 |
if not history:
|
|
@@ -410,18 +375,13 @@ def bot(history, choice, tts_choice):
|
|
| 410 |
yield history, audio_path
|
| 411 |
|
| 412 |
|
|
|
|
|
|
|
| 413 |
def add_message(history, message):
|
| 414 |
history = history or []
|
| 415 |
history.append([message, ""]) # Ensure it is a list with two elements: message and empty response
|
| 416 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
| 417 |
-
|
| 418 |
-
# history.append((message, None))
|
| 419 |
-
# return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
| 420 |
-
|
| 421 |
-
# def add_message(history, message):
|
| 422 |
-
# history = history or []
|
| 423 |
-
# history.append((message, None))
|
| 424 |
-
# return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
| 425 |
|
| 426 |
# def generate_voice_response(history, tts_choice):
|
| 427 |
# if not history:
|
|
|
|
| 335 |
)
|
| 336 |
return agent
|
| 337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
def generate_answer(message, choice):
|
| 339 |
logging.debug(f"generate_answer called with prompt_choice: {choice}")
|
| 340 |
|
|
|
|
| 348 |
response = agent(message)
|
| 349 |
|
| 350 |
addresses = extract_addresses(response['output'])
|
| 351 |
+
return response['output'], addresses
|
| 352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
|
| 355 |
def bot(history, choice, tts_choice):
|
| 356 |
if not history:
|
|
|
|
| 375 |
yield history, audio_path
|
| 376 |
|
| 377 |
|
| 378 |
+
|
| 379 |
+
|
| 380 |
def add_message(history, message):
|
| 381 |
history = history or []
|
| 382 |
history.append([message, ""]) # Ensure it is a list with two elements: message and empty response
|
| 383 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
| 384 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
|
| 386 |
# def generate_voice_response(history, tts_choice):
|
| 387 |
# if not history:
|