anithai commited on
Commit
0149d28
·
verified ·
1 Parent(s): 7d6b580
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+
4
+ def chatbot_interface(question):
5
+ try:
6
+ # Correct Java path for Hugging Face deployment
7
+ result = subprocess.run(
8
+ ['java', '-cp', '/app:/app/lib/json-20210307.jar', 'Main', question],
9
+ capture_output=True,
10
+ text=True
11
+ )
12
+
13
+ response = result.stdout.strip()
14
+ error_output = result.stderr.strip()
15
+
16
+ if error_output:
17
+ return f"Java Error: {error_output}"
18
+ if not response:
19
+ return "Error: No response received from the Java logic."
20
+ return response
21
+
22
+ except Exception as e:
23
+ return f"Error: {str(e)}"
24
+
25
+ iface = gr.Interface(
26
+ fn=chatbot_interface,
27
+ inputs=gr.Textbox(label="Enter your question"),
28
+ outputs=gr.Textbox(label="Response"),
29
+ title="Syllabus Related Answer Chatbot",
30
+ description="Ask syllabus-related questions and get accurate responses."
31
+ )
32
+
33
+ if __name__ == "__main__":
34
+ iface.launch()