anithai commited on
Commit
9d3424b
·
verified ·
1 Parent(s): 5ca9a87
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,11 +1,16 @@
1
  import gradio as gr
2
  import subprocess
 
3
 
4
  def chatbot_interface(question):
 
 
 
 
 
5
  try:
6
- # Use full path to Java if necessary
7
  result = subprocess.run(
8
- ['/usr/bin/java', '-cp', '/app:/app/lib/json-20210307.jar', 'Main', question],
9
  capture_output=True,
10
  text=True
11
  )
 
1
  import gradio as gr
2
  import subprocess
3
+ import shutil # To locate the Java path dynamically
4
 
5
  def chatbot_interface(question):
6
+ java_path = shutil.which("java") # Finds the correct Java path
7
+
8
+ if not java_path:
9
+ return "Error: Java is not installed or not found in PATH."
10
+
11
  try:
 
12
  result = subprocess.run(
13
+ [java_path, '-cp', '/app:/app/lib/json-20210307.jar', 'Main', question],
14
  capture_output=True,
15
  text=True
16
  )