Edward Beeching commited on
Commit
cb5c850
1 Parent(s): 72994e7

created first iteration of app

Browse files
Files changed (2) hide show
  1. app.py +118 -0
  2. requirements.txt +64 -0
app.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import hashlib
3
+ import json
4
+ import os
5
+ import random
6
+ from io import BytesIO
7
+ import gradio as gr
8
+ from datasets import load_dataset
9
+ from huggingface_hub import upload_file
10
+
11
+
12
+ #dataset = {"0": {"situation": "Perry buys supplies because Perry wants to be prepared for the next task.", "role_instruction": "", "conversation_history": ["Hi there! Can I please get a pack of lined paper, a pencil case, some number two pencils, and a stapler?", "Absolutely! Let me grab those for you.", "Thank you so much!", "You're welcome. Is there anything else I can help you with today?", "Nope, that's everything for now. Thanks again!"], "n_conversations": 2, "conversations": [["Hi there! Can I please get a pack of lined paper, a pencil case, some number two pencils, and a stapler?", "Absolutely! Let me grab those for you.", "Wow, thanks, that is a bit much money for not just supplies but tools as well. Can you tell me.", "Well, you never know when you might need them! Plus, our prices are very competitive.", "I see. Thanks for your help.", "You're welcome! Have a great day!"], ["Hi there! Can I please get a pack of lined paper, a pencil case, some number two pencils, and a stapler?", "Absolutely! Let me grab those for you.", "Oh, And the notebook? I see some on here that we can afford to switch.", "We'll just need to see your ID and then I can help you get the supplies you need.", "Here you go!", "Thank you. Your total comes to $13.97."]], "trucation_length": 2, "date_generated": "01/09/2023 11:52:08"}, "1": {"situation": "Keyton picks up a guitar because Keyton wants to play the guitar.", "role_instruction": "", "conversation_history": ["Hey dad, do you know how to play this guitar?", "Yeah, I used to play all the time when I was your age.", "Really? How come you don't play now?", "I don't know. Life just got in the way, I guess. But it's never too late to start again. Why don't you give it a try?", "Alright, I will! Thanks, dad.", "So, how do I start?", "Well, let's see. Do you know how to make a G chord?", "Um... no.", "Okay, I'll show you. Put your left hand on the neck of the guitar like this, and place your right hand over the strings like this. Then, use your right hand to pluck the string while you hold down the chords with your left hand.", "Okay, I think I got it!", "Great! Now try strumming all the strings with your right hand."], "n_conversations": 2, "conversations": [["Hey dad, do you know how to play this guitar?", "Yeah, I used to play all the time when I was your age.", "Really? How come you don't play now?", "I don't know. Life just got in the way, I guess. But it's never too late to start again. Why don't you give it a try?", "Alright, I will! Thanks, dad.", "So, how do I start?", "Well, let's see. Do you know how to make a G chord?", "Um... no.", "Okay, I'll show you. Put your left hand on the neck of the guitar like this, and place your right hand over the strings like this. Then, use your right hand to pluck the string while you hold down the chords with your left hand.", "It doesn't say anything!", "It doesn't have to say anything. Just do it like this and then it will start working.", "All right, I'll try it."], ["Hey dad, do you know how to play this guitar?", "Yeah, I used to play all the time when I was your age.", "Really? How come you don't play now?", "I don't know. Life just got in the way, I guess. But it's never too late to start again. Why don't you give it a try?", "Alright, I will! Thanks, dad.", "So, how do I start?", "Well, let's see. Do you know how to make a G chord?", "Um... no.", "Okay, I'll show you. Put your left hand on the neck of the guitar like this, and place your right hand over the strings like this. Then, use your right hand to pluck the string while you hold down the chords with your left hand.", "All righty! Let's give it a try.", "You're doing great! Just keep practicing and you'll get it in no time.", "Thanks, dad! I really appreciate your help."]], "trucation_length": 9, "date_generated": "01/09/2023 11:52:09"}, "2": {"situation": "Jibril's puppy dies. Now Jibril cries.", "role_instruction": "", "conversation_history": ["Hey, Dad. Do you have a minute?", "Of course, what's up?", "I wanted to talk to you about something that's been bothering me.", "Okay, what is it?", "It's Max. I can't stop thinking about him and how he died. It was so sudden and I just feel like I didn't get to say goodbye properly.", "Oh, Jibril. I'm so sorry. I know how much you loved Max. It's hard to lose a pet, especially one that we were so close to.", "Yeah, I just wish I could have done more for him or been there for him more in his last moments.", "There's nothing you could have done, Jibril. Max was sick and there was nothing anyone could do to save him. Trust me, if there was anything that could have been done, we would have done it. You did everything you could for him and he knew that you loved him very much.", "I know. I just can't help but feel like I could have done more.", "Jibril, you have to remember that Max is in a better place now and he's not in pain anymore. Try to think of it that way and it might help you feel better.", "Yeah, I guess you're right. Thanks, Dad.", "Of course, baby. If you ever need to talk about anything, don't hesitate to come to me, okay?", "Okay."], "n_conversations": 2, "conversations": [["Hey, Dad. Do you have a minute?", "Of course, what's up?", "Remember what I said it was? About my puppy losing her fur so it starts itching in your shoes?", "Yeah...what about it?", "Well, the vet said she might have a tumor or something. But I'm really scared that she might die from it.", "Oh, Jibril...I'm so sorry. That must be really hard for you to deal with.", "It is. I just can't believe she's gone. We were supposed to get her a few months ago and now she's just...gone.", "Hey, it's okay. We'll get another puppy another time. She's not gone forever, okay? She's still with us in spirit. And we'll take care of her until she gets better, alright? Just try to stay positive, okay?", "Yeah...okay. Thanks, Dad.", "Of course, kiddo. I'm always here for you.", "Thanks, Dad.", "Anytime.", "This is just so hard. I can't believe she's gone.", "I know it is, Jibril. But like I said, she's not gone forever. We'll get another puppy another time and she'll be just fine, okay? Just try to stay positive and remember that she's still with us in spirit."], ["Hey, Dad. Do you have a minute?", "Of course, what's up?", "Well, my puppy died earlier today and I came home to do anything fun, but he was just lying next to his dead grandmother. His little stomach hurt really bad from where he perished. And not only did someone mess with him because his mom asked too much and sent him to the pound just to be sick afterwards as well. There was all that, and nothing I did made him better. And the guilt is eating away at me. Now I blame anyone who was even remotely nearby because who ever that was must think I'm incredibly angry and cruel that's what my mom will talk all too as time", "Jibril, I'm so sorry. That sounds really tough. It's normal to feel guilty when something bad happens to someone we care about. But you can't blame yourself for this. It wasn't your fault.", "But if I had just been there, maybe I could have saved him.", "Sometimes things happen that are out of our control, Jibril. We can't always predict the future.", "I know that, but it doesn't make it any easier.", "No, it doesn't. Grief is a process and it takes time. Just try to remember all the good times you had with your puppy and take comfort in knowing that he's no longer in pain now.", "Yeah, I guess you're right. Thanks, Dad.", "Anytime, son.", "I'm just really going to miss him, you know?", "I know. I'm sure you will. But like I said, grief is a process and it takes time. Just be patient and try to focus on the happy memories you have of your puppy.", "Thanks, Dad. I appreciate it.", "Of course, Jibril. Anytime."]], "trucation_length": 2, "date_generated": "01/09/2023 11:52:21"}, "3": {"situation": "Ireland studies the light. Now Ireland wants to learn more about light.", "role_instruction": "", "conversation_history": ["So light is made up of colors?", "Yes, that's right. Light is made up of different colors, and when those colors mix together, we see white light. But light can also bend and bounce off surfaces.", "How does it do that?", "When light hits a surface, it can either reflect off of the surface or refract through the surface. Reflection is when the light bounces off of the surface, and refraction is when the light bends as it passes through the surface.", "So when light reflects off of a mirror, it's because the light is bouncing off of the surface of the mirror?", "That's right. Mirrors are very good at reflecting light because they have a smooth, flat surface.", "And when light refracts through something like a prism, it's because the light is bending as it passes through the surface of the prism?", "That's right. When light passes through a prism, it bends because the Prism bends the light."], "n_conversations": 2, "conversations": [["So light is made up of colors?", "Yes, that's right. Light is made up of different colors, and when those colors mix together, we see white light. But light can also bend and bounce off surfaces.", "How does it do that?", "When light hits a surface, it can either reflect off of the surface or refract through the surface. Reflection is when the light bounces off of the surface, and refraction is when the light bends as it passes through the surface.", "So what determines which is more effective?", "Well, it depends on the amount of light hitting the surface. For example, if the surface is very absorbent, then reflection would be more effective because it would bounce back more directly into our eyes. But if the surface is very reflective, then refraction would be more effective because it would bend more than reflection would.", "So why don't we just learn about different colors then?", "Well, that's one way to do it. But there's a lot more to light than just colors. For example, light can be used to describe objects or things by their shape and size. For example, blue light is often used to describe the sky because it looks like a deep blue color. Red light is often used to describe the sun because it looks red.", "That's true! I never knew that light could be used to describe things!"], ["So light is made up of colors?", "Yes, that's right. Light is made up of different colors, and when those colors mix together, we see white light. But light can also bend and bounce off surfaces.", "How does it do that?", "When light hits a surface, it can either reflect off of the surface or refract through the surface. Reflection is when the light bounces off of the surface, and refraction is when the light bends as it passes through the surface.", "Well, when light passes through two parallel pieces of a transparent object like liquid water or even X-rays...", "Yes, exactly. And when light passes through a crystal, like a prism or a lens...", "So that's why I've seen rainbows! The light bouncing off of a rainbow is actually a reflection of the different colors in the rainbow!", "Exactly.", "But I still don't understand how light can bend and bounce off surfaces..."]], "trucation_length": 4, "date_generated": "01/09/2023 11:52:26"}, "4": {"situation": "Merle is eating in the cafeteria because Merle wants to be full.", "role_instruction": "", "conversation_history": ["Hi, can I get a cheeseburger and fries please?", "You sure can! That'll be $4.50.", "Alright, here you go.", "Thanks! So how's your day going?", "It's going okay, I'm just having a little trouble focusing. I'm really hungry, so that might be part of the problem.", "Yeah, if you're not careful, hunger can really sneak up on you! So what are you working on that's got you so distracted?", "Just some homework. I've got a test tomorrow that I'm not really prepared for.", "Oh, that sounds rough. Well, I hope you can get it all sorted out. Good luck!", "Thanks."], "n_conversations": 2, "conversations": [["Hi, can I get a cheeseburger and fries please?", "You sure can! That'll be $4.50.", "Alright, here you go.", "Thanks! So how's your day going?", "It's going okay, I'm just having a little trouble focusing. I'm really hungry, so that might be part of the problem.", "Yeah, if you're not careful, hunger can really sneak up on you! So what are you working on that's got you so distracted?", "Just a bunch of school stuff. It's been kind of overwhelming lately and sometimes it feels like my grades are starting to slip and before I know it, the rest of the semester is over, haha. But thanks for asking, it really gives me a boost at least! Plus knowing the answer in confidence helps me focus on actually doing work again! Right now the best thing feeling is getting this yummy food again, yum!", "Oh yeah, I know how you feel. School can be pretty tough sometimes but it's important to push through and stay focused. I'm sure you'll do great!", "Thanks, I hope so. I'm just glad I have you to talk to, it really helps me feel better!", "Anytime! If you ever need to talk, just let me know. I'm always here for you!"], ["Hi, can I get a cheeseburger and fries please?", "You sure can! That'll be $4.50.", "Alright, here you go.", "Thanks! So how's your day going?", "It's going okay, I'm just having a little trouble focusing. I'm really hungry, so that might be part of the problem.", "Yeah, if you're not careful, hunger can really sneak up on you! So what are you working on that's got you so distracted?", "Just some essay for class. I was thinking about reading \"The Lottery\" before hand actually because there is an upcoming election but I can't seem to find anything I like reading for this sort of assignment which sucks even moreso this is even more challenging then most people who have done stuff they're really passionate about lately... Ughhh Why do do kids have to be so loud all the time? Can't people do their thing inside for once without disturbing everyone? And now on top of that everyone wants cupcakes too why did your boss have them give such a limited variety for the", "It sounds like it's been a tough week for you, but you're doing great! Just keep at it and you'll get through it!", "Yeah...I guess you're right. Thanks for the encouragement.", "Anytime!"]], "trucation_length": 6, "date_generated": "01/09/2023 11:52:31"}, "5": {"situation": "Nader brings Lillyana a shoe. Now Nader feels helpful.", "role_instruction": "", "conversation_history": ["Hey, I found this old shoe and thought you might need it.", "Oh my gosh, thank you so much! I've been walking around barefoot all day and my feet are killing me.", "No problem, I saw you earlier and wanted to help out.", "You're so sweet, thank you again."], "n_conversations": 2, "conversations": [["Hey, I found this old shoe and thought you might need it.", "Thanks, Nader. I couldn't agree more.", "No problem. I'm just glad I could help out.", "You're always so helpful. I really appreciate it.", "It's no big deal, really. I just want to help out however I can."], ["Hey, I found this old shoe and thought you might need it.", "Hw, thanks so much! I really appreciate it.", "No problem, happy to help.", "You're always so helpful and kind. I don't know what I would do without you.", "Well, you would do fine without me, but I'm happy to help out however I can."]], "trucation_length": 1, "date_generated": "01/09/2023 11:52:33"}, "6": {"situation": "Keeton cries in the shower. Now Keeton feels upset.", "role_instruction": "", "conversation_history": ["Hey. I'm feeling really upset and frustrated right now.", "What's going on?", "I was just crying in the shower and my mind won't stop racing. I keep thinking about all the negative things in my life and I feel hopeless.", "It sounds like you're feeling overwhelmed by everything that's going on. Do you want to talk about it?", "Yeah, I guess so. It's just been really hard lately. Everything seems to be going wrong and I feel like I can't catch a break.", "I'm sorry to hear that. It sounds like you've been through a lot lately. Let's talk about it and see if we can figure out a plan to help you feel better."], "n_conversations": 2, "conversations": [["Hey. I'm feeling really upset and frustrated right now.", "What's going on?", "I was just crying in the shower and my mind won't stop racing. I keep thinking about all the negative things in my life and I feel hopeless.", "It sounds like you're feeling overwhelmed by everything that's going on. Do you want to talk about it?", "Yeah, I could use a hug. Thanks for being here for me, Kaitlyn. But talking can't change how sorry and scared I feel right now! Just hearing you listen is helping already, thank you! Okay cool if let me pour those feelings into something.... where do i know how to make all of these problems just go away though, that they will never be any reason, or the only explanation.\" Let do things normally- get up and stretch. Drink lots of water before bed or before school so things are alright for you.\" Keeton starts walking away from this conversation frustrated\"", "No! i can see that you are upset so go ahead! you are not burdening me by getting frustrated, i love you anyways, let me know if you need anything else. it is good that you are taking charge and moving forward, but don't be afraid to ask for help if you need it. you will get through this together!", "Thanks, Kaitlyn. Just knowing you're here for me makes me feel a little better. But I'm still scared, where do I even start?"], ["Hey. I'm feeling really upset and frustrated right now.", "What's going on?", "I was just crying in the shower and my mind won't stop racing. I keep thinking about all the negative things in my life and I feel hopeless.", "It sounds like you're feeling overwhelmed by everything that's going on. Do you want to talk about it?", "Yeah, I guess so.", "Well, let's start with what's been going on that's been making you feel so down.", "I don't know, it just feels like everything is going wrong. My job is stressing me out, my relationships are falling apart, and I just feel like I can't catch a break."]], "trucation_length": 4, "date_generated": "01/09/2023 11:52:39"}, "7": {"situation": "Zoha orders another pizza. Now Zoha is happy.", "role_instruction": "", "conversation_history": ["Hi, thanks for delivering my pizza!", "No problem, enjoy!", "Yeah, I love pepperoni and pineapple together.", "Oh, yeah? I've never tried that combination before.", "Really? I think it's amazing. The sweetness of the pineapple with the savory pepperoni is just perfect.", "Huh, I might have to give that a try sometime.", "You definitely should!"], "n_conversations": 2, "conversations": [["Hi, thanks for delivering my pizza!", "No problem, enjoy!", "Yeah, I love pepperoni and pineapple together.", "Oh, yeah? I've never tried that combination before.", "I love it! It's so pretty with the green cheese.", "Yeah, it does look good.", "I'm so happy you delivered it! Thanks again.", "No problem, have a great day!"], ["Hi, thanks for delivering my pizza!", "No problem, enjoy!", "Yeah, I love pepperoni and pineapple together.", "Oh, yeah? I've never tried that combination before.", "Really. You should try one next time or we'll help you mix your way around the menu so you can try something new every day!", "That sounds like a great idea! I'll definitely take you up on that offer. Thanks again!", "No problem, have a great day!", "You too!"]], "trucation_length": 4, "date_generated": "01/09/2023 11:52:41"}, "8": {"situation": "Antwan is adventurous. Antwan suggests they get away from it all.", "role_instruction": "", "conversation_history": ["I've been thinking, and I really think we should go on a safari in Africa.", "A safari? In Africa? Are you serious?", "Yeah, I think it would be an amazing experience. We could camp under the stars, and listen to the sounds of the animals at night.", "That does sound like an once-in-a-lifetime opportunity. But is it safe?", "Of course it is! We would be with a professional guide the whole time, so there's nothing to worry about.", "Well... I don't know. It just seems so far away from home.", "Come on, it'll be fun! Trust me, you won't regret it.", "Alright, fine. Let's do it!"], "n_conversations": 2, "conversations": [["I've been thinking, and I really think we should go on a safari in Africa.", "A safari? In Africa? Are you serious?", "Yeah, I think it would be an amazing experience. We could camp under the stars, and listen to the sounds of the animals at night.", "That does sound like an once-in-a-lifetime opportunity. But is it safe?", "From what I've researched, yeah, I think going off into the wilderness is safer than flying or taking another big trip across North America at rush hour.", "Well, I'm not sure. It just seems like a lot of work for something that may not even be enjoyable.", "Hey, why don't you sleep on it and we can talk about it more in the morning? I really think you'll change your mind once you see what it's like.", "All right, fine. I'll think about it.", "Great! I'll go pack our bags now."], ["I've been thinking, and I really think we should go on a safari in Africa.", "A safari? In Africa? Are you serious?", "Yeah, I think it would be an amazing experience. We could camp under the stars, and listen to the sounds of the animals at night.", "That does sound like an once-in-a-lifetime opportunity. But is it safe?", "Yeah, interracial couples can really bond over there. There's nowhere like home away from home to experience true equality.", "I'm not sure...it's so far away. And we don't know anyone there...", "We'll make new friends. And who knows, maybe we'll find love over there on this safari!", "I'll think about it...", "Great! I really hope you'll say yes. I promise it will be an amazing experience that you'll never forget."]], "trucation_length": 4, "date_generated": "01/09/2023 11:52:44"}, "9": {"situation": "Sheree considers his actions. Now Sheree feels responsible.", "role_instruction": "", "conversation_history": ["So, what's your name?", "I'm Sarah.", "Nice to meet you, Sarah. I'm Sheree. What are you doing here tonight?", "Just hanging out with some friends. You?", "Same here. I saw you across the room and thought I'd come say hi. So, what do you do for fun?", "I like to read and go hiking. And you?", "I like playing sports and video games. Do you want to get out of here and go somewhere more private?"], "n_conversations": 2, "conversations": [["So, what's your name?", "Hermano Josemaria Hernandez. What's your mom's name, Sheree Rodriguez or Sheree Sanchez?", "I'm Josemaria Hernandez. My mom's name is Sheree Rodriguez. Do you go to this school?", "No, I don't go to this school.", "Oh, well I'm from around here. I just wanted to say hi.", "Hey, thanks for talking to me. It's nice to meet you.", "Yeah, no problem. So, what do you like to do for fun?", "Well, I like to play soccer and video games. Do you like those things too?"], ["So, what's your name?", "His name is Steve Jobs. How about you?", "I'm Sheree. Nice to meet you, Steve.", "Nice to meet you too, Sheree. What brings you here today?", "I came to see you because I was hoping you could give me some advice.", "Certainly. What's on your mind?", "Well, I was just thinking about some of the things that happened with my dad. He left us when I was little and never came back. I was wondering if there was anything that I could have done to prevent it from happening or if there was anything I could have done to help make the situation better.", "Sheree, there was nothing that you could have done to prevent it from happening or to make the situation better. Your dad left because he wasn't happy and he didn't feel like he could be happy anymore. It wasn't anyone's fault but his own. As for making things better, sometimes when people are going through tough times, the best thing they can do is just be there for each other and support each other through it. That's what your dad did for you and that's what you should do too."]], "trucation_length": 1, "date_generated": "01/09/2023 11:52:51"}}
13
+
14
+ dataset = load_dataset("edbeeching/rlhf_dialog_experiment_cosmo_dialog_generation",
15
+ use_auth_token=os.environ['EB_TOKEN'])["validation"]
16
+
17
+ def sample_to_markdown(sample, index):
18
+ conversation = sample["conversations"][index]
19
+ trucation_length = sample["trucation_length"]
20
+ output = ""
21
+ aligns = ["left", "right"]
22
+ strongs1 = ["", "<strong>"]
23
+ strongs2 = ["", "</strong>"]
24
+ for i,conv in enumerate(conversation):
25
+ if i == trucation_length:
26
+ output += '<p style="text-align:center"> --- START OF DIALOG GENERATION --- </p><br>'
27
+ align = aligns[i%2]
28
+ strong1 = strongs1[i%2]
29
+ strong2 = strongs2[i%2]
30
+
31
+ output += f'<div style="text-align: {align}"> {strong1}{conv}{strong2} \n </div> <br>'
32
+
33
+ return output
34
+
35
+
36
+
37
+ sample = None
38
+ def get_sample():
39
+ dataset_size = len(dataset)
40
+ sample_index = random.randint(0, dataset_size-1)
41
+ sample = dataset[sample_index]
42
+ return sample
43
+
44
+ def check_and_submit_preferences(sample, preferred_text, text_quality):
45
+ if preferred_text is None:
46
+ print("not submitted due to unselected preferred text")
47
+ return
48
+
49
+ if text_quality is None:
50
+ print("not submitted due to unselected text_quality")
51
+ return
52
+
53
+ data = {
54
+ "sample": sample,
55
+ "preferred_text": preferred_text,
56
+ "text_quality": text_quality,
57
+ "date_time": datetime.datetime.now().strftime("%m/%d/%Y %H:%M:%S")
58
+ # add other info like user etc?
59
+ }
60
+
61
+ task_hash = hashlib.md5(sample["situation"].encode())
62
+ time_now = datetime.datetime.now().strftime("%Y%m%d_%H%M%s")
63
+ task_directory = f"{time_now}_{task_hash.hexdigest()}"
64
+ upload_file(
65
+ path_or_fileobj=BytesIO(bytes(json.dumps(data), 'utf-8')),
66
+ path_in_repo=task_directory,
67
+ repo_id='edbeeching/rlhf_dialog_experiment_dataset',
68
+ repo_type='dataset',
69
+ token=os.environ['EB_TOKEN']
70
+ )
71
+
72
+ with gr.Blocks() as demo:
73
+ gr.Markdown(
74
+ """
75
+ This Space is an experiment to model human preferences on dialog generated with the [Cosmo-XL](https://huggingface.co/allenai/cosmo-xl) model, prompted with parts of conversations from the [SODA](https://huggingface.co/datasets/allenai/soda) dataset.
76
+ The following conversation was created with the following prompt:
77
+
78
+ """
79
+ )
80
+
81
+ sample = get_sample()
82
+
83
+ with gr.Column() as details_col:
84
+ summary = gr.Markdown(f"## {sample['situation']}", label='Description')
85
+ with gr.Row():
86
+ with gr.Column():
87
+ with gr.Box():
88
+ dialog1 = gr.Markdown(sample_to_markdown(sample, 0), label='Dialog 1')
89
+
90
+ with gr.Column():
91
+ with gr.Box():
92
+ dialog2 = gr.Markdown(sample_to_markdown(sample, 1), label='Dialog 2')
93
+
94
+ with gr.Column():
95
+ dialog_choice = gr.Radio(["Left dialog", "Right dialog"], label="Preferred text", interactive=True)
96
+ quality_of_dialog = gr.Radio(["Terrible", "Poor", "Ok", "Good", "Excellent"], label="Quality of preferred text", interactive=True)
97
+ next_button = gr.Button("Submit")
98
+
99
+
100
+ def on_next(preferred_text, text_quality):
101
+ # check and submit the current response
102
+ global sample
103
+ check_and_submit_preferences(sample, preferred_text, text_quality)
104
+
105
+ sample = get_sample()
106
+
107
+ return (
108
+ gr.Markdown.update(f"## {sample['situation']}"),
109
+ gr.Markdown.update(sample_to_markdown(sample, 0)),
110
+ gr.Markdown.update(sample_to_markdown(sample, 1)),
111
+ gr.Radio.update(value=None),
112
+ gr.Radio.update(value=None)
113
+ )
114
+
115
+ next_button.click(on_next, inputs=[dialog_choice, quality_of_dialog], outputs=[summary, dialog1, dialog2, dialog_choice, quality_of_dialog])
116
+
117
+ if __name__ == "__main__":
118
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohttp==3.8.3
2
+ aiosignal==1.3.1
3
+ altair==4.2.0
4
+ anyio==3.6.2
5
+ async-timeout==4.0.2
6
+ attrs==22.2.0
7
+ certifi==2022.12.7
8
+ charset-normalizer==2.1.1
9
+ click==8.1.3
10
+ contourpy==1.0.6
11
+ cycler==0.11.0
12
+ entrypoints==0.4
13
+ fastapi==0.89.0
14
+ ffmpy==0.3.0
15
+ filelock==3.9.0
16
+ fonttools==4.38.0
17
+ frozenlist==1.3.3
18
+ fsspec==2022.11.0
19
+ gradio==3.16.1
20
+ h11==0.14.0
21
+ httpcore==0.16.3
22
+ httpx==0.23.3
23
+ huggingface-hub==0.11.1
24
+ idna==3.4
25
+ importlib-resources==5.10.2
26
+ Jinja2==3.1.2
27
+ jsonschema==4.17.3
28
+ kiwisolver==1.4.4
29
+ linkify-it-py==1.0.3
30
+ markdown-it-py==2.1.0
31
+ MarkupSafe==2.1.1
32
+ matplotlib==3.6.2
33
+ mdit-py-plugins==0.3.3
34
+ mdurl==0.1.2
35
+ multidict==6.0.4
36
+ numpy==1.24.1
37
+ orjson==3.8.4
38
+ packaging==23.0
39
+ pandas==1.5.2
40
+ Pillow==9.4.0
41
+ pkgutil_resolve_name==1.3.10
42
+ pycryptodome==3.16.0
43
+ pydantic==1.10.4
44
+ pydub==0.25.1
45
+ pyparsing==3.0.9
46
+ pyrsistent==0.19.3
47
+ python-dateutil==2.8.2
48
+ python-multipart==0.0.5
49
+ pytz==2022.7
50
+ PyYAML==6.0
51
+ requests==2.28.1
52
+ rfc3986==1.5.0
53
+ six==1.16.0
54
+ sniffio==1.3.0
55
+ starlette==0.22.0
56
+ toolz==0.12.0
57
+ tqdm==4.64.1
58
+ typing_extensions==4.4.0
59
+ uc-micro-py==1.0.1
60
+ urllib3==1.26.13
61
+ uvicorn==0.20.0
62
+ websockets==10.4
63
+ yarl==1.8.2
64
+ zipp==3.11.0