Update app.py
Browse files
app.py
CHANGED
|
@@ -55,37 +55,37 @@ def predict(page_text="", selected_text="", evidence_text=""):
|
|
| 55 |
"""
|
| 56 |
# Extract claims
|
| 57 |
claims = extract_claims(page_text) if page_text else []
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 55 |
"""
|
| 56 |
# Extract claims
|
| 57 |
claims = extract_claims(page_text) if page_text else []
|
| 58 |
+
|
| 59 |
+
# Combine claims + selected text for AI detection
|
| 60 |
+
ai_input = claims.copy()
|
| 61 |
+
if selected_text:
|
| 62 |
+
ai_input.append(selected_text)
|
| 63 |
+
ai_results = detect_ai(ai_input) if ai_input else []
|
| 64 |
+
|
| 65 |
+
# Fact-checking: only if evidence is provided
|
| 66 |
+
fc_results = fact_check(claims + ([selected_text] if selected_text else []), evidence_text) if evidence_text else []
|
| 67 |
+
|
| 68 |
+
return {
|
| 69 |
+
"claims": claims,
|
| 70 |
+
"ai_detection": ai_results,
|
| 71 |
+
"fact_checking": fc_results
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
# ---------------------------
|
| 75 |
+
# Gradio UI
|
| 76 |
+
# ---------------------------
|
| 77 |
+
with gr.Blocks() as demo:
|
| 78 |
+
gr.Markdown("## EduShield AI Backend - Predict API & UI")
|
| 79 |
+
|
| 80 |
+
page_text_input = gr.Textbox(label="Full Page Text", lines=10, placeholder="Paste page text here...")
|
| 81 |
+
selected_text_input = gr.Textbox(label="Selected Text", lines=5, placeholder="Paste selected text here...")
|
| 82 |
+
evidence_input = gr.Textbox(label="Evidence Text", lines=5, placeholder="Paste evidence text here...")
|
| 83 |
+
predict_btn = gr.Button("Run Predict")
|
| 84 |
+
output_json = gr.JSON(label="Predict Results")
|
| 85 |
+
predict_btn.click(predict, inputs=[page_text_input, selected_text_input, evidence_input], outputs=output_json)
|
| 86 |
+
|
| 87 |
+
# ---------------------------
|
| 88 |
+
# Launch
|
| 89 |
+
# ---------------------------
|
| 90 |
+
if __name__ == "__main__":
|
| 91 |
+
demo.launch(server_name="0.0.0.0")
|