nniehaus commited on
Commit
ce0ea95
·
verified ·
1 Parent(s): 7e9b859

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -31
app.py CHANGED
@@ -1,46 +1,53 @@
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("Plan Your Investment Strategy")
8
 
9
- # User inputs
10
- st.subheader("Investment Profile")
11
- age = st.number_input("Your Age", min_value=18, max_value=100, step=1)
12
- investment_experience = st.selectbox("Your Investment Experience", ["Beginner", "Intermediate", "Advanced"])
13
- investment_goal = st.text_input("Investment Goal", placeholder="e.g., Retirement, Buying a Home, Education")
 
 
 
14
 
15
- st.subheader("Financial Information")
16
- annual_income = st.number_input("Annual Income", min_value=10000, max_value=1000000, step=1000) # Removed format argument
17
- investment_amount = st.number_input("Amount Available for Investment", min_value=1000, max_value=500000, step=100) # Removed format argument
18
- risk_tolerance = st.selectbox("Risk Tolerance", ["Low", "Medium", "High"])
19
 
20
- if st.button('Generate My Investment Strategy'):
21
- # Construct the prompt for the AI
22
- prompt_text = (
23
- f"Generate an investment strategy for a {age}-year-old with {investment_experience} experience. "
24
- f"Investment goal: {investment_goal}. Annual income: {annual_income}. "
25
- f"Amount available for investment: {investment_amount}. Risk tolerance: {risk_tolerance}."
26
- )
27
 
 
 
 
 
 
28
  # Call the OpenAI API for text generation
29
  try:
30
- response_text = openai.ChatCompletion.create(
31
- model="gpt-4",
32
- messages=[
33
- {"role": "system", "content": "You are an AI specializing in personalized investment strategies."},
34
- {"role": "user", "content": prompt_text}
35
- ]
 
 
36
  )
37
- investment_strategy = response_text.choices[0].message['content']
38
  except Exception as e:
39
- investment_strategy = f"Error in generating investment strategy: {e}"
40
-
41
- # Display the investment strategy
42
- st.markdown("### Your Personalized Investment Strategy")
43
- st.write(investment_strategy)
44
 
45
  # Disclaimer
46
- st.write("Disclaimer: This tool provides suggestions based on AI-generated content. Please ensure to conduct your own research or consult with a financial advisor before making any investment decisions.")
 
1
  import streamlit as st
2
  import openai
3
 
4
+ # Access the OpenAI API key from Hugging Face Spaces secrets or your environment variables
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
+ st.title("Video Script Generator")
8
 
9
+ # Define video styles and their descriptions
10
+ video_styles = {
11
+ "Explainer": "Explainer videos break down complex concepts into simple, engaging visuals and narratives.",
12
+ "Testimonial": "Testimonial videos feature satisfied customers sharing their positive experiences.",
13
+ "Product Demo": "Product demos showcase the features and benefits of a product in action.",
14
+ "How-To": "How-to videos provide step-by-step instructions on performing a task or using a product.",
15
+ "Brand Story": "Brand story videos share the company's mission, vision, and values, connecting emotionally with the audience."
16
+ }
17
 
18
+ # User selects the video style
19
+ video_style = st.selectbox("Choose the style of video you want to create:", options=list(video_styles.keys()))
 
 
20
 
21
+ # Display the description of the selected video style
22
+ st.write(f"**Description:** {video_styles[video_style]}")
23
+
24
+ # Additional inputs
25
+ business_name = st.text_input("Business Name", "Your Business Name")
26
+ target_audience = st.text_area("Target Audience", "Describe your target audience.")
 
27
 
28
+ # Button to generate video script
29
+ if st.button('Generate Video Script'):
30
+ # Construct the prompt for the AI
31
+ prompt_text = f"Create a script for a {video_style.lower()} video for '{business_name}' targeting '{target_audience}'. {video_styles[video_style]}"
32
+
33
  # Call the OpenAI API for text generation
34
  try:
35
+ response = openai.Completion.create(
36
+ engine="text-davinci-003",
37
+ prompt=prompt_text,
38
+ max_tokens=500,
39
+ temperature=0.7,
40
+ top_p=1,
41
+ frequency_penalty=0,
42
+ presence_penalty=0
43
  )
44
+ script = response.choices[0].text.strip()
45
  except Exception as e:
46
+ script = f"Error in generating script: {e}"
47
+
48
+ # Display the generated script
49
+ st.markdown("### Generated Video Script")
50
+ st.write(script)
51
 
52
  # Disclaimer
53
+ st.write("Disclaimer: This tool provides AI-generated suggestions. Please review and customize the script to fit your specific business needs.")