bizvideoschool
commited on
Commit
•
c1fbddd
1
Parent(s):
8d9d64c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import streamlit as st
|
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 homeowners create a personalized selling plan for their home. You'll receive information about their timeline, budget, and any known tasks they need to complete. Generate a detailed plan that includes a timeline for tasks like repairs, staging, listing, and open houses. Provide advice on how to prioritize tasks based on their budget and timeline."""}]
|
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("Personalized Selling Plan Generator")
|
24 |
+
st.write("This tool generates a personalized selling plan for your home. Enter your selling timeline (in months), your budget for home preparations, and any tasks you already know you need to complete. The AI assistant will provide a detailed plan that includes a timeline for tasks like repairs, staging, listing, and open houses, and advice on how to prioritize tasks based on your budget and timeline.")
|
25 |
+
|
26 |
+
selling_timeline = st.text_input("Selling Timeline", "Enter the number of months until you plan to sell your home.")
|
27 |
+
budget = st.text_input("Budget for Preparations", "Enter the amount of money you have available for home preparations.")
|
28 |
+
known_tasks = st.text_input("Known Tasks to Complete", "Enter any tasks you already know you need to complete before selling.")
|
29 |
+
submit_button = st.button('Generate Plan')
|
30 |
+
|
31 |
+
if submit_button:
|
32 |
+
messages = initial_messages.copy()
|
33 |
+
user_input = f"I plan to sell my home in {selling_timeline}. My budget for preparing the home for sale is {budget}. The tasks I know I need to complete are: {known_tasks}."
|
34 |
+
reply, _ = CustomChatGPT(user_input, messages)
|
35 |
+
st.write(reply)
|