TDN-M commited on
Commit
df847b0
·
verified ·
1 Parent(s): 1befe26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +155 -53
app.py CHANGED
@@ -1,54 +1,156 @@
1
  import streamlit as st
2
- import openai
3
-
4
- # Access the OpenAI API key from Hugging Face Spaces secrets
5
- openai.api_key = st.secrets["OPENAI_API_KEY"]
6
-
7
- st.title("2025 Video Content Calendar Generator")
8
-
9
- # User inputs for the marketing plan
10
- st.subheader("Define Your Business and Audience")
11
- business_type = st.text_input("Your Business Type", placeholder="e.g., Cafe, Yoga Studio")
12
- target_audience = st.text_area("Describe Your Target Audience", placeholder="e.g., demographics, interests")
13
-
14
- st.subheader("Current Marketing Efforts")
15
- current_marketing = st.text_area("Current Marketing Strategies", placeholder="Describe your ongoing marketing activities.")
16
-
17
- if st.button('Generate My Custom 2025 Video Content Plan'):
18
- # Construct the prompt for text generation
19
- prompt_text = f"""
20
- Generate a 2025 video marketing plan for a {business_type} targeting an audience characterized as: {target_audience}.
21
- Include up to four video ideas for each month of 2025 with a short description of each, ensuring a full plan for all 12 months, try to incorporate current
22
- marketing efforts when it makes sense to do so: {current_marketing}.
23
- """
24
-
25
- # Call the OpenAI API for text generation
26
- try:
27
- response_text = openai.ChatCompletion.create(
28
- model="gpt-4",
29
- messages=[
30
- {"role": "system", "content": """
31
- You are an AI specializing in marketing strategy. You are specialized in creating a diverse range of video topic ideas for businesses.
32
- Your ideas are a creative blend of topics that focus on the interests or pain points of the client. They are often community oriented
33
- but 1 in 4 ideas is promotional in nature and focuses on helping the business attract customers.
34
- """},
35
- {"role": "user", "content": prompt_text}
36
- ]
37
- )
38
- marketing_plan = response_text.choices[0].message['content']
39
- except Exception as e:
40
- marketing_plan = f"Error in generating marketing plan: {e}"
41
-
42
- # Display the marketing plan
43
- st.markdown("### Your Customized Video Marketing Plan")
44
- st.write(marketing_plan)
45
-
46
- # Suggestion to enroll in Business Video School
47
- st.markdown("### Take Your Video Marketing to the Next Level!")
48
- st.write("""
49
- To successfully execute your new video marketing plan, consider enrolling in Business Video School.
50
- Our One Day Challenge and Video Workspaces are designed to keep you accountable and help you stay on track with your plan.
51
- Join now to transform your video marketing strategy!
52
- """)
53
-
54
- # No additional code needed beyond this point for your application
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from groq import Groq
3
+ import time
4
+
5
+ # Thiết lập trang
6
+ st.set_page_config(
7
+ page_title="Lập Lịch Video Laya Green 2025",
8
+ page_icon="💄",
9
+ layout="wide"
10
+ )
11
+
12
+ # CSS tùy chỉnh
13
+ st.markdown("""
14
+ <style>
15
+ .stTextInput input, .stTextArea textarea {
16
+ border-radius: 10px !important;
17
+ padding: 10px !important;
18
+ }
19
+ .stButton button {
20
+ width: 100%;
21
+ border-radius: 10px;
22
+ padding: 10px;
23
+ background-color: #6a8d73;
24
+ color: white;
25
+ font-weight: bold;
26
+ }
27
+ .stButton button:hover {
28
+ background-color: #5a7c63;
29
+ }
30
+ .stMarkdown h1, .stMarkdown h2, .stMarkdown h3 {
31
+ color: #6a8d73;
32
+ }
33
+ </style>
34
+ """, unsafe_allow_html=True)
35
+
36
+ # Khởi tạo Groq client
37
+ client = Groq(api_key=st.secrets["GROQ_API_KEY"])
38
+
39
+ # Tiêu đề ứng dụng với branding Laya Green
40
+ st.image("https://via.placeholder.com/1200x200/6a8d73/FFFFFF?text=Laya+Green+Video+Planner", use_column_width=True)
41
+ st.title("📅 Lập Lịch Video Content 2025")
42
+ st.markdown(f"""
43
+ <div style="background-color:#f0f7f4;padding:15px;border-radius:10px;margin-bottom:20px">
44
+ <h4 style="color:#6a8d73">Công cụ thiết kế lịch đăng video dành riêng cho thương hiệu mỹ phẩm thiên nhiên Laya Green</h4>
45
+ </div>
46
+ """, unsafe_allow_html=True)
47
+
48
+ # Phần nhập thông tin (tối giản vì đã cố định sản phẩm)
49
+ with st.expander("🔍 THÔNG TIN THƯƠNG HIỆU", expanded=True):
50
+ target_audience = st.text_area(
51
+ "Mô tả khách hàng mục tiêu của Laya Green",
52
+ placeholder="Ví dụ: Nữ 20-35 tuổi, quan tâm skincare thiên nhiên, thích làm đẹp an toàn...",
53
+ height=100,
54
+ help="Càng chi tiết càng giúp tạo nội dung phù hợp"
55
+ )
56
+
57
+ # Phần chiến lược hiện tại
58
+ with st.expander("📈 HOẠT ĐỘNG MARKETING HIỆN TẠI"):
59
+ current_marketing = st.text_area(
60
+ "Các hoạt động truyền thông đang triển khai",
61
+ placeholder="Ví dụ: Đang chạy quảng cáo Tiktok về serum, có group cộng đồng về làm đẹp tự nhiên...",
62
+ height=120
63
+ )
64
+
65
+ # Danh sách sản phẩm Laya Green (cố định)
66
+ products = [
67
+ "Serum trị mụn Organic",
68
+ "Kem dưỡng trắng da Chiết xuất Sakura",
69
+ "Tẩy trang dầu Argan",
70
+ "Mặt nạ ngủ Collagen",
71
+ "Son dưỡng môi màu Natural",
72
+ "Bộ chăm sóc da mùa đông"
73
+ ]
74
+
75
+ # Nút tạo kế hoạch
76
+ if st.button('✨ TẠO LỊCH VIDEO 2025', type="primary"):
77
+ if not target_audience:
78
+ st.warning("Vui lòng nhập thông tin khách hàng mục tiêu")
79
+ st.stop()
80
+
81
+ with st.spinner("Đang tạo lịch video tối ưu cho Laya Green..."):
82
+ progress_bar = st.progress(0)
83
+
84
+ # Tạo prompt chuyên biệt cho mỹ phẩm
85
+ prompt_text = f"""
86
+ Hãy tạo lịch đăng video marketing năm 2025 cho thương hiệu mỹ phẩm thiên nhiên Laya Green với các sản phẩm: {', '.join(products)}.
87
+
88
+ Khách hàng mục tiêu: {target_audience}
89
+
90
+ Yêu cầu chi tiết:
91
+ 1. Định dạng bằng tiếng Việt
92
+ 2. 12 tháng, mỗi tháng 4 video
93
+ 3. Mỗi video cần có:
94
+ - Tiêu đề hấp dẫn
95
+ - Concept rõ ràng
96
+ - Sản phẩm liên quan
97
+ - Gợi ý format (tutorial, review, before-after,...)
98
+ 4. Kết hợp các hoạt động hiện tại: {current_marketing}
99
+ 5. Tỷ lệ nội dung:
100
+ - 50% giáo dục (hướng dẫn skincare, kiến thức thành phần)
101
+ - 30% showcase sản phẩm
102
+ - 20% user-generated content
103
+ 6. Có các chủ đề theo mùa (Tết, Valentine, 8/3,...)
104
+ 7. Ưu tiên xu hướng làm đẹp 2025
105
+ """
106
+
107
+ # Gọi API Groq
108
+ try:
109
+ for i in range(10):
110
+ progress_bar.progress((i + 1) * 10)
111
+ time.sleep(0.1)
112
+
113
+ chat_completion = client.chat.completions.create(
114
+ messages=[
115
+ {
116
+ "role": "system",
117
+ "content": """
118
+ Bạn là chuyên gia content cho thương hiệu mỹ phẩm cao cấp.
119
+ Bạn rất am hiểu về skincare routine, thành phần mỹ phẩm organic,
120
+ và các xu hướng làm đẹp năm 2025. Hãy tạo content sáng tạo,
121
+ tự nhiên và thể hiện được tinh thần xanh của Laya Green.
122
+ """
123
+ },
124
+ {
125
+ "role": "user",
126
+ "content": prompt_text
127
+ }
128
+ ],
129
+ model="mixtral-8x7b-32768",
130
+ temperature=0.7,
131
+ max_tokens=4000
132
+ )
133
+
134
+ marketing_plan = chat_completion.choices[0].message.content
135
+
136
+ # Hiển thị kết quả
137
+ st.success("✅ Lịch video đã sẵn sàng!")
138
+ st.balloons()
139
+
140
+ with st.expander("📅 LỊCH VIDEO LAYA GREEN 2025", expanded=True):
141
+ st.markdown(marketing_plan)
142
+
143
+ # Tải về file
144
+ st.download_button(
145
+ label="💾 Tải về bản đầy đủ",
146
+ data=marketing_plan,
147
+ file_name="Lich_video_Laya_Green_2025.txt",
148
+ mime="text/plain"
149
+ )
150
+
151
+ except Exception as e:
152
+ st.error(f"Có lỗi xảy ra: {str(e)}")
153
+
154
+ # Footer
155
+ st.markdown("---")
156
+ st.markdown("<div style='text-align: center; color: #6a8d73'>© 2024 Laya Green - Mỹ phẩm thiên nhiên cao cấp</div>", unsafe_allow_html=True)