Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,26 +11,49 @@ from langchain.memory import ConversationBufferMemory
|
|
11 |
from langchain.chains import ConversationalRetrievalChain
|
12 |
from gtts import gTTS
|
13 |
import sys
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
# Load environment variables
|
35 |
load_dotenv()
|
36 |
secret_key = os.getenv("GROQ_API_KEY")
|
|
|
11 |
from langchain.chains import ConversationalRetrievalChain
|
12 |
from gtts import gTTS
|
13 |
import sys
|
14 |
+
import pytesseract
|
15 |
+
from pdf2image import convert_from_path
|
16 |
+
|
17 |
+
def check_installation(command):
|
18 |
+
try:
|
19 |
+
result = subprocess.run([command, '--version'], capture_output=True, text=True)
|
20 |
+
return result.returncode == 0, result.stdout
|
21 |
+
except FileNotFoundError:
|
22 |
+
return False, f"{command} not found"
|
23 |
+
|
24 |
+
def check_dependencies():
|
25 |
+
dependencies = {
|
26 |
+
'tesseract': '/usr/bin/tesseract',
|
27 |
+
'pdftoppm': '/usr/bin/pdftoppm', # Part of poppler-utils
|
28 |
+
}
|
29 |
+
|
30 |
+
status = {}
|
31 |
+
for dep, path in dependencies.items():
|
32 |
+
installed, version = check_installation(path)
|
33 |
+
status[dep] = {
|
34 |
+
'installed': installed,
|
35 |
+
'path': path,
|
36 |
+
'version': version if installed else 'Not found'
|
37 |
+
}
|
38 |
|
39 |
+
return status
|
40 |
+
|
41 |
+
def log_dependency_status(status):
|
42 |
+
print("Dependency Status:")
|
43 |
+
for dep, info in status.items():
|
44 |
+
print(f"{dep}:")
|
45 |
+
print(f" Installed: {info['installed']}")
|
46 |
+
print(f" Path: {info['path']}")
|
47 |
+
print(f" Version: {info['version']}")
|
48 |
+
print("\nEnvironment Variables:")
|
49 |
+
for key, value in os.environ.items():
|
50 |
+
if 'PATH' in key or 'PYTHONPATH' in key:
|
51 |
+
print(f"{key}: {value}")
|
52 |
+
|
53 |
+
# Run dependency check
|
54 |
+
dependency_status = check_dependencies()
|
55 |
+
log_dependency_status(dependency_status)
|
56 |
+
|
57 |
# Load environment variables
|
58 |
load_dotenv()
|
59 |
secret_key = os.getenv("GROQ_API_KEY")
|