jostlebot commited on
Commit
89997ca
·
1 Parent(s): a953a14

Security: Remove hardcoded API key and add environment variable handling

Browse files
Files changed (2) hide show
  1. .env.template +2 -0
  2. 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 = "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"
 
 
 
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)}")