File size: 3,214 Bytes
5896fe9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import streamlit as st
import os
import sys
import platform
import json

# Page config
st.set_page_config(
    page_title="KARTE - Diagnostic Test",
    page_icon="🔍",
    layout="wide"
)

# Title
st.title("🔍 KARTE - Diagnostic Test")
st.markdown("This is a diagnostic app to troubleshoot Hugging Face Spaces deployment issues.")

# System information
st.header("System Information")
st.write(f"Python version: {sys.version}")
st.write(f"Platform: {platform.platform()}")
st.write(f"Current working directory: {os.getcwd()}")

# Environment variables
st.header("Environment Variables")
env_vars = {k: v for k, v in os.environ.items() if not k.startswith('_')}
st.write(f"Number of environment variables: {len(env_vars)}")
st.write("Environment variable names:")
st.write(list(env_vars.keys()))

# Check for specific environment variables
st.header("Required Environment Variables")
required_vars = ["OPENAI_API_KEY", "GROQ_API_KEY", "BASIC_AUTH_USERNAME", "BASIC_AUTH_PASSWORD"]
for var in required_vars:
    if var in os.environ:
        st.success(f"✅ {var} is set")
    else:
        st.error(f"❌ {var} is not set")

# Check for Streamlit secrets
st.header("Streamlit Secrets")
if hasattr(st, 'secrets'):
    st.success("✅ Streamlit secrets are available")
    # Check if our required variables are in secrets
    for var in required_vars:
        if var in st.secrets:
            st.success(f"✅ {var} is in Streamlit secrets")
        else:
            st.warning(f"⚠️ {var} is not in Streamlit secrets")
else:
    st.error("❌ Streamlit secrets are not available")

# File system
st.header("File System")
st.write("Files in current directory:")
st.write(os.listdir('.'))

if os.path.exists("prompts"):
    st.success("✅ 'prompts' directory exists")
    st.write("Files in 'prompts' directory:")
    st.write(os.listdir('prompts'))
else:
    st.error("❌ 'prompts' directory does not exist")

# Check for ffmpeg
st.header("External Dependencies")
import subprocess
try:
    result = subprocess.run(["ffmpeg", "-version"], capture_output=True, text=True)
    if result.returncode == 0:
        st.success("✅ ffmpeg is installed")
        st.write(result.stdout.split('\n')[0])
    else:
        st.error("❌ ffmpeg is not installed or not working")
except Exception as e:
    st.error(f"❌ Error checking ffmpeg: {str(e)}")

# Python packages
st.header("Python Packages")
try:
    import pkg_resources
    packages = [d for d in pkg_resources.working_set]
    package_dict = {p.key: p.version for p in packages}
    
    required_packages = ["streamlit", "openai", "groq", "python-dotenv", "pydub"]
    for pkg in required_packages:
        if pkg in package_dict:
            st.success(f"✅ {pkg} {package_dict[pkg]} is installed")
        else:
            st.error(f"❌ {pkg} is not installed")
    
    st.write("All installed packages:")
    st.json(package_dict)
except Exception as e:
    st.error(f"Error listing packages: {str(e)}")

# Test Streamlit functionality
st.header("Streamlit Functionality Test")
if st.button("Test Button"):
    st.success("Button works!")

test_text = st.text_input("Test Text Input", "Type something here")
st.write(f"You typed: {test_text}")