Spaces:
Running
Running
Commit
·
5ac7eb0
1
Parent(s):
cb9fe7f
Fix loading json bugs
Browse files
sessions/pokemon_types_flavoured_soft_drinks/data.json
CHANGED
@@ -4,21 +4,21 @@
|
|
4 |
"start": "As the meteor dust settled, Pikachu and Charmander emerged, curious about their new surroundings. Nearby, a bustling city was abuzz with people trying to comprehend the arrival of these creatures. Suddenly, a mysterious figure appeared, offering a challenge: \"Can you help these Pokemon find their favorite soft drinks?\""
|
5 |
},
|
6 |
"2": {
|
7 |
-
"Pikachu's_Favorite_Drink_Quest": "
|
8 |
"Charmander's_Favorite_Drink_Quest": "As you choose to help Charmander, the mysterious figure reveals a ticking clock: \"A rare solar eclipse will occur soon, and only during this time can Charmander identify its favorite drink. Hurry, the eclipse is approaching fast!\"",
|
9 |
"Both_Pokemon's_Drink_Quest": "Unexplored!"
|
10 |
},
|
11 |
"3": {
|
12 |
-
"City_Search": "
|
13 |
-
"Local_Expert": "
|
14 |
"Taste_Test": "Unexplored!"
|
15 |
},
|
16 |
"4": {
|
17 |
-
"Charmander_takes_a_sip": "
|
18 |
},
|
19 |
"5": {
|
20 |
-
"Celebrate_the_success": "
|
21 |
-
"Learn_about_other_Pokemon": "
|
22 |
"Plan_future_adventures": "As the eclipse fades, the sky returns to its usual hue, and the crowd disperses with excitement. Professor Maple approaches you, suggesting a future journey to explore more Pokemon and their unique preferences. Pikachu and Charmander look eager, ready for more adventures by your side."
|
23 |
},
|
24 |
"6": {
|
@@ -47,6 +47,22 @@
|
|
47 |
"7b000a21-8ee5-4f8f-9f80-3039f22c1340": {
|
48 |
"question": "What_do_you_decide_to_do_next?",
|
49 |
"options": "{'Embark_on_a_new_adventure_with_Pikachu_and_Charmander': 'New_Adventure_Begins', \"Reflect_on_the_impact_of_the_eclipse_and_the_Pokemon's_arrival\": 'Reflective_Moment', 'Bid_farewell_to_Professor_Maple_and_the_Pokemon,_returning_to_your_usual_life': 'Return_to_Normalcy'}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
},
|
52 |
"state_question_map": {
|
@@ -54,16 +70,20 @@
|
|
54 |
"start": "3a9f3748-d14b-43a7-beeb-9ca20b46427b"
|
55 |
},
|
56 |
"2": {
|
57 |
-
"Charmander's_Favorite_Drink_Quest": "154fe5ae-612c-4cc8-a46a-71021627aa28"
|
|
|
58 |
},
|
59 |
"3": {
|
60 |
-
"Local_Expert": "740b89c8-3b16-42ec-a819-b026163f3761"
|
|
|
61 |
},
|
62 |
"4": {
|
63 |
"Charmander_takes_a_sip": "a388a0ff-ee45-4d9e-a285-d9deeaff659e"
|
64 |
},
|
65 |
"5": {
|
66 |
-
"Plan_future_adventures": "7b000a21-8ee5-4f8f-9f80-3039f22c1340"
|
|
|
|
|
67 |
}
|
68 |
},
|
69 |
"categories": [
|
@@ -94,7 +114,7 @@
|
|
94 |
}
|
95 |
],
|
96 |
"categories_seen": {
|
97 |
-
"Electric Zing":
|
98 |
"Fire Blaze": true,
|
99 |
"Water Splash": false,
|
100 |
"Grass Burst": false,
|
@@ -104,6 +124,18 @@
|
|
104 |
"3a9f3748-d14b-43a7-beeb-9ca20b46427b+Charmander-154fe5ae-612c-4cc8-a46a-71021627aa28+Consult_a_local_expert_on_Pokemon_tastes-740b89c8-3b16-42ec-a819-b026163f3761+Cinnamon_Flame_Fizz-a388a0ff-ee45-4d9e-a285-d9deeaff659e+Reflect_on_the_experience_and_plan_for_future_adventures-7b000a21-8ee5-4f8f-9f80-3039f22c1340+Embark_on_a_new_adventure_with_Pikachu_and_Charmander": [
|
105 |
"Fire Blaze",
|
106 |
"You chose to help Charmander, a Fire-type Pokémon, and selected the Cinnamon Flame Fizz, a fiery drink, as its favorite. This aligns with the traits of the Fire Blaze category, which is described as a fiery drink that ignites your taste buds with the heat of Fire-type Pokémon. Your choices reflect a preference for the spicy, warming, and invigorating traits associated with Fire Blaze."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
]
|
108 |
}
|
109 |
}
|
|
|
4 |
"start": "As the meteor dust settled, Pikachu and Charmander emerged, curious about their new surroundings. Nearby, a bustling city was abuzz with people trying to comprehend the arrival of these creatures. Suddenly, a mysterious figure appeared, offering a challenge: \"Can you help these Pokemon find their favorite soft drinks?\""
|
5 |
},
|
6 |
"2": {
|
7 |
+
"Pikachu's_Favorite_Drink_Quest": "As you approach Pikachu, the mysterious figure hands you a map with cryptic symbols. \"This will lead you to the Electric Berry Soda,\" they whisper. The path begins in the heart of the city, but strange shadows lurk in the alleyways. What could they be hiding?",
|
8 |
"Charmander's_Favorite_Drink_Quest": "As you choose to help Charmander, the mysterious figure reveals a ticking clock: \"A rare solar eclipse will occur soon, and only during this time can Charmander identify its favorite drink. Hurry, the eclipse is approaching fast!\"",
|
9 |
"Both_Pokemon's_Drink_Quest": "Unexplored!"
|
10 |
},
|
11 |
"3": {
|
12 |
+
"City_Search": "The map leads you through the bustling streets, where a sudden flash of light reveals a group of shadowy figures blocking your path. They demand a challenge before letting you pass. Pikachu and Charmander stand ready, sparks flying and flames flickering. What will you do next?",
|
13 |
+
"Local_Expert": "You and your Pokemon cautiously step into the alley, where the shadows reveal a hidden group of Pokemon enthusiasts. They seem to be guarding a secret stash of rare Pokemon-themed soft drinks. One of them steps forward, intrigued by your presence, and asks, \"Are you here for the challenge or something more?\"",
|
14 |
"Taste_Test": "Unexplored!"
|
15 |
},
|
16 |
"4": {
|
17 |
+
"Charmander_takes_a_sip": "The shadowy figures pause, intrigued by your offer of negotiation. They whisper among themselves, then reveal their true form: a group of mischievous Ditto. They agree to a trade—solve their riddle, and they'll guide you to the hidden Electric Berry Soda fountain."
|
18 |
},
|
19 |
"5": {
|
20 |
+
"Celebrate_the_success": "As the eclipse reaches its peak, a shimmering portal opens, inviting the Pokemon back to their world. Charmander, grateful for the help, gifts you a fiery gem as a token of friendship. The crowd waves goodbye, feeling a sense of wonder and unity.",
|
21 |
+
"Learn_about_other_Pokemon": "With the Ditto's riddle solved, a path opens to the Electric Berry Soda fountain. Professor Maple smiles warmly, revealing a book filled with tales of other Pokemon. As you sip the soda, the Pokemon cheer, and a sense of peace settles over the city.",
|
22 |
"Plan_future_adventures": "As the eclipse fades, the sky returns to its usual hue, and the crowd disperses with excitement. Professor Maple approaches you, suggesting a future journey to explore more Pokemon and their unique preferences. Pikachu and Charmander look eager, ready for more adventures by your side."
|
23 |
},
|
24 |
"6": {
|
|
|
47 |
"7b000a21-8ee5-4f8f-9f80-3039f22c1340": {
|
48 |
"question": "What_do_you_decide_to_do_next?",
|
49 |
"options": "{'Embark_on_a_new_adventure_with_Pikachu_and_Charmander': 'New_Adventure_Begins', \"Reflect_on_the_impact_of_the_eclipse_and_the_Pokemon's_arrival\": 'Reflective_Moment', 'Bid_farewell_to_Professor_Maple_and_the_Pokemon,_returning_to_your_usual_life': 'Return_to_Normalcy'}"
|
50 |
+
},
|
51 |
+
"8681384d-fba7-45aa-8daa-6a4d951c552f": {
|
52 |
+
"question": "What_do_you_do_as_the_portal_closes?",
|
53 |
+
"options": "{'Wave_farewell_and_reflect_on_the_adventure': 'Reflective_Moment', 'Prepare_for_a_new_adventure_with_the_fiery_gem': 'New_Adventure_Begins', 'Return_to_your_daily_life_with_a_story_to_tell': 'Return_to_Normalcy'}"
|
54 |
+
},
|
55 |
+
"28399188-1fe7-4d89-ae01-51829063301f": {
|
56 |
+
"question": "Do_you_follow_the_map_or_investigate_the_shadows?",
|
57 |
+
"options": "{'Follow_the_map': 'City_Search', 'Investigate_the_shadows': 'Local_Expert', 'Seek_help_from_a_local': 'Taste_Test'}"
|
58 |
+
},
|
59 |
+
"d112564b-30cc-4d67-bb98-a2274e60a186": {
|
60 |
+
"question": "How_will_you_respond_to_the_shadowy_figures?",
|
61 |
+
"options": "{'Challenge_them_to_a_battle': 'Charmander_takes_a_sip', 'Try_to_negotiate_with_them': 'Charmander_takes_a_sip', 'Look_for_an_alternate_route': 'Charmander_takes_a_sip'}"
|
62 |
+
},
|
63 |
+
"089ed925-3c43-4f23-86d9-5c7c6718fdf3": {
|
64 |
+
"question": "How_would_you_like_to_end_this_adventure?",
|
65 |
+
"options": "{'Celebrate_with_the_Pokemon': 'Reflective_Moment', 'Plan_a_new_journey_with_Professor_Maple': 'New_Adventure_Begins', 'Return_to_the_city_and_share_your_story': 'Return_to_Normalcy'}"
|
66 |
}
|
67 |
},
|
68 |
"state_question_map": {
|
|
|
70 |
"start": "3a9f3748-d14b-43a7-beeb-9ca20b46427b"
|
71 |
},
|
72 |
"2": {
|
73 |
+
"Charmander's_Favorite_Drink_Quest": "154fe5ae-612c-4cc8-a46a-71021627aa28",
|
74 |
+
"Pikachu's_Favorite_Drink_Quest": "28399188-1fe7-4d89-ae01-51829063301f"
|
75 |
},
|
76 |
"3": {
|
77 |
+
"Local_Expert": "740b89c8-3b16-42ec-a819-b026163f3761",
|
78 |
+
"City_Search": "d112564b-30cc-4d67-bb98-a2274e60a186"
|
79 |
},
|
80 |
"4": {
|
81 |
"Charmander_takes_a_sip": "a388a0ff-ee45-4d9e-a285-d9deeaff659e"
|
82 |
},
|
83 |
"5": {
|
84 |
+
"Plan_future_adventures": "7b000a21-8ee5-4f8f-9f80-3039f22c1340",
|
85 |
+
"Celebrate_the_success": "8681384d-fba7-45aa-8daa-6a4d951c552f",
|
86 |
+
"Learn_about_other_Pokemon": "089ed925-3c43-4f23-86d9-5c7c6718fdf3"
|
87 |
}
|
88 |
},
|
89 |
"categories": [
|
|
|
114 |
}
|
115 |
],
|
116 |
"categories_seen": {
|
117 |
+
"Electric Zing": true,
|
118 |
"Fire Blaze": true,
|
119 |
"Water Splash": false,
|
120 |
"Grass Burst": false,
|
|
|
124 |
"3a9f3748-d14b-43a7-beeb-9ca20b46427b+Charmander-154fe5ae-612c-4cc8-a46a-71021627aa28+Consult_a_local_expert_on_Pokemon_tastes-740b89c8-3b16-42ec-a819-b026163f3761+Cinnamon_Flame_Fizz-a388a0ff-ee45-4d9e-a285-d9deeaff659e+Reflect_on_the_experience_and_plan_for_future_adventures-7b000a21-8ee5-4f8f-9f80-3039f22c1340+Embark_on_a_new_adventure_with_Pikachu_and_Charmander": [
|
125 |
"Fire Blaze",
|
126 |
"You chose to help Charmander, a Fire-type Pokémon, and selected the Cinnamon Flame Fizz, a fiery drink, as its favorite. This aligns with the traits of the Fire Blaze category, which is described as a fiery drink that ignites your taste buds with the heat of Fire-type Pokémon. Your choices reflect a preference for the spicy, warming, and invigorating traits associated with Fire Blaze."
|
127 |
+
],
|
128 |
+
"3a9f3748-d14b-43a7-beeb-9ca20b46427b+Charmander-8681384d-fba7-45aa-8daa-6a4d951c552f+Consult_a_local_expert_on_Pokemon_tastes-8681384d-fba7-45aa-8daa-6a4d951c552f+Spicy_Chili_Soda": [
|
129 |
+
"Fire Blaze",
|
130 |
+
"You chose to help Charmander, a Fire-type Pokémon, and selected a Spicy Chili Soda, which aligns with the traits of a fiery drink that ignites your taste buds with the heat of Fire-type Pokémon."
|
131 |
+
],
|
132 |
+
"3a9f3748-d14b-43a7-beeb-9ca20b46427b+Pikachu-28399188-1fe7-4d89-ae01-51829063301f+Investigate_the_shadows-740b89c8-3b16-42ec-a819-b026163f3761+Spicy_Chili_Soda-7b000a21-8ee5-4f8f-9f80-3039f22c1340+Reflect_on_the_experience_and_plan_for_future_adventures": [
|
133 |
+
"Fire Blaze",
|
134 |
+
"Your choice to help Pikachu first shows a willingness to engage with Electric-type Pokémon, but your decision to investigate the shadows and select the Spicy Chili Soda for Charmander aligns more closely with the traits of the Fire Blaze category. The spicy and invigorating nature of the drink you chose for Charmander, along with the warm glow and delight it brought, reflects the fiery and warming traits of Fire-type Pokémon. Additionally, your decision to reflect on the experience and plan for future adventures suggests an invigorating and forward-thinking mindset, which is characteristic of the Fire Blaze category."
|
135 |
+
],
|
136 |
+
"3a9f3748-d14b-43a7-beeb-9ca20b46427b+Pikachu-d112564b-30cc-4d67-bb98-a2274e60a186+Follow_the_map-a388a0ff-ee45-4d9e-a285-d9deeaff659e+Try_to_negotiate_with_them-089ed925-3c43-4f23-86d9-5c7c6718fdf3+Thank_Professor_Maple_and_ask_about_other_Pokemon-089ed925-3c43-4f23-86d9-5c7c6718fdf3+Return_to_the_city_and_share_your_story": [
|
137 |
+
"Electric Zing",
|
138 |
+
"Your journey began with a choice to help Pikachu, an Electric-type Pokémon, and your adventure was centered around finding the Electric Berry Soda. Your decisions to follow the map and negotiate with the shadowy figures, who turned out to be Ditto, led you to the Electric Berry Soda fountain. This aligns with the traits of the Electric Zing category, which is associated with Electric-type Pokémon and their zesty, electrifying nature."
|
139 |
]
|
140 |
}
|
141 |
}
|
src/agents/coordinator.py
CHANGED
@@ -180,9 +180,16 @@ def load_coordinator() -> None:
|
|
180 |
combined_data = load_information(filepath)
|
181 |
|
182 |
states = {int(k): v for k, v in combined_data['states'].items()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
questions = {k: Question(**{
|
184 |
'question': v['question'],
|
185 |
-
'options': json.loads(v['options']
|
186 |
}) for k, v in combined_data['questions'].items()}
|
187 |
state_question_map = {int(k): v for k, v in combined_data['state_question_map'].items()}
|
188 |
categories = [Category(**c) for c in combined_data['categories']]
|
|
|
180 |
combined_data = load_information(filepath)
|
181 |
|
182 |
states = {int(k): v for k, v in combined_data['states'].items()}
|
183 |
+
for k, v in combined_data['questions'].items():
|
184 |
+
w = [c for c in v['options'].replace('\'', '\"')]
|
185 |
+
for i in range(1, len(w) - 1):
|
186 |
+
if w[i] == '\"' and w[i - 1].isalpha() and w[i + 1].isalpha():
|
187 |
+
w[i] = '\''
|
188 |
+
combined_data['questions'][k]['options'] = ''.join(w)
|
189 |
+
|
190 |
questions = {k: Question(**{
|
191 |
'question': v['question'],
|
192 |
+
'options': json.loads(v['options'])
|
193 |
}) for k, v in combined_data['questions'].items()}
|
194 |
state_question_map = {int(k): v for k, v in combined_data['state_question_map'].items()}
|
195 |
categories = [Category(**c) for c in combined_data['categories']]
|
src/frontend/chatbot.py
CHANGED
@@ -100,7 +100,7 @@ def control_screen(
|
|
100 |
return {
|
101 |
chatbot: gr.update(visible=is_visible),
|
102 |
button_row: gr.Row(visible=is_visible),
|
103 |
-
restart_button: gr.update(visible=
|
104 |
}
|
105 |
|
106 |
|
|
|
100 |
return {
|
101 |
chatbot: gr.update(visible=is_visible),
|
102 |
button_row: gr.Row(visible=is_visible),
|
103 |
+
restart_button: gr.update(visible=False)
|
104 |
}
|
105 |
|
106 |
|
src/frontend/continue_story_screen.py
CHANGED
@@ -22,7 +22,7 @@ information_text = gr.Text(
|
|
22 |
key='continue_story_user_information',
|
23 |
preserved_by_key='key',
|
24 |
visible=False,
|
25 |
-
label=
|
26 |
)
|
27 |
session_dir = os.path.join(
|
28 |
os.path.dirname(__file__),
|
@@ -54,6 +54,7 @@ for i, dirname in enumerate(sorted(os.listdir(session_dir))):
|
|
54 |
)
|
55 |
text = gr.Text(
|
56 |
value=story_context,
|
|
|
57 |
interactive=False,
|
58 |
visible=False,
|
59 |
key=f'continue_story_{i}',
|
|
|
22 |
key='continue_story_user_information',
|
23 |
preserved_by_key='key',
|
24 |
visible=False,
|
25 |
+
label=''
|
26 |
)
|
27 |
session_dir = os.path.join(
|
28 |
os.path.dirname(__file__),
|
|
|
54 |
)
|
55 |
text = gr.Text(
|
56 |
value=story_context,
|
57 |
+
label='',
|
58 |
interactive=False,
|
59 |
visible=False,
|
60 |
key=f'continue_story_{i}',
|
src/frontend/progress_screen.py
CHANGED
@@ -30,6 +30,7 @@ category_buttons = [
|
|
30 |
]
|
31 |
category_text = gr.Text(
|
32 |
value='Select a category!',
|
|
|
33 |
visible=False,
|
34 |
interactive=False,
|
35 |
key='category_text',
|
@@ -45,7 +46,8 @@ graph_plot = gr.Plot(
|
|
45 |
def control_screen(is_visible: bool) -> Dict[gr.Row, gr.Row]:
|
46 |
return {
|
47 |
categories_row: gr.Row(visible=is_visible),
|
48 |
-
graph_row: gr.Row(visible=is_visible)
|
|
|
49 |
}
|
50 |
|
51 |
|
@@ -102,14 +104,19 @@ def update_graph():
|
|
102 |
question = C.questions[question_uuid]
|
103 |
question_str = question.question
|
104 |
options = question.options
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
f'
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
graph.add_vertices(nodes, attributes=node_attributes)
|
115 |
graph.add_edges(edges, attributes=edge_attributes)
|
@@ -148,7 +155,7 @@ def update_graph():
|
|
148 |
.apply(lambda x: x.replace('\n', '<br>'))
|
149 |
node_labels = node_labels['label'].to_list()
|
150 |
edge_labels = [
|
151 |
-
question.replace('_', ' ') + '\n\n' + option.replace('_', ' ')
|
152 |
for question, option in zip(
|
153 |
edge_attributes['question'], edge_attributes['option']
|
154 |
)
|
@@ -216,12 +223,13 @@ def control_screen(
|
|
216 |
categories_row: gr.Row(visible=is_visible),
|
217 |
graph_row: gr.Row(visible=is_visible)
|
218 |
}
|
219 |
-
|
220 |
-
graph_plot: update_graph() if is_visible else gr.update(visible=False)
|
|
|
221 |
}
|
222 |
category_button_updates = update_categories()
|
223 |
|
224 |
-
return row_updates |
|
225 |
|
226 |
|
227 |
def render():
|
|
|
30 |
]
|
31 |
category_text = gr.Text(
|
32 |
value='Select a category!',
|
33 |
+
label='',
|
34 |
visible=False,
|
35 |
interactive=False,
|
36 |
key='category_text',
|
|
|
46 |
def control_screen(is_visible: bool) -> Dict[gr.Row, gr.Row]:
|
47 |
return {
|
48 |
categories_row: gr.Row(visible=is_visible),
|
49 |
+
graph_row: gr.Row(visible=is_visible),
|
50 |
+
category_text: gr.update(visible=is_visible)
|
51 |
}
|
52 |
|
53 |
|
|
|
104 |
question = C.questions[question_uuid]
|
105 |
question_str = question.question
|
106 |
options = question.options
|
107 |
+
prev_foll_state = None
|
108 |
+
for option, foll_state in sorted(options.items(), key=lambda x: x[1]):
|
109 |
+
if prev_foll_state is not None and prev_foll_state == foll_state:
|
110 |
+
edge_attributes['option'][-1] += f', {option}'
|
111 |
+
else:
|
112 |
+
edge = (
|
113 |
+
f'{state} (Stage {level})',
|
114 |
+
f'{foll_state} (Stage {level + 1})'
|
115 |
+
)
|
116 |
+
edges.append(edge)
|
117 |
+
edge_attributes['question'].append(question_str)
|
118 |
+
edge_attributes['option'].append(option)
|
119 |
+
prev_foll_state = foll_state
|
120 |
|
121 |
graph.add_vertices(nodes, attributes=node_attributes)
|
122 |
graph.add_edges(edges, attributes=edge_attributes)
|
|
|
155 |
.apply(lambda x: x.replace('\n', '<br>'))
|
156 |
node_labels = node_labels['label'].to_list()
|
157 |
edge_labels = [
|
158 |
+
question.replace('_', ' ') + '\n\n[ ' + option.replace('_', ' ') + ' ]'
|
159 |
for question, option in zip(
|
160 |
edge_attributes['question'], edge_attributes['option']
|
161 |
)
|
|
|
223 |
categories_row: gr.Row(visible=is_visible),
|
224 |
graph_row: gr.Row(visible=is_visible)
|
225 |
}
|
226 |
+
other_update = {
|
227 |
+
graph_plot: update_graph() if is_visible else gr.update(visible=False),
|
228 |
+
category_text: gr.update(visible=is_visible)
|
229 |
}
|
230 |
category_button_updates = update_categories()
|
231 |
|
232 |
+
return row_updates | other_update | category_button_updates
|
233 |
|
234 |
|
235 |
def render():
|