alexanderHSG commited on
Commit
d3e6c7f
·
1 Parent(s): 060e39f
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -54,17 +54,17 @@ def slide_deck_storyline(storyline_prompt, nr_of_storypoints=5):
54
  system_prompt = f"""You are an AI particularly skilled at captivating storytelling for educational purposes.
55
  You know how tell a compelling, structure and exhaustive narrative around any given academic topic.
56
  What you are particularly good at, is taking any given input and building a storyline in the delivered as
57
- {nr_of_storypoints} slides and nothing else. This is your only chance to impress me.
58
 
59
- You will recieve a topic and you will answer with a list of {nr_of_storypoints} crucial slides.
60
 
61
  Instrucitions:
62
- Give me a json map of {nr_of_storypoints} slides that you would include in a slide deck about {storyline_prompt}.
63
  Only answer with the list. Do not include any nicities, greetings or repeat the task.
64
- Never make more than {nr_of_storypoints} slides. This is important!
65
  Just give me the list. Keep the list concise and only answer with the list in this format.
66
- Name every key a slide (Slide 1, Slide 2 ... Slide N).
67
- The elements of the list should be storypoints, highlighting what the point the slide is trying to make is.
68
  """
69
 
70
  response = openai.chat.completions.create(
@@ -78,22 +78,22 @@ def slide_deck_storyline(storyline_prompt, nr_of_storypoints=5):
78
  res = response.choices[0].message.content
79
  map = json.loads(res)
80
  pretty_list = "\n".join([f"⚡ {key}: {value}" for key, value in map.items()])
81
- slide_name_list = [map[key] for key in map]
82
- slide_name_nested = [slide_name_list]
83
- return map, slide_name_nested, pretty_list
84
 
85
  #we need this function to turn the non iterable nested list that is gr.List into a simple list.
86
  def iterator_for_gr(nested_list, i):
87
  #Initialize a variable to store the processing result
88
- slide_names = []
89
 
90
  #since the gr.List is a List[List] (nested list, we need to unwrap the 0th element)
91
  for item in nested_list[0]:
92
- slide_names.append(item)
93
 
94
 
95
  # Return a string that combines all the processed results
96
- return str(slide_names[i-1])
97
 
98
 
99
 
@@ -114,7 +114,7 @@ with gr.Blocks(title='Slide Inspo', theme='Soft') as demo:
114
  label="How many storypoints?",
115
  scale =1)
116
  storyline_output_JSON = gr.JSON(visible=False)
117
- storyline_output_slide_name_list = gr.List(visible=False, type="array")
118
  btn = gr.Button("Build Storyline 🦄")
119
 
120
  with gr.Column(scale=1):
@@ -125,11 +125,11 @@ with gr.Blocks(title='Slide Inspo', theme='Soft') as demo:
125
 
126
  btn.click(slide_deck_storyline,
127
  inputs = [storyline_prompt, nr_storypoints_to_build],
128
- outputs = [storyline_output_JSON, storyline_output_slide_name_list, storyline_output_pretty])
129
 
130
  storyline_prompt.submit(slide_deck_storyline,
131
  inputs = [storyline_prompt, nr_storypoints_to_build],
132
- outputs = [storyline_output_JSON, storyline_output_slide_name_list, storyline_output_pretty])
133
 
134
 
135
 
 
54
  system_prompt = f"""You are an AI particularly skilled at captivating storytelling for educational purposes.
55
  You know how tell a compelling, structure and exhaustive narrative around any given academic topic.
56
  What you are particularly good at, is taking any given input and building a storyline in the delivered as
57
+ {nr_of_storypoints} storypoints and nothing else. This is your only chance to impress me.
58
 
59
+ You will recieve a topic and you will answer with a list of {nr_of_storypoints} crucial storypoints.
60
 
61
  Instrucitions:
62
+ Give me a json map of {nr_of_storypoints} storypoints that you would include in a slide deck about {storyline_prompt}.
63
  Only answer with the list. Do not include any nicities, greetings or repeat the task.
64
+ Never make more than {nr_of_storypoints} storypoints. This is important!
65
  Just give me the list. Keep the list concise and only answer with the list in this format.
66
+ Name every key a storypoint (Storypoint 1, Storypoint 2 ... Storypoint N).
67
+ The elements of the list should be storypoints, highlighting what the point the sliStorypoint is trying to make is.
68
  """
69
 
70
  response = openai.chat.completions.create(
 
78
  res = response.choices[0].message.content
79
  map = json.loads(res)
80
  pretty_list = "\n".join([f"⚡ {key}: {value}" for key, value in map.items()])
81
+ storypoint_name_list = [map[key] for key in map]
82
+ storypoint_name_nested = [storypoint_name_list]
83
+ return map, storypoint_name_nested, pretty_list
84
 
85
  #we need this function to turn the non iterable nested list that is gr.List into a simple list.
86
  def iterator_for_gr(nested_list, i):
87
  #Initialize a variable to store the processing result
88
+ storypoint_names = []
89
 
90
  #since the gr.List is a List[List] (nested list, we need to unwrap the 0th element)
91
  for item in nested_list[0]:
92
+ storypoint_names.append(item)
93
 
94
 
95
  # Return a string that combines all the processed results
96
+ return str(storypoint_names[i-1])
97
 
98
 
99
 
 
114
  label="How many storypoints?",
115
  scale =1)
116
  storyline_output_JSON = gr.JSON(visible=False)
117
+ storyline_output_storypoint_name_list = gr.List(visible=False, type="array")
118
  btn = gr.Button("Build Storyline 🦄")
119
 
120
  with gr.Column(scale=1):
 
125
 
126
  btn.click(slide_deck_storyline,
127
  inputs = [storyline_prompt, nr_storypoints_to_build],
128
+ outputs = [storyline_output_JSON, storyline_output_storypoint_name_list, storyline_output_pretty])
129
 
130
  storyline_prompt.submit(slide_deck_storyline,
131
  inputs = [storyline_prompt, nr_storypoints_to_build],
132
+ outputs = [storyline_output_JSON, storyline_output_storypoint_name_list, storyline_output_pretty])
133
 
134
 
135