|
import os |
|
import streamlit as st |
|
import pickle |
|
from pathlib import Path |
|
|
|
st.title("Debug App") |
|
|
|
|
|
st.write("## Environment Variables") |
|
if os.environ.get("OPENAI_API_KEY"): |
|
st.write("β
OPENAI_API_KEY is set") |
|
else: |
|
st.error("β OPENAI_API_KEY is not set") |
|
|
|
|
|
st.write("## Data Directory") |
|
possible_paths = [ |
|
"data/processed_data", |
|
"app/data/processed_data", |
|
"/data/processed_data", |
|
"/app/data/processed_data" |
|
] |
|
|
|
for path in possible_paths: |
|
if os.path.exists(path): |
|
st.write(f"β
Found data directory at: {path}") |
|
|
|
|
|
chunks_path = os.path.join(path, "chunks.pkl") |
|
if os.path.exists(chunks_path): |
|
st.write(f"β
Found chunks.pkl: {os.path.getsize(chunks_path) / (1024*1024):.2f} MB") |
|
|
|
|
|
try: |
|
with open(chunks_path, "rb") as f: |
|
chunks = pickle.load(f) |
|
st.write(f"β
Successfully loaded chunks: {len(chunks)} items") |
|
except Exception as e: |
|
st.error(f"β Error loading chunks.pkl: {str(e)}") |
|
else: |
|
st.error(f"β chunks.pkl not found in {path}") |
|
|
|
embedded_docs_path = os.path.join(path, "embedded_docs.pkl") |
|
if os.path.exists(embedded_docs_path): |
|
st.write(f"β
Found embedded_docs.pkl: {os.path.getsize(embedded_docs_path) / (1024*1024):.2f} MB") |
|
|
|
|
|
try: |
|
with open(embedded_docs_path, "rb") as f: |
|
embedded_docs = pickle.load(f) |
|
st.write(f"β
Successfully loaded embedded_docs: {len(embedded_docs)} items") |
|
except Exception as e: |
|
st.error(f"β Error loading embedded_docs.pkl: {str(e)}") |
|
else: |
|
st.error(f"β embedded_docs.pkl not found in {path}") |
|
|
|
break |
|
else: |
|
st.error("β Could not find data directory") |
|
|
|
st.write("## System Info") |
|
import sys |
|
st.write(f"Python version: {sys.version}") |
|
st.write(f"Working directory: {os.getcwd()}") |
|
st.write(f"Directory contents: {os.listdir('.')}") |
|
|
|
st.write("Debug complete.") |