import streamlit as st import openai # Access the OpenAI API key from Hugging Face Spaces secrets openai.api_key = st.secrets["OPENAI_API_KEY"] st.title("Holiday Video Script Generator for Realtors") # User inputs agent_name = st.text_input("Your Name", placeholder="Enter your name") community_focus = st.text_input("Community Focus", placeholder="Enter the community or area you focus on") holiday_theme = st.selectbox("Holiday Theme", ["Christmas", "Hanukkah", "New Year's", "General Holiday Season"]) personal_message = st.text_area("Personal Message", placeholder="Enter any personal message or story you want to include") if st.button('Generate Script'): # Formulate the user input for the script user_input = ( f"""You are an AI assistant that helps real estate agents create compelling holiday video scripts. The script should be festive, engaging, and approximately one minute long. Include elements like community engagement, local highlights, market insights, home decoration tips, and a personalized message. The agent's name is {agent_name}. They focus on the {community_focus} community. The holiday theme is {holiday_theme}. They want to include the following personal message: {personal_message}. """ ) # Call the OpenAI API with the chat model response = openai.ChatCompletion.create( model="gpt-4", # Use the appropriate GPT-4 model messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": user_input} ] ) # Display the response from the API st.write(response.choices[0].message['content'])