From 8326e7d00207d132ed0061534bb5715204ceb506 Mon Sep 17 00:00:00 2001 From: charvi arora <107393948+Charvi-14@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:12:24 +0530 Subject: [PATCH] Update app.py Add support for environment variables using a .env file Using a .env File (Recommended for Development): - Created a .env file in the root directory to manage environment variables for development. - Added CLAUDE_API_KEY to the .env file. Instructions: 1. Add your environment variable to the file: CLAUDE_API_KEY=your_api_key_here 2. Install the python-dotenv package to read the .env file in your Python script: pip install python-dotenv 3. Updated the script to load the environment variables with the following code --- app.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 89deb08..e75bbe1 100644 --- a/app.py +++ b/app.py @@ -5,14 +5,18 @@ import requests, random from streamlit_lottie import st_lottie from streamlit_option_menu import option_menu - +import os +from dotenv import load_dotenv #AI Integration import anthropic -# Retrieve API key from Hugging Face secrets -claude_api_key = "api-key" +#Changes made by --Charvi Arora +#Added security +# Load environment variables from .env file +load_dotenv() +# Retrieve the API key +claude_api_key = os.getenv("CLAUDE_API_KEY") -# Initialize ClaudeAI client client = anthropic.Client(api_key=claude_api_key) def anxiety_management_guide(mood, feeling_description, current_stress_level, recent_events):