Spaces:
Sleeping
Sleeping
Security: Remove hardcoded API key and add environment variable handling
Browse files- .env.template +2 -0
- src/streamlit_app.py +4 -1
.env.template
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
# Anthropic Key
|
2 |
+
ANTHROPIC_KEY=your_anthropic_key_here
|
src/streamlit_app.py
CHANGED
@@ -39,7 +39,10 @@ AGE_CONTEXT = {
|
|
39 |
|
40 |
# Handle API key setup
|
41 |
try:
|
42 |
-
api_key = "
|
|
|
|
|
|
|
43 |
c = Anthropic(api_key=api_key)
|
44 |
except Exception as e:
|
45 |
st.error(f"Error initializing Anthropic client: {str(e)}")
|
|
|
39 |
|
40 |
# Handle API key setup
|
41 |
try:
|
42 |
+
api_key = os.getenv("ANTHROPIC_KEY")
|
43 |
+
if not api_key:
|
44 |
+
st.error("Anthropic API key not found. Please set the ANTHROPIC_KEY environment variable.")
|
45 |
+
st.stop()
|
46 |
c = Anthropic(api_key=api_key)
|
47 |
except Exception as e:
|
48 |
st.error(f"Error initializing Anthropic client: {str(e)}")
|