Abbas0786 commited on
Commit
304e4da
·
verified ·
1 Parent(s): ff80cb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -32
app.py CHANGED
@@ -6,19 +6,23 @@ import folium
6
  from folium import plugins
7
  import pandas as pd
8
  from streamlit.components.v1 import html
9
- from groq import Groq
 
 
 
10
 
11
  # Use environment variables to store sensitive data
12
  GROQ_API_KEY = os.getenv("GROQ_API_KEY", "default_value_if_key_missing")
13
  ORS_API_KEY = os.getenv("ORS_API_KEY", "default_value_if_key_missing")
14
 
15
- # Initialize Groq client with the API key from the environment variable
16
- client = Groq(api_key=GROQ_API_KEY)
 
17
 
18
  # Set up the title and description for the Streamlit app
19
  st.set_page_config(page_title="Gaia: Women Safety App", page_icon="🤖", layout="centered")
20
 
21
- # Function to get AI response (Groq model)
22
  def get_response(user_input):
23
  """Get response from Groq AI model."""
24
  if 'messages' not in st.session_state:
@@ -43,7 +47,7 @@ def get_response(user_input):
43
  st.sidebar.title('Features')
44
  page = st.sidebar.radio("Choose a feature", ["Personal Information", "AI-Powered Support", "Emergency Call", "Dangerous Area Map", "ORS Route"])
45
 
46
- # Personal Information Page (First Page)
47
  if page == "Personal Information":
48
  st.title("Personal Information Page")
49
  st.write("Please fill in the following details:")
@@ -138,7 +142,7 @@ elif page == "Dangerous Area Map":
138
  map_html = m._repr_html_()
139
  html(map_html, height=500)
140
 
141
- # ORS Route Page (New Page)
142
  elif page == "ORS Route":
143
  st.title("OpenRouteService: Route Calculator")
144
  st.write("Enter your current location and destination to calculate the route:")
@@ -172,29 +176,4 @@ elif page == "ORS Route":
172
  # Plot the route on the map
173
  folium.PolyLine(locations=[(lat, lon) for lon, lat in route], color='blue', weight=5).add_to(route_map)
174
 
175
- # Display the route map in the app
176
- st.subheader("Calculated Route")
177
- route_html = route_map._repr_html_()
178
- html(route_html, height=500)
179
- else:
180
- st.error(f"Error: {response.status_code}")
181
- except requests.exceptions.HTTPError as err:
182
- st.error(f"HTTP error occurred: {err}")
183
- except Exception as err:
184
- st.error(f"An error occurred: {err}")
185
- else:
186
- st.error("Please enter valid coordinates for both start and end locations.")
187
-
188
- # Styling the chat window (Optional)
189
- st.markdown("""
190
- <style>
191
- .css-1v3fvcr {
192
- font-family: 'Arial', sans-serif;
193
- background-color: #f0f2f6;
194
- border-radius: 12px;
195
- padding: 15px;
196
- box-shadow: 0 0 20px rgba(0,0,0,0.1);
197
- }
198
- .css-15zrgwt {
199
- font-size: 1.1rem;
200
- line-height: 1.
 
6
  from folium import plugins
7
  import pandas as pd
8
  from streamlit.components.v1 import html
9
+ from dotenv import load_dotenv
10
+
11
+ # Load environment variables from .env file
12
+ load_dotenv()
13
 
14
  # Use environment variables to store sensitive data
15
  GROQ_API_KEY = os.getenv("GROQ_API_KEY", "default_value_if_key_missing")
16
  ORS_API_KEY = os.getenv("ORS_API_KEY", "default_value_if_key_missing")
17
 
18
+ # Initialize Groq client with the API key from the environment variable (assuming Groq client exists)
19
+ # Make sure to install and use the correct library for Groq or replace it with another AI provider.
20
+ # client = Groq(api_key=GROQ_API_KEY) # This line assumes Groq is a valid library.
21
 
22
  # Set up the title and description for the Streamlit app
23
  st.set_page_config(page_title="Gaia: Women Safety App", page_icon="🤖", layout="centered")
24
 
25
+ # Function to get AI response (Groq model) - assuming Groq API works similarly to OpenAI's API
26
  def get_response(user_input):
27
  """Get response from Groq AI model."""
28
  if 'messages' not in st.session_state:
 
47
  st.sidebar.title('Features')
48
  page = st.sidebar.radio("Choose a feature", ["Personal Information", "AI-Powered Support", "Emergency Call", "Dangerous Area Map", "ORS Route"])
49
 
50
+ # Personal Information Page
51
  if page == "Personal Information":
52
  st.title("Personal Information Page")
53
  st.write("Please fill in the following details:")
 
142
  map_html = m._repr_html_()
143
  html(map_html, height=500)
144
 
145
+ # ORS Route Page
146
  elif page == "ORS Route":
147
  st.title("OpenRouteService: Route Calculator")
148
  st.write("Enter your current location and destination to calculate the route:")
 
176
  # Plot the route on the map
177
  folium.PolyLine(locations=[(lat, lon) for lon, lat in route], color='blue', weight=5).add_to(route_map)
178
 
179
+ # Display the route