Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,26 @@ import gradio as gr
|
|
| 4 |
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
| 5 |
|
| 6 |
# Function to format the input into a suitable prompt for generating strict and engaging learning content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def format_prompt(topic, description, difficulty):
|
| 8 |
prompt = (
|
| 9 |
-
f"You are an expert educator. Generate highly engaging
|
| 10 |
-
f"
|
| 11 |
-
f"The content should be suitable for a '{difficulty}' difficulty level
|
| 12 |
-
f"
|
|
|
|
| 13 |
)
|
| 14 |
return prompt
|
| 15 |
|
| 16 |
# The function to generate learning content based on the inputs
|
| 17 |
-
def generate_learning_content(topic, description, difficulty, temperature=0.9, max_new_tokens=
|
| 18 |
temperature = max(float(temperature), 1e-2) # Ensure minimum temperature
|
| 19 |
top_p = float(top_p)
|
| 20 |
|
|
|
|
| 4 |
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
| 5 |
|
| 6 |
# Function to format the input into a suitable prompt for generating strict and engaging learning content
|
| 7 |
+
# def format_prompt(topic, description, difficulty):
|
| 8 |
+
# prompt = (
|
| 9 |
+
# f"You are an expert educator. Generate highly engaging and educational learning content "
|
| 10 |
+
# f"strictly on the topic '{topic}', with the following description: '{description}'. "
|
| 11 |
+
# f"The content should be suitable for a '{difficulty}' difficulty level, and it should be presented in a way that helps readers clearly understand the key points. "
|
| 12 |
+
# f"Please provide the content in paragraph form, ensuring it is both informative and interesting for the learner."
|
| 13 |
+
# )
|
| 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 present key points clearly and logically. "
|
| 20 |
+
f"Ensure the writing is informative, easy to follow, and captivating for the learner. "
|
| 21 |
+
f"Structure the content in well-organized paragraphs to enhance readability and understanding."
|
| 22 |
)
|
| 23 |
return prompt
|
| 24 |
|
| 25 |
# The function to generate learning content based on the inputs
|
| 26 |
+
def generate_learning_content(topic, description, difficulty, temperature=0.9, max_new_tokens=1500, top_p=0.95, repetition_penalty=1.2):
|
| 27 |
temperature = max(float(temperature), 1e-2) # Ensure minimum temperature
|
| 28 |
top_p = float(top_p)
|
| 29 |
|