File size: 1,148 Bytes
1ba1ba2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import gradio as gr
from filter_agent import filter_math_query
from wiki_scraper import get_wikipedia_article
def math_explainer(topic):
"""First checks if the topic is mathematical, corrects spelling, then fetches the full Wikipedia article and summarizes it."""
# π Step 1: Check if topic is math-related + Spelling correction
filter_result, corrected_topic = filter_math_query(topic)
if "β" in filter_result: # If the query is rejected
return filter_result # Return the error message
# π Step 2: Retrieve full Wikipedia article and summarize it
return get_wikipedia_article(corrected_topic)
iface = gr.Interface(
fn=math_explainer,
inputs="text",
outputs="text",
title="Math Research AI",
description="π Math Research AI makes learning mathematics easier by making key concepts accessible to everyone through clear and simplified explanations.\n\nThis math-specialized AI agent analyzes your query, automatically corrects spelling errors, retrieves a Wikipedia article, and generates a simplified and understandable summary."
)
if __name__ == "__main__":
iface.launch()
|