tarrasyed19472007 commited on
Commit
78300fa
·
verified ·
1 Parent(s): ac877e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -1,5 +1,17 @@
 
1
  import requests
2
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # Define the 3 questions for mood analysis
5
  questions = [
@@ -10,7 +22,7 @@ questions = [
10
 
11
  # Function to query the Gemini API
12
  def query_gemini_api(user_answers):
13
- url = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=AIzaSyBDo08q1vihxhI4nIHv0R6kDOPNT02NYG4' # Replace with your actual API key
14
  headers = {'Content-Type': 'application/json'}
15
 
16
  # Prepare the payload with user answers
 
1
+ import os
2
  import requests
3
  import streamlit as st
4
+ from dotenv import load_dotenv
5
+
6
+ # Load environment variables from the .env file
7
+ load_dotenv()
8
+
9
+ # Get the Gemini API key from the .env file
10
+ GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
11
+
12
+ if GEMINI_API_KEY is None:
13
+ st.error("API key not found! Please set the GEMINI_API_KEY in your .env file.")
14
+ st.stop()
15
 
16
  # Define the 3 questions for mood analysis
17
  questions = [
 
22
 
23
  # Function to query the Gemini API
24
  def query_gemini_api(user_answers):
25
+ url = f'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key={GEMINI_API_KEY}'
26
  headers = {'Content-Type': 'application/json'}
27
 
28
  # Prepare the payload with user answers