import gradio as gr import json from utils import get_best_answer from dotenv import load_dotenv # ✅ Load environment variables load_dotenv() # ✅ Load dataset with open("ds.json", "r") as f: dataset = json.load(f) # ✅ Gradio UI Function def chatbot_response(user_input): try: best_answer = get_best_answer(user_input) return best_answer # ✅ Displays the rephrased best answer except Exception as e: return "Oops! Something went wrong. Please try again." # ✅ Gradio Interface iface = gr.Interface( fn=chatbot_response, inputs="text", outputs="text", title="UOE Academic Chatbot", description="Hello! 🎓 Welcome to **Academic Navigator** – the university information assistant for UOE.\nI can answer your university-related questions, such as admissions, scholarships." ) # ✅ Launch App iface.launch(share=True)