Team Ai
Apppublic

anithai/Java-Gradio-Chatbot

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py33 linesDownload Raw Back to root
1import gradio as gr2import subprocess3 4def chatbot_interface(question):5    try:6        result = subprocess.run(7            ['java', '-cp', '.', 'Main', question],8            capture_output=True,9            text=True10        )11        response = result.stdout.strip()12        error_output = result.stderr.strip()13 14        if error_output:15            return f"Java Error: {error_output}"16        if not response:17            return "Error: No response received from the Java logic."18        return response19 20    except Exception as e:21        return f"Error: {str(e)}"22 23iface = gr.Interface(24    fn=chatbot_interface,25    inputs=gr.Textbox(label="Enter your question"),26    outputs=gr.Textbox(label="Response"),27    title="Syllabus Related Answer Chatbot",28    description="Ask syllabus-related questions and get accurate responses.",29    flagging_dir="/tmp/flagged"30)31 32iface.launch()33