Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -396,7 +396,7 @@ def process_summary_with_stablemed(summary):
|
|
396 |
|
397 |
# Main function to handle the Gradio interface logic
|
398 |
|
399 |
-
def process_and_query(input_language=None, audio_input=None, image_input=None, text_input=None):
|
400 |
components['speech_to_text'].hide()
|
401 |
components['image_identification'].hide()
|
402 |
components['text_summarization'].hide()
|
@@ -444,10 +444,7 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
|
|
444 |
# Evaluate hallucination
|
445 |
hallucination_label = evaluate_hallucination(final_response, markdown_output)
|
446 |
print("Hallucination Label:", hallucination_label) # Debug print
|
447 |
-
|
448 |
state['show_results'] = True
|
449 |
-
create_interface(state) # Recreate the interface with the updated state
|
450 |
-
|
451 |
return final_response, hallucination_label
|
452 |
except Exception as e:
|
453 |
print(f"An error occurred: {e}")
|
@@ -576,16 +573,16 @@ languages = [
|
|
576 |
"Zulu"
|
577 |
]
|
578 |
|
|
|
579 |
def clear(state):
|
580 |
state['show_results'] = False
|
581 |
-
|
582 |
-
|
583 |
|
584 |
def create_interface(state):
|
585 |
with gr.Blocks(theme='ParityError/Anime') as iface:
|
586 |
with gr.Row():
|
587 |
input_language = gr.Dropdown(languages, label="Select the language", value="English", interactive=True)
|
588 |
-
input_language.change(lambda x: create_interface(
|
589 |
|
590 |
if not state.get('show_results'):
|
591 |
with gr.Accordion("Use Voice", open=False):
|
@@ -601,7 +598,7 @@ def create_interface(state):
|
|
601 |
text_output = gr.Markdown(label="Output text")
|
602 |
text_button = gr.Button("Use MultiMed")
|
603 |
hallucination_output = gr.Label(label="Hallucination Evaluation")
|
604 |
-
text_button.click(process_and_query, inputs=[
|
605 |
|
606 |
if state.get('show_results'):
|
607 |
with gr.Row():
|
@@ -609,7 +606,7 @@ def create_interface(state):
|
|
609 |
hallucination_output = gr.Label()
|
610 |
|
611 |
clear_button = gr.Button("Clear")
|
612 |
-
clear_button.click(clear, inputs=[state], outputs=[])
|
613 |
|
614 |
return iface
|
615 |
|
|
|
396 |
|
397 |
# Main function to handle the Gradio interface logic
|
398 |
|
399 |
+
def process_and_query(input_language=None, audio_input=None, image_input=None, text_input=None, state=state):
|
400 |
components['speech_to_text'].hide()
|
401 |
components['image_identification'].hide()
|
402 |
components['text_summarization'].hide()
|
|
|
444 |
# Evaluate hallucination
|
445 |
hallucination_label = evaluate_hallucination(final_response, markdown_output)
|
446 |
print("Hallucination Label:", hallucination_label) # Debug print
|
|
|
447 |
state['show_results'] = True
|
|
|
|
|
448 |
return final_response, hallucination_label
|
449 |
except Exception as e:
|
450 |
print(f"An error occurred: {e}")
|
|
|
573 |
"Zulu"
|
574 |
]
|
575 |
|
576 |
+
|
577 |
def clear(state):
|
578 |
state['show_results'] = False
|
579 |
+
return state
|
|
|
580 |
|
581 |
def create_interface(state):
|
582 |
with gr.Blocks(theme='ParityError/Anime') as iface:
|
583 |
with gr.Row():
|
584 |
input_language = gr.Dropdown(languages, label="Select the language", value="English", interactive=True)
|
585 |
+
input_language.change(lambda x: create_interface({'show_results': False}))
|
586 |
|
587 |
if not state.get('show_results'):
|
588 |
with gr.Accordion("Use Voice", open=False):
|
|
|
598 |
text_output = gr.Markdown(label="Output text")
|
599 |
text_button = gr.Button("Use MultiMed")
|
600 |
hallucination_output = gr.Label(label="Hallucination Evaluation")
|
601 |
+
text_button.click(process_and_query, inputs=[input_language, audio_input, image_input, text_input, state], outputs=[text_output, hallucination_output])
|
602 |
|
603 |
if state.get('show_results'):
|
604 |
with gr.Row():
|
|
|
606 |
hallucination_output = gr.Label()
|
607 |
|
608 |
clear_button = gr.Button("Clear")
|
609 |
+
clear_button.click(clear, inputs=[state], outputs=[state])
|
610 |
|
611 |
return iface
|
612 |
|