|
|
import streamlit as st |
|
|
import os |
|
|
import sys |
|
|
import platform |
|
|
import json |
|
|
|
|
|
|
|
|
st.set_page_config( |
|
|
page_title="KARTE - Diagnostic Test", |
|
|
page_icon="🔍", |
|
|
layout="wide" |
|
|
) |
|
|
|
|
|
|
|
|
st.title("🔍 KARTE - Diagnostic Test") |
|
|
st.markdown("This is a diagnostic app to troubleshoot Hugging Face Spaces deployment issues.") |
|
|
|
|
|
|
|
|
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()}") |
|
|
|
|
|
|
|
|
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())) |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
st.header("Streamlit Secrets") |
|
|
if hasattr(st, 'secrets'): |
|
|
st.success("✅ Streamlit secrets are available") |
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
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)}") |
|
|
|
|
|
|
|
|
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)}") |
|
|
|
|
|
|
|
|
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}") |