Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,6 +42,14 @@ prompt = PromptTemplate(input_variables=['task_type', 'task_number', 'question',
|
|
| 42 |
# Define the LLM chain
|
| 43 |
chain = LLMChain(llm=llm_model, prompt=prompt)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def evaluate(task_type, task_number, question, input_type, image=None, text=None):
|
| 46 |
if input_type == "Image" and image is not None:
|
| 47 |
# Process the image to extract text
|
|
@@ -66,12 +74,7 @@ def evaluate(task_type, task_number, question, input_type, image=None, text=None
|
|
| 66 |
|
| 67 |
return result
|
| 68 |
|
| 69 |
-
|
| 70 |
-
def toggle_input(input_type):
|
| 71 |
-
if input_type == "Image":
|
| 72 |
-
return gr.update(visible=True), gr.update(visible=False)
|
| 73 |
-
else:
|
| 74 |
-
return gr.update(visible=False), gr.update(visible=True)
|
| 75 |
|
| 76 |
footer_html_with_analytics = f"""
|
| 77 |
<script async src="https://www.googletagmanager.com/gtag/js?id={tracking_id}"></script>
|
|
@@ -100,6 +103,7 @@ footer_html_with_analytics = f"""
|
|
| 100 |
</div>
|
| 101 |
"""
|
| 102 |
|
|
|
|
| 103 |
# Create the Gradio interface
|
| 104 |
with gr.Blocks() as demo:
|
| 105 |
gr.Markdown("# IELTS Writing Evaluation")
|
|
@@ -116,12 +120,15 @@ with gr.Blocks() as demo:
|
|
| 116 |
|
| 117 |
input_type.change(toggle_input, [input_type], [image_input, text_input])
|
| 118 |
|
| 119 |
-
gr.
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
| 125 |
gr.HTML(footer_html_with_analytics)
|
| 126 |
|
| 127 |
# Launch the interface
|
|
|
|
| 42 |
# Define the LLM chain
|
| 43 |
chain = LLMChain(llm=llm_model, prompt=prompt)
|
| 44 |
|
| 45 |
+
# Define the function to toggle input visibility
|
| 46 |
+
def toggle_input(input_type):
|
| 47 |
+
if input_type == "Image":
|
| 48 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 49 |
+
else:
|
| 50 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 51 |
+
|
| 52 |
+
# Define the evaluation function
|
| 53 |
def evaluate(task_type, task_number, question, input_type, image=None, text=None):
|
| 54 |
if input_type == "Image" and image is not None:
|
| 55 |
# Process the image to extract text
|
|
|
|
| 74 |
|
| 75 |
return result
|
| 76 |
|
| 77 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
footer_html_with_analytics = f"""
|
| 80 |
<script async src="https://www.googletagmanager.com/gtag/js?id={tracking_id}"></script>
|
|
|
|
| 103 |
</div>
|
| 104 |
"""
|
| 105 |
|
| 106 |
+
|
| 107 |
# Create the Gradio interface
|
| 108 |
with gr.Blocks() as demo:
|
| 109 |
gr.Markdown("# IELTS Writing Evaluation")
|
|
|
|
| 120 |
|
| 121 |
input_type.change(toggle_input, [input_type], [image_input, text_input])
|
| 122 |
|
| 123 |
+
result_output = gr.Markdown(label="Result")
|
| 124 |
+
|
| 125 |
+
# Define the submit button and the function to be called
|
| 126 |
+
submit_button = gr.Button("Submit")
|
| 127 |
+
submit_button.click(fn=evaluate,
|
| 128 |
+
inputs=[test_type, task_number, question, input_type, image_input, text_input],
|
| 129 |
+
outputs=result_output)
|
| 130 |
+
|
| 131 |
+
# Add the footer HTML
|
| 132 |
gr.HTML(footer_html_with_analytics)
|
| 133 |
|
| 134 |
# Launch the interface
|