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