File size: 895 Bytes
d1ba382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
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("dataset.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)