bizvideoschool's picture
Create app.py
c1fbddd
raw
history blame
No virus
2.22 kB
import openai
import streamlit as st
import os
# Ensure your OpenAI API key is set in your environment variables
openai.api_key = os.environ["OPENAI_API_KEY"]
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."""}]
def call_openai_api(messages):
return openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages
)
def CustomChatGPT(user_input, messages):
messages.append({"role": "user", "content": user_input})
response = call_openai_api(messages)
ChatGPT_reply = response["choices"][0]["message"]["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply, messages
st.title("Personalized Selling Plan Generator")
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.")
selling_timeline = st.text_input("Selling Timeline", "Enter the number of months until you plan to sell your home.")
budget = st.text_input("Budget for Preparations", "Enter the amount of money you have available for home preparations.")
known_tasks = st.text_input("Known Tasks to Complete", "Enter any tasks you already know you need to complete before selling.")
submit_button = st.button('Generate Plan')
if submit_button:
messages = initial_messages.copy()
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}."
reply, _ = CustomChatGPT(user_input, messages)
st.write(reply)