Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def predict(input, msg_history=STARTING_PROMPT):
|
|
33 |
return [response, msg_history]
|
34 |
|
35 |
|
36 |
-
def prompt_builder_predict(questionType=None, difficulty=0, topic=None, prerequisites=None, caseStudy=False, additionalPrompt=None, msg_history=STARTING_PROMPT):
|
37 |
|
38 |
level = ['Very Easy', 'Easy', 'Medium', 'Difficult', 'Extremely Difficult']
|
39 |
prompt = 'randomly generatate a math question '
|
@@ -47,6 +47,8 @@ def prompt_builder_predict(questionType=None, difficulty=0, topic=None, prerequi
|
|
47 |
prompt = prompt + f"This question will require to use the following methods to solve: {' and '.join(prerequisites)}. "
|
48 |
if caseStudy:
|
49 |
prompt = prompt + 'This question must be in the form of case study where it tries to test the application of the topic in the real life scenario. '
|
|
|
|
|
50 |
if additionalPrompt:
|
51 |
prompt = prompt + f"In addition, {additionalPrompt}."
|
52 |
|
@@ -70,16 +72,18 @@ with gr.Blocks() as demo:
|
|
70 |
topic = gr.Dropdown(["Simultaneous Equation", "Linear Equation", "Derivatives", "Integrals", "Optimization"], value='Simultaneous Equation', label="Main Testing Topic")
|
71 |
prerequisites = gr.Dropdown(["Elimination", "Subsitution", "Linear Equation", "Algebra", "Geometry", "Trigonometry", "Logarithms", "Power Rule", "Sum Rule", 'Difference Rule', "Product Rule", "Quotient Rule", 'Reciprocal Rule', "Chain Rule", "Implicit Differentiation", "Logarithmic Differentiation"], multiselect=True, interactive=True, label="Prerequisite Topics")
|
72 |
|
73 |
-
|
|
|
|
|
|
|
74 |
additionalInfo = gr.Textbox(label="Additional information (prompt)", placeholder="Give a scenario where Jim and John are working in a garden....")
|
75 |
|
76 |
-
|
77 |
gen_btn = gr.Button("Generate A New Question")
|
78 |
|
79 |
with gr.Row():
|
80 |
question = gr.TextArea(label="Generated Question")
|
81 |
|
82 |
-
gen_btn.click(fn=prompt_builder_predict, inputs = [questionType, difficulty, topic, prerequisites, caseStudy, additionalInfo, msg_history], outputs= [question, msg_history])
|
83 |
|
84 |
with gr.Row():
|
85 |
prompt = gr.Textbox(label='Additional Prompt', info='Not satified with the result? Enter instructions to modify the question.', placeholder='Include the case study of....', visible=False)
|
|
|
33 |
return [response, msg_history]
|
34 |
|
35 |
|
36 |
+
def prompt_builder_predict(questionType=None, difficulty=0, topic=None, prerequisites=None, caseStudy=False, additionalPrompt=None, msg_history=STARTING_PROMPT, latex=False):
|
37 |
|
38 |
level = ['Very Easy', 'Easy', 'Medium', 'Difficult', 'Extremely Difficult']
|
39 |
prompt = 'randomly generatate a math question '
|
|
|
47 |
prompt = prompt + f"This question will require to use the following methods to solve: {' and '.join(prerequisites)}. "
|
48 |
if caseStudy:
|
49 |
prompt = prompt + 'This question must be in the form of case study where it tries to test the application of the topic in the real life scenario. '
|
50 |
+
if latex:
|
51 |
+
prompt = prompt + 'Convert all mathematical equation parts of the question to LaTeX format. '
|
52 |
if additionalPrompt:
|
53 |
prompt = prompt + f"In addition, {additionalPrompt}."
|
54 |
|
|
|
72 |
topic = gr.Dropdown(["Simultaneous Equation", "Linear Equation", "Derivatives", "Integrals", "Optimization"], value='Simultaneous Equation', label="Main Testing Topic")
|
73 |
prerequisites = gr.Dropdown(["Elimination", "Subsitution", "Linear Equation", "Algebra", "Geometry", "Trigonometry", "Logarithms", "Power Rule", "Sum Rule", 'Difference Rule', "Product Rule", "Quotient Rule", 'Reciprocal Rule', "Chain Rule", "Implicit Differentiation", "Logarithmic Differentiation"], multiselect=True, interactive=True, label="Prerequisite Topics")
|
74 |
|
75 |
+
with gr.Row():
|
76 |
+
caseStudy = gr.Checkbox(label="Case Study", info="Does this question test the application of theory in real life scenarios?")
|
77 |
+
latex = gr.Checkbox(label="LaTeX", info="Display all equations in LaTex format?")
|
78 |
+
|
79 |
additionalInfo = gr.Textbox(label="Additional information (prompt)", placeholder="Give a scenario where Jim and John are working in a garden....")
|
80 |
|
|
|
81 |
gen_btn = gr.Button("Generate A New Question")
|
82 |
|
83 |
with gr.Row():
|
84 |
question = gr.TextArea(label="Generated Question")
|
85 |
|
86 |
+
gen_btn.click(fn=prompt_builder_predict, inputs = [questionType, difficulty, topic, prerequisites, caseStudy, additionalInfo, msg_history, latex], outputs= [question, msg_history])
|
87 |
|
88 |
with gr.Row():
|
89 |
prompt = gr.Textbox(label='Additional Prompt', info='Not satified with the result? Enter instructions to modify the question.', placeholder='Include the case study of....', visible=False)
|