Spaces:
Sleeping
Sleeping
Add debug info and improve secrets handling
Browse files- src/streamlit_app.py +9 -2
src/streamlit_app.py
CHANGED
@@ -42,12 +42,19 @@ try:
|
|
42 |
# Try multiple ways to get the API key
|
43 |
api_key = None
|
44 |
|
45 |
-
# Try environment variable
|
46 |
api_key = os.getenv("ANTHROPIC_KEY")
|
47 |
|
48 |
# Try Streamlit secrets if env var not found
|
49 |
if not api_key and hasattr(st, 'secrets'):
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
if not api_key:
|
53 |
st.error("""
|
|
|
42 |
# Try multiple ways to get the API key
|
43 |
api_key = None
|
44 |
|
45 |
+
# Try environment variable first
|
46 |
api_key = os.getenv("ANTHROPIC_KEY")
|
47 |
|
48 |
# Try Streamlit secrets if env var not found
|
49 |
if not api_key and hasattr(st, 'secrets'):
|
50 |
+
try:
|
51 |
+
api_key = st.secrets["ANTHROPIC_KEY"] # Try direct dictionary access
|
52 |
+
except (KeyError, AttributeError):
|
53 |
+
pass # Secret not found, continue to error message
|
54 |
+
|
55 |
+
# Debug info (will be removed in production)
|
56 |
+
st.write("Available secrets:", [k for k in st.secrets.keys()] if hasattr(st, 'secrets') else "No secrets available")
|
57 |
+
st.write("Environment variables:", [k for k in os.environ.keys() if not k.startswith("_")])
|
58 |
|
59 |
if not api_key:
|
60 |
st.error("""
|