Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,7 +40,13 @@ available_models = [] # to be filled in later
|
|
| 40 |
|
| 41 |
def display_chat_history(model_selections):
|
| 42 |
eval_item = sample_an_eval_result(eval_results, model_selections)
|
|
|
|
| 43 |
task = eval_item["task"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
if eval_item["image"]:
|
| 45 |
image_path = eval_item["image"]
|
| 46 |
else:
|
|
@@ -53,12 +59,13 @@ def display_chat_history(model_selections):
|
|
| 53 |
chats_ground += [item_user, item_asst]
|
| 54 |
chats_plan = [(chats_plan[i], chats_plan[i+1]) for i in range(0, len(chats_plan), 2)]
|
| 55 |
chats_ground = [(chats_ground[i], chats_ground[i+1]) for i in range(0, len(chats_ground), 2)]
|
|
|
|
| 56 |
|
| 57 |
if image_path != "":
|
| 58 |
image = f'<div style="text-align: center;"> <img src="{image_path}" style="height: 250px;"> </div>'
|
| 59 |
-
return task, chats_plan, chats_ground, image
|
| 60 |
else:
|
| 61 |
-
return task, chats_plan, chats_ground, f'<div style="text-align: center;"> </div>'
|
| 62 |
|
| 63 |
|
| 64 |
|
|
@@ -118,6 +125,12 @@ def build_demo(TYPES):
|
|
| 118 |
image = gr.HTML("", elem_id="input_image")
|
| 119 |
image.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
with gr.Row():
|
| 122 |
with gr.Column():
|
| 123 |
gr.Markdown("## ๐ข Plan Module Process History", elem_classes="markdown-text")
|
|
@@ -127,9 +140,25 @@ def build_demo(TYPES):
|
|
| 127 |
gr.Markdown("## ๐ข Ground Module Process History", elem_classes="markdown-text")
|
| 128 |
Chatbot_Common_Ground = gr.Chatbot(avatar_images=["human_icon.jpeg", "ai_icon.png"], height="auto", container=False, label="Common Ground History", likeable=False, show_share_button=False, show_label=True, elem_classes="chat-common", layout="bubble")
|
| 129 |
Chatbot_Common_Ground.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
# Display chat history when button is clicked
|
| 132 |
-
btn_show_history.click(fn=display_chat_history, inputs=[selected_models], outputs=[task, Chatbot_Common_Plan, Chatbot_Common_Ground, image])
|
| 133 |
|
| 134 |
with gr.TabItem("๐ฎ About Us", elem_id="od-benchmark-tab-table", id=3):
|
| 135 |
gr.Markdown(ABOUT_MD, elem_classes="markdown-text")
|
|
|
|
| 40 |
|
| 41 |
def display_chat_history(model_selections):
|
| 42 |
eval_item = sample_an_eval_result(eval_results, model_selections)
|
| 43 |
+
session_id = eval_item["session_id"]
|
| 44 |
task = eval_item["task"]
|
| 45 |
+
task_type = eval_item["task_type"]
|
| 46 |
+
prediction = eval_item["pred"]
|
| 47 |
+
gold_answer = eval_item["answer"]
|
| 48 |
+
correctness = eval_item["correctness"]
|
| 49 |
+
|
| 50 |
if eval_item["image"]:
|
| 51 |
image_path = eval_item["image"]
|
| 52 |
else:
|
|
|
|
| 59 |
chats_ground += [item_user, item_asst]
|
| 60 |
chats_plan = [(chats_plan[i], chats_plan[i+1]) for i in range(0, len(chats_plan), 2)]
|
| 61 |
chats_ground = [(chats_ground[i], chats_ground[i+1]) for i in range(0, len(chats_ground), 2)]
|
| 62 |
+
task_metadata = f"- ๐: `{session_id}` \n- **Task category**: {task_type}"
|
| 63 |
|
| 64 |
if image_path != "":
|
| 65 |
image = f'<div style="text-align: center;"> <img src="{image_path}" style="height: 250px;"> </div>'
|
| 66 |
+
return task, chats_plan, chats_ground, task_metadata, prediction, gold_answer, correctness, image
|
| 67 |
else:
|
| 68 |
+
return task, chats_plan, chats_ground, task_metadata, prediction, gold_answer, correctness, f'<div style="text-align: center;"> </div>'
|
| 69 |
|
| 70 |
|
| 71 |
|
|
|
|
| 125 |
image = gr.HTML("", elem_id="input_image")
|
| 126 |
image.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 127 |
|
| 128 |
+
with gr.Row():
|
| 129 |
+
with gr.Column():
|
| 130 |
+
with gr.Accordion("๐ Task Metadata", open=False, elem_classes="accordion-label"):
|
| 131 |
+
task_metadata = gr.Markdown("", elem_classes="markdown-text-tiny")
|
| 132 |
+
task_metadata.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 133 |
+
|
| 134 |
with gr.Row():
|
| 135 |
with gr.Column():
|
| 136 |
gr.Markdown("## ๐ข Plan Module Process History", elem_classes="markdown-text")
|
|
|
|
| 140 |
gr.Markdown("## ๐ข Ground Module Process History", elem_classes="markdown-text")
|
| 141 |
Chatbot_Common_Ground = gr.Chatbot(avatar_images=["human_icon.jpeg", "ai_icon.png"], height="auto", container=False, label="Common Ground History", likeable=False, show_share_button=False, show_label=True, elem_classes="chat-common", layout="bubble")
|
| 142 |
Chatbot_Common_Ground.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 143 |
+
|
| 144 |
+
with gr.Row():
|
| 145 |
+
with gr.Column():
|
| 146 |
+
with gr.Accordion("๐ Prediction", open=True, elem_classes="accordion-label"):
|
| 147 |
+
prediction = gr.Markdown("", elem_classes="markdown-text-tiny")
|
| 148 |
+
prediction.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 149 |
+
|
| 150 |
+
with gr.Column():
|
| 151 |
+
with gr.Accordion("๐ Ground-Truth Answer", open=True, elem_classes="accordion-label"):
|
| 152 |
+
gold_answer = gr.HTML("", elem_id="ground-truth-answer")
|
| 153 |
+
gold_answer.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 154 |
+
|
| 155 |
+
with gr.Column():
|
| 156 |
+
with gr.Accordion("Correctness", open=True, elem_classes="accordion-label"):
|
| 157 |
+
correctness = gr.HTML("", elem_id="correct-or-not")
|
| 158 |
+
correctness.change(lambda x: x, inputs=[], outputs=[], scroll_to_output=False, js=js_code)
|
| 159 |
|
| 160 |
# Display chat history when button is clicked
|
| 161 |
+
btn_show_history.click(fn=display_chat_history, inputs=[selected_models], outputs=[task, Chatbot_Common_Plan, Chatbot_Common_Ground, task_metadata, prediction, gold_answer, correctness, image])
|
| 162 |
|
| 163 |
with gr.TabItem("๐ฎ About Us", elem_id="od-benchmark-tab-table", id=3):
|
| 164 |
gr.Markdown(ABOUT_MD, elem_classes="markdown-text")
|