Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,6 @@ def csv_prompter(question):
|
|
15 |
json_data = json.load(json_file)
|
16 |
json_data = json_data['records']
|
17 |
|
18 |
-
print(json_data)
|
19 |
fulltext = []
|
20 |
#print all nm in json file
|
21 |
for i in json_data:
|
@@ -40,9 +39,8 @@ def csv_prompter(question):
|
|
40 |
#fulltext = fulltext + "\n 00:00 - Customer: Hey, dear, can I please take out? 00:03 - Waiter: I'm up here. Okay go ahead. 00:06 - Customer: Can I get two sesame chicken dinners? 00:10 - Customer: One with lo mein and one with fried rice? 00:13 - Customer: Can I get, I know spring rolls come with each of those, but can I get just as long 00:17 - Customer: as I've got a total of two spring rolls and two egg rolls? 00:21 - Waiter: Okay. Anything? 00:22 - Customer: And a small bowl of hot and sour soup. 00:25 - Customer: And that's it. 00:26 - Waiter: Alright. Two sesame chickens, small one with fried rice, small one with lo mein, and both of those with spring rolls, two egg rolls and a small hot and sour soup. 00:30 - Customer: It's 205-473-1750. 00:36 - Waiter: What's the fun number please? 00:43 - Waiter: Just got around 20 minutes. Thank you. 00:43 - Customer: Okay, dear, thank you so much."
|
41 |
fulltext = fulltext+'\n'
|
42 |
|
43 |
-
fulltext = fulltext+'\n'+question
|
44 |
|
45 |
-
fulltext = fulltext+'Based on the above dialogue and menu, If you were a waiter, what would you say next?\n Waiter:'
|
46 |
print(fulltext)
|
47 |
messages = [
|
48 |
{"role": "system", "content": ""},
|
@@ -73,7 +71,7 @@ with gr.Blocks() as demo:
|
|
73 |
def restart(history):
|
74 |
invitation = "Waiter: "
|
75 |
human_invitation = "Customer: "
|
76 |
-
return [["
|
77 |
|
78 |
def user(user_message, history):
|
79 |
invitation = "Waiter: "
|
@@ -84,13 +82,12 @@ with gr.Blocks() as demo:
|
|
84 |
invitation = "Waiter: "
|
85 |
human_invitation = "Customer: "
|
86 |
print(history)
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
response = csv_prompter(
|
94 |
|
95 |
response = invitation+ response
|
96 |
history[-1][1] = response
|
|
|
15 |
json_data = json.load(json_file)
|
16 |
json_data = json_data['records']
|
17 |
|
|
|
18 |
fulltext = []
|
19 |
#print all nm in json file
|
20 |
for i in json_data:
|
|
|
39 |
#fulltext = fulltext + "\n 00:00 - Customer: Hey, dear, can I please take out? 00:03 - Waiter: I'm up here. Okay go ahead. 00:06 - Customer: Can I get two sesame chicken dinners? 00:10 - Customer: One with lo mein and one with fried rice? 00:13 - Customer: Can I get, I know spring rolls come with each of those, but can I get just as long 00:17 - Customer: as I've got a total of two spring rolls and two egg rolls? 00:21 - Waiter: Okay. Anything? 00:22 - Customer: And a small bowl of hot and sour soup. 00:25 - Customer: And that's it. 00:26 - Waiter: Alright. Two sesame chickens, small one with fried rice, small one with lo mein, and both of those with spring rolls, two egg rolls and a small hot and sour soup. 00:30 - Customer: It's 205-473-1750. 00:36 - Waiter: What's the fun number please? 00:43 - Waiter: Just got around 20 minutes. Thank you. 00:43 - Customer: Okay, dear, thank you so much."
|
40 |
fulltext = fulltext+'\n'
|
41 |
|
42 |
+
fulltext = fulltext+'\n\n'+question
|
43 |
|
|
|
44 |
print(fulltext)
|
45 |
messages = [
|
46 |
{"role": "system", "content": ""},
|
|
|
71 |
def restart(history):
|
72 |
invitation = "Waiter: "
|
73 |
human_invitation = "Customer: "
|
74 |
+
return [["\n",invitation+"Taste of China, may I help you?"]]
|
75 |
|
76 |
def user(user_message, history):
|
77 |
invitation = "Waiter: "
|
|
|
82 |
invitation = "Waiter: "
|
83 |
human_invitation = "Customer: "
|
84 |
print(history)
|
|
|
85 |
|
86 |
+
alist = list(itertools.chain.from_iterable(history))
|
87 |
+
alist=filter(None, alist)
|
88 |
+
fulltext = "Based on the above menu and following dialogue, If you were a waiter, what would you say next?\n"+ "\n".join(alist) + "\n" + invitation
|
89 |
|
90 |
+
response = csv_prompter(fulltext)
|
91 |
|
92 |
response = invitation+ response
|
93 |
history[-1][1] = response
|