will33am commited on
Commit
91e1297
1 Parent(s): 5d994d6
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -5,6 +5,7 @@ from gradio import ChatMessage
5
 
6
  DATASETS_LIST = [("Self-GRIT/tuluv2-expanded-150k-part_v0-chat-format-syn-knowledge","part_v0")]
7
  DATASETS = {f"{name}: {split}":load_dataset(name,split = split) for name,split in DATASETS_LIST}
 
8
  KEY_MESSAGES_ORIGINAL = "messages_original"
9
  KEY_MESSAGES_AUGMENTED = "messages_augmented"
10
 
@@ -16,9 +17,10 @@ def return_conversation_chat_message(history: List[Dict]):
16
 
17
  def update_chatbot(value,dataset_name):
18
  example = DATASETS[dataset_name][int(value)]
 
19
  oring_chat_history = return_conversation_chat_message(example[KEY_MESSAGES_ORIGINAL])
20
  augmented_chat_history = return_conversation_chat_message(example[KEY_MESSAGES_AUGMENTED])
21
- return oring_chat_history,augmented_chat_history
22
 
23
  with gr.Blocks() as demo:
24
  with gr.Group():
@@ -26,8 +28,13 @@ with gr.Blocks() as demo:
26
  with gr.Column():
27
  dropdown = gr.Dropdown(DATASETS.keys(), label="Select the dataset")
28
  with gr.Column():
29
- slider = gr.Slider(minimum=0, maximum=100, step=1, label="Select the example")
30
  with gr.Group():
 
 
 
 
 
31
  with gr.Row():
32
  gr.Markdown("Original Chat")
33
  with gr.Row():
@@ -37,5 +44,5 @@ with gr.Blocks() as demo:
37
  gr.Markdown("Augmented Chat")
38
  with gr.Row():
39
  chatbot_augmented = gr.Chatbot(type = "messages")
40
- slider.change(fn=update_chatbot, inputs=[slider,dropdown], outputs=[chatbot_original,chatbot_augmented])
41
  demo.launch()
 
5
 
6
  DATASETS_LIST = [("Self-GRIT/tuluv2-expanded-150k-part_v0-chat-format-syn-knowledge","part_v0")]
7
  DATASETS = {f"{name}: {split}":load_dataset(name,split = split) for name,split in DATASETS_LIST}
8
+ LENS = {name:len(dataset) for name,dataset in DATASETS.items()}
9
  KEY_MESSAGES_ORIGINAL = "messages_original"
10
  KEY_MESSAGES_AUGMENTED = "messages_augmented"
11
 
 
17
 
18
  def update_chatbot(value,dataset_name):
19
  example = DATASETS[dataset_name][int(value)]
20
+ domain,_id = example["dataset"],example["id"]
21
  oring_chat_history = return_conversation_chat_message(example[KEY_MESSAGES_ORIGINAL])
22
  augmented_chat_history = return_conversation_chat_message(example[KEY_MESSAGES_AUGMENTED])
23
+ return oring_chat_history,augmented_chat_history,domain,_id
24
 
25
  with gr.Blocks() as demo:
26
  with gr.Group():
 
28
  with gr.Column():
29
  dropdown = gr.Dropdown(DATASETS.keys(), label="Select the dataset")
30
  with gr.Column():
31
+ slider = gr.Slider(minimum=0, maximum=48127, step=1, label="Select the example")
32
  with gr.Group():
33
+ with gr.Row():
34
+ with gr.Column():
35
+ domain_text = gr.Textbox("Domain")
36
+ with gr.Column():
37
+ id_text = gr.Textbox("ID")
38
  with gr.Row():
39
  gr.Markdown("Original Chat")
40
  with gr.Row():
 
44
  gr.Markdown("Augmented Chat")
45
  with gr.Row():
46
  chatbot_augmented = gr.Chatbot(type = "messages")
47
+ slider.change(fn=update_chatbot, inputs=[slider,dropdown], outputs=[chatbot_original,chatbot_augmented,domain_text,id_text])
48
  demo.launch()