Anand Sampat commited on
Commit
793d2fe
1 Parent(s): cb98498

additional containers + updated prompts

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -75,7 +75,7 @@ def process_concept(sn_api_key, concept, num_subconcepts, progress=gr.Progress()
75
  subconcepts = subconcepts[:lmt]
76
 
77
  prompts = [
78
- f"Please give a detailed explanation of this subconcept: {subconcept}" for subconcept in subconcepts
79
  ]
80
 
81
  progress(0.3, f"Generating explanations for {len(subconcepts)} subconcepts in parallel")
@@ -119,11 +119,12 @@ def process_concept(sn_api_key, concept, num_subconcepts, progress=gr.Progress()
119
 
120
  progress(0.9, "Formatting output")
121
  # Format the output in Markdown
 
 
 
 
 
122
  markdown_intro = f"# Lesson Plan: {concept.title()}\n\n"
123
- markdown_intro += f"**Number of LLama 3.2 3B calls made to SambaNova's API:** {num_subconcepts + 1}\n\n"
124
- markdown_intro += f"**1 LLama 3.1 8B call made to SambaNova's API to summarize**\n\n"
125
- markdown_intro += f"**Total time taken:** {total_time:.2f} seconds\n\n"
126
- markdown_intro += f"\n\n---\n\n"
127
  markdown_intro += intro_summary
128
 
129
  subconcept_markdowns = []
@@ -141,14 +142,14 @@ def process_concept(sn_api_key, concept, num_subconcepts, progress=gr.Progress()
141
  new_tabs.extend([gr.update(visible=False, render=False) for _ in range(MAX_SUBCONCEPTS-len(subconcept_markdowns))])
142
  new_tab_contents.extend([gr.update(visible=False) for _ in range(MAX_SUBCONCEPTS-len(subconcept_markdowns))])
143
 
144
- return "Process complete!", markdown_intro, *new_tabs, *new_tab_contents
145
 
146
  with gr.Blocks() as demo:
147
  gr.Markdown(
148
  """
149
  # Lesson Plan Generator
150
 
151
- **Ever wanted to learn something new? Struggled to break down the concept to more digestible subconcepts? In this demo, we use <a href="https://cloud.sambanova.ai">SambaNova's</a> superfast LLama 3.2 3B and LLama 3.1 8B models to summarize the concept and subconcepts as well as provide a detailed lesson for each of the subconcepts.**
152
 
153
  *To use this, follow the instructions below:*
154
 
@@ -173,6 +174,7 @@ with gr.Blocks() as demo:
173
 
174
  with gr.Column():
175
  progress_output = gr.Textbox(label="Progress", interactive=True)
 
176
  lesson_intro = gr.Markdown(label="Lesson Intro", container=True)
177
 
178
  tab_contents = []
@@ -186,7 +188,7 @@ with gr.Blocks() as demo:
186
  generate_btn.click(
187
  process_concept,
188
  inputs=[sn_api_key_input, concept_input, slider],
189
- outputs=[progress_output, lesson_intro] + [tabs.children[i] for i in range(MAX_SUBCONCEPTS)] + tab_contents
190
  )
191
 
192
  demo.launch()
 
75
  subconcepts = subconcepts[:lmt]
76
 
77
  prompts = [
78
+ f"Please give a detailed explanation of this subconcept: {subconcept} in the context of this original concept: {concept}" for subconcept in subconcepts
79
  ]
80
 
81
  progress(0.3, f"Generating explanations for {len(subconcepts)} subconcepts in parallel")
 
119
 
120
  progress(0.9, "Formatting output")
121
  # Format the output in Markdown
122
+ perf_markdown = f"### Performance\n\n"
123
+ perf_markdown += f"**# of LLama 3.2 3B calls made to SambaNova's API:** {num_subconcepts + 1}\n\n"
124
+ perf_markdown += f"**# of LLama 3.1 8B calls made to SambaNova's API: 1 (summary)**\n\n"
125
+ perf_markdown += f"**Total time taken:** {total_time:.2f} seconds\n\n"
126
+
127
  markdown_intro = f"# Lesson Plan: {concept.title()}\n\n"
 
 
 
 
128
  markdown_intro += intro_summary
129
 
130
  subconcept_markdowns = []
 
142
  new_tabs.extend([gr.update(visible=False, render=False) for _ in range(MAX_SUBCONCEPTS-len(subconcept_markdowns))])
143
  new_tab_contents.extend([gr.update(visible=False) for _ in range(MAX_SUBCONCEPTS-len(subconcept_markdowns))])
144
 
145
+ return "Process complete!", perf_markdown, markdown_intro, *new_tabs, *new_tab_contents
146
 
147
  with gr.Blocks() as demo:
148
  gr.Markdown(
149
  """
150
  # Lesson Plan Generator
151
 
152
+ **Ever wanted to learn something new? Struggled to break down the concept to more digestible subconcepts? In this demo, we use <a href="https://cloud.sambanova.ai">SambaNova's</a> superfast LLama 3.2 3B and LLama 3.1 8B models to expound on the concept and subconcepts, provide a detailed lesson for each of the subconcepts, and summarize the lesson plan.**
153
 
154
  *To use this, follow the instructions below:*
155
 
 
174
 
175
  with gr.Column():
176
  progress_output = gr.Textbox(label="Progress", interactive=True)
177
+ performance_output = gr.Markdown(label="Performance", container=True)
178
  lesson_intro = gr.Markdown(label="Lesson Intro", container=True)
179
 
180
  tab_contents = []
 
188
  generate_btn.click(
189
  process_concept,
190
  inputs=[sn_api_key_input, concept_input, slider],
191
+ outputs=[progress_output, performance_output, lesson_intro] + [tabs.children[i] for i in range(MAX_SUBCONCEPTS)] + tab_contents
192
  )
193
 
194
  demo.launch()