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