bizvideoschool commited on
Commit
bf70abc
1 Parent(s): 75ef369

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -35
app.py CHANGED
@@ -1,38 +1,25 @@
1
- import streamlit as st
2
  import openai
3
- import os
4
 
5
- # Ensure your OpenAI API key is set in your environment variables
6
- openai.api_key = os.environ["OPENAI_API_KEY"]
7
-
8
- initial_messages = [{"role": "system", "content": """You are an AI assistant that helps users find the perfect engagement ring for their fiance. You'll gather information about their budget, metal preference, carat size, job of the fiance, and whether they prefer a simple or elaborate design. Provide recommendations for engagement rings that match these criteria."""}]
9
-
10
- def call_openai_api(messages):
11
- return openai.ChatCompletion.create(
12
- model="gpt-3.5-turbo",
13
- messages=messages
 
 
 
 
 
 
 
 
 
 
 
14
  )
15
-
16
- def CustomChatGPT(user_input, messages):
17
- messages.append({"role": "user", "content": user_input})
18
- response = call_openai_api(messages)
19
- ChatGPT_reply = response["choices"][0]["message"]["content"]
20
- messages.append({"role": "assistant", "content": ChatGPT_reply})
21
- return ChatGPT_reply, messages
22
-
23
- st.title("Engagement Ring Finder")
24
- st.write("This tool helps you find the perfect engagement ring for your fiance. Enter your budget, preferred metal, desired carat size, the job of your fiance, and whether you're looking for something simple or elaborate.")
25
-
26
- budget = st.text_input("Budget", placeholder="Enter your budget for the ring.")
27
- metal_preference = st.text_input("Metal Preference", placeholder="Enter your preferred metal (e.g., gold, platinum).")
28
- carat_size = st.text_input("Carat Size", placeholder="Enter the desired carat size.")
29
- fiance_job = st.text_input("Fiance's Job", placeholder="Enter your fiance's job (e.g., teacher, engineer).")
30
- design_preference = st.selectbox("Design Preference", ["Simple", "Elaborate"])
31
-
32
- submit_button = st.button('Find Rings')
33
-
34
- if submit_button:
35
- messages = initial_messages.copy()
36
- user_input = f"My budget for the engagement ring is {budget}. I prefer {metal_preference} as the metal. I am looking for a ring with a carat size of {carat_size}. My fiance's job is {fiance_job} and I'm looking for a {design_preference.lower()} design."
37
- reply, _ = CustomChatGPT(user_input, messages)
38
- st.write(reply)
 
1
+ import streamlit as st
2
  import openai
 
3
 
4
+ # OpenAI API Key Setup
5
+ openai.api_key = st.secrets["OPENAI_API_KEY"]
6
+
7
+ st.title("Holiday Video Script Generator for Real Estate Agents")
8
+
9
+ # Collecting User Inputs
10
+ agent_name = st.text_input("Your Name")
11
+ agency_name = st.text_input("Your Agency")
12
+ target_audience = st.text_input("Target Audience")
13
+ video_type = st.selectbox("Type of Video", ["Community Engagement", "Personalized Messages", "Local Highlights", "Market Insights", "Year in Review", "Home Decoration/Staging Tips"])
14
+ personal_anecdotes = st.text_area("Personal Anecdotes/Success Stories")
15
+ local_features = st.text_area("Local Community Features")
16
+ market_statistics = st.text_area("Real Estate Market Statistics")
17
+
18
+ if st.button('Generate Script'):
19
+ user_input = f"Generate a one-minute holiday video script for a real estate agent. Agent's Name: {agent_name}. Agency: {agency_name}. Target Audience: {target_audience}. Video Type: {video_type}. Include: {personal_anecdotes}, {local_features}, {market_statistics}."
20
+ response = openai.Completion.create(
21
+ model="gpt-4",
22
+ prompt=user_input,
23
+ max_tokens=500
24
  )
25
+ st.write(response.choices[0].text)