nniehaus commited on
Commit
1e560ed
·
1 Parent(s): 88073e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -18
app.py CHANGED
@@ -1,22 +1,31 @@
1
  import streamlit as st
2
  import openai
3
 
4
- # Access the OpenAI API key from Hugging Face Spaces secrets
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
- st.title("AI Lead Magnet Idea Generator for Marketers")
8
 
9
- # User inputs for the marketing plan
10
- st.subheader("Tell Us About Your Target Audience")
11
- business_type = st.text_input("Business Type", placeholder="e.g., Real Estate, E-commerce")
12
- target_audience = st.text_area("Target Audience", placeholder="Describe your primary customer base")
 
13
 
14
- # Generate AI lead magnet ideas button
15
- if st.button('Generate AI Lead Magnet Ideas'):
16
- # Construct the prompt for AI lead magnet ideas
 
 
 
 
 
 
 
 
17
  prompt_text = (
18
- f"Generate ideas for AI-based lead magnets that a {business_type} company can offer to their target audience: {target_audience}. "
19
- f"Focus on interactive and engaging AI-driven tools or content that can attract and provide value to their customers."
20
  )
21
 
22
  # Call the OpenAI API for text generation
@@ -24,16 +33,17 @@ if st.button('Generate AI Lead Magnet Ideas'):
24
  response_text = openai.ChatCompletion.create(
25
  model="gpt-4",
26
  messages=[
27
- {"role": "system", "content": "You are an assistant who specializes in marketing and AI applications."},
28
  {"role": "user", "content": prompt_text}
29
  ]
30
  )
31
- lead_magnet_ideas = response_text.choices[0].message['content']
32
  except Exception as e:
33
- lead_magnet_ideas = f"Error in generating AI lead magnet ideas: {e}"
34
 
35
- # Display the AI lead magnet ideas
36
- st.markdown("### AI Lead Magnet Ideas")
37
- st.write(lead_magnet_ideas)
38
 
39
- # Rest of your Streamlit code...
 
 
1
  import streamlit as st
2
  import openai
3
 
4
+ # Access the OpenAI API key from environment variables or secrets
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
+ st.title("Personalized 6-Month Fitness and Health Plan Generator")
8
 
9
+ # User inputs
10
+ st.subheader("About You")
11
+ name = st.text_input("Your Name", placeholder="Enter your name")
12
+ age = st.number_input("Your Age", min_value=12, max_value=100, step=1)
13
+ gender = st.selectbox("Your Gender", ["Female", "Male", "Prefer not to say"])
14
 
15
+ st.subheader("Current Fitness and Health Status")
16
+ current_fitness_level = st.selectbox("Your Current Fitness Level", ["Beginner", "Intermediate", "Advanced"])
17
+ current_health_issues = st.text_area("Current Health Issues", placeholder="Any known health issues or concerns")
18
+ dietary_preferences = st.text_area("Dietary Preferences", placeholder="e.g., Vegan, Gluten-free, Keto, No preferences")
19
+
20
+ st.subheader("Your Fitness Goals")
21
+ fitness_goals = st.multiselect("Select Your Fitness Goals", ["Weight loss", "Muscle gain", "Endurance improvement", "Flexibility", "General well-being"])
22
+ goal_timeframe = st.selectbox("Goal Timeframe", ["3 months", "6 months", "1 year"])
23
+
24
+ if st.button('Generate My Fitness Plan'):
25
+ # Construct the prompt for the AI
26
  prompt_text = (
27
+ f"Create a personalized 6-month fitness and health plan for {name}, a {age}-year-old {gender} with {current_fitness_level} fitness level. "
28
+ f"Health issues: {current_health_issues}. Dietary preferences: {dietary_preferences}. Fitness goals: {', '.join(fitness_goals)} over {goal_timeframe}."
29
  )
30
 
31
  # Call the OpenAI API for text generation
 
33
  response_text = openai.ChatCompletion.create(
34
  model="gpt-4",
35
  messages=[
36
+ {"role": "system", "content": "You are an AI fitness coach."},
37
  {"role": "user", "content": prompt_text}
38
  ]
39
  )
40
+ fitness_plan = response_text.choices[0].message['content']
41
  except Exception as e:
42
+ fitness_plan = f"Error in generating fitness plan: {e}"
43
 
44
+ # Display the fitness plan
45
+ st.markdown("### Your Personalized 6-Month Fitness Plan")
46
+ st.write(fitness_plan)
47
 
48
+ # Disclaimer
49
+ st.write("Disclaimer: This tool provides suggestions based on AI-generated content. Please consult with a healthcare provider or a professional fitness trainer before starting any new fitness program.")