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()