Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,59 +1,33 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
| 3 |
-
import
|
| 4 |
-
from PIL import Image
|
| 5 |
-
from io import BytesIO
|
| 6 |
|
| 7 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
| 8 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 9 |
|
| 10 |
-
st.title("
|
| 11 |
|
| 12 |
-
# User inputs for the
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
# Function to generate the
|
| 19 |
-
def
|
| 20 |
-
prompt = f"
|
| 21 |
response = openai.ChatCompletion.create(
|
| 22 |
model="gpt-4",
|
| 23 |
messages=[
|
| 24 |
-
{"role": "system", "content": "You are a
|
| 25 |
{"role": "user", "content": prompt}
|
| 26 |
],
|
| 27 |
-
max_tokens=
|
| 28 |
)
|
| 29 |
return response.choices[0].message['content']
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
response = openai.Image.create(
|
| 36 |
-
prompt=prompt,
|
| 37 |
-
n=1,
|
| 38 |
-
size="1024x1024", # Adjust the size if needed
|
| 39 |
-
model="dall-e-3" # Specify DALL-E 3 model
|
| 40 |
-
)
|
| 41 |
-
image_url = response['data'][0]['url']
|
| 42 |
-
image_response = requests.get(image_url)
|
| 43 |
-
image = Image.open(BytesIO(image_response.content))
|
| 44 |
-
return image
|
| 45 |
-
except Exception as e:
|
| 46 |
-
st.error(f"Error in generating image: {e}")
|
| 47 |
-
return None
|
| 48 |
-
|
| 49 |
-
if st.button('Generate Story and Images'):
|
| 50 |
-
story = generate_story(age_group, theme, main_character, details)
|
| 51 |
-
story_parts = story.split('.')[:10] # Use the first 10 sentences for panels
|
| 52 |
-
|
| 53 |
-
for i, part in enumerate(story_parts):
|
| 54 |
-
if part.strip(): # Ensure part is not empty
|
| 55 |
-
st.subheader(f'Panel {i+1}')
|
| 56 |
-
st.write(part.strip())
|
| 57 |
-
image = generate_image(part, main_character)
|
| 58 |
-
if image:
|
| 59 |
-
st.image(image, caption=f'Image for Panel {i+1}')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
| 3 |
+
import os
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
| 6 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 7 |
|
| 8 |
+
st.title("2024 Lead Generation Plan Creator for Small Businesses")
|
| 9 |
|
| 10 |
+
# User inputs for creating the lead generation plan
|
| 11 |
+
st.subheader("Tell Us About Your Business")
|
| 12 |
+
business_description = st.text_area("Business Description", placeholder="Describe your business (e.g., nature, services/products, size).")
|
| 13 |
+
target_customers = st.text_area("Target Customers", placeholder="Describe your ideal customers (e.g., demographics, interests, locations).")
|
| 14 |
+
advertising_budget = st.selectbox("Advertising Budget", ["No budget", "Limited budget", "Moderate budget", "Large budget"])
|
| 15 |
+
additional_details = st.text_area("Additional Details", placeholder="Any specific goals or strategies you've considered?")
|
| 16 |
|
| 17 |
+
# Function to generate the lead generation plan
|
| 18 |
+
def generate_lead_generation_plan(business_description, target_customers, advertising_budget, additional_details):
|
| 19 |
+
prompt = f"Create a detailed lead generation plan for 2024 for a business described as follows: {business_description}. The target customers are: {target_customers}. The advertising budget is: {advertising_budget}. Additional details: {additional_details}. Include step-by-step instructions and strategies for implementing lead generation systems."
|
| 20 |
response = openai.ChatCompletion.create(
|
| 21 |
model="gpt-4",
|
| 22 |
messages=[
|
| 23 |
+
{"role": "system", "content": "You are a marketing expert."},
|
| 24 |
{"role": "user", "content": prompt}
|
| 25 |
],
|
| 26 |
+
max_tokens=500 # Adjust the token limit as needed
|
| 27 |
)
|
| 28 |
return response.choices[0].message['content']
|
| 29 |
|
| 30 |
+
if st.button('Generate Lead Generation Plan'):
|
| 31 |
+
plan = generate_lead_generation_plan(business_description, target_customers, advertising_budget, additional_details)
|
| 32 |
+
st.subheader("Your Customized Lead Generation Plan for 2024:")
|
| 33 |
+
st.write(plan)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|