abhiimanyu commited on
Commit
d934fa4
·
verified ·
1 Parent(s): 8fe829b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -14,22 +14,30 @@ client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
14
  # return prompt
15
  def format_prompt(topic, description, difficulty):
16
  prompt = (
17
- f"You are an expert educator. Generate highly engaging, educational, and structured content on the topic '{topic}'. "
18
  f"Use the following description as context: '{description}'. "
19
- f"The content should be suitable for a '{difficulty}' difficulty level and should follow this structure:\n\n"
20
- f"1. Title: Provide a concise and captivating title for the content.\n"
21
- f"2. Introduction: Write an engaging introduction that sets the stage for the topic.\n"
22
- f"3. Key Points: Present the main points or concepts related to the topic in clear, logical sections. "
23
- f"Each section should have:\n"
24
- f" - Heading: A clear and descriptive heading for the section.\n"
25
- f" - Description: A detailed explanation of the concept, broken into paragraphs if necessary.\n"
26
- f"4. Conclusion: Summarize the key takeaways and encourage further exploration or application of the topic.\n\n"
27
- f"Ensure the writing is informative, captivating, easy to follow, and formatted properly with headings and descriptions. "
28
- f"The content must be concise yet detailed, suitable for the specified difficulty level."
 
 
 
 
 
 
 
29
  )
30
  return prompt
31
 
32
 
 
33
  # The function to generate learning content based on the inputs
34
  def generate_learning_content(topic, description, difficulty, temperature=0.9, max_new_tokens=2000, top_p=0.95, repetition_penalty=1.2):
35
  temperature = max(float(temperature), 1e-2) # Ensure minimum temperature
 
14
  # return prompt
15
  def format_prompt(topic, description, difficulty):
16
  prompt = (
17
+ f"You are an expert educator. Generate structured educational content on the topic '{topic}'. "
18
  f"Use the following description as context: '{description}'. "
19
+ f"The content should be suitable for a '{difficulty}' difficulty level and follow this exact structure:\n\n"
20
+ f"1. Title: A clear and concise title for the topic.\n"
21
+ f"2. Sections: Each section must include:\n"
22
+ f" - Subheading: A descriptive subheading summarizing the section.\n"
23
+ f" - Reading Content: Detailed content explaining the section, broken into well-organized paragraphs.\n"
24
+ f"3. Ensure the output is formatted as follows:\n\n"
25
+ f" Title: [Your Topic Title]\n\n"
26
+ f" Section 1:\n"
27
+ f" Subheading: [Subheading for Section 1]\n"
28
+ f" Reading Content:\n"
29
+ f" [Detailed explanation for Section 1]\n\n"
30
+ f" Section 2:\n"
31
+ f" Subheading: [Subheading for Section 2]\n"
32
+ f" Reading Content:\n"
33
+ f" [Detailed explanation for Section 2]\n\n"
34
+ f"4. Repeat the structure for each additional section.\n\n"
35
+ f"Ensure the output is consistent, with headings, subheadings, and content for every section."
36
  )
37
  return prompt
38
 
39
 
40
+
41
  # The function to generate learning content based on the inputs
42
  def generate_learning_content(topic, description, difficulty, temperature=0.9, max_new_tokens=2000, top_p=0.95, repetition_penalty=1.2):
43
  temperature = max(float(temperature), 1e-2) # Ensure minimum temperature