import streamlit as st import openai # Set up the OpenAI API key from Hugging Face Spaces secrets openai.api_key = st.secrets["OPENAI_API_KEY"] st.title("Customer Avatar Generator") # User inputs for generating the customer avatar business_type = st.text_input("Business Type", "Enter the type of your business (e.g., Real Estate, E-commerce)") target_market = st.text_input("Target Market", "Describe your target market (e.g., first-time home buyers, fitness enthusiasts)") unique_selling_points = st.text_area("Unique Selling Points", "What sets your business apart from competitors? (e.g., personalized service, affordable pricing)") customer_challenges = st.text_area("Customer Challenges", "What challenges do your customers face that your business solves? (e.g., finding affordable housing, achieving fitness goals)") submit_button = st.button("Generate Customer Avatar") if submit_button: # Construct the prompt for the AI prompt = f""" Generate a detailed customer avatar for a business. Business Type: {business_type} Target Market: {target_market} Unique Selling Points: {unique_selling_points} Customer Challenges: {customer_challenges} """ # Call the OpenAI API try: response = openai.Completion.create( model="gpt-4", # Specify GPT-4 model prompt=prompt, max_tokens=500, # Adjust based on the required length of the avatar ) avatar = response.choices[0].text.strip() # Display the customer avatar st.subheader("Generated Customer Avatar") st.write(avatar) except Exception as e: st.error(f"An error occurred: {e}")