Spaces:
Runtime error
Runtime error
app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
def chatbot_interface(question):
|
| 5 |
+
try:
|
| 6 |
+
result = subprocess.run(
|
| 7 |
+
['java', '-cp', '.', 'Main', question],
|
| 8 |
+
capture_output=True,
|
| 9 |
+
text=True
|
| 10 |
+
)
|
| 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 response
|
| 19 |
+
|
| 20 |
+
except Exception as e:
|
| 21 |
+
return f"Error: {str(e)}"
|
| 22 |
+
|
| 23 |
+
iface = 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 |
+
)
|
| 30 |
+
|
| 31 |
+
iface.launch()
|