Spaces:
Sleeping
Sleeping
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) | |