Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,230 +1,7 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
# 월별 기본 컨셉 정의
|
9 |
-
self.monthly_concepts = {
|
10 |
-
1: {"theme": "신년/설날", "colors": ["#FF6B6B", "#FFE66D"], "mood": "희망찬, 따뜻한"},
|
11 |
-
2: {"theme": "발렌타인데이", "colors": ["#FF69B4", "#FFB6C1"], "mood": "로맨틱, 달콤한"},
|
12 |
-
3: {"theme": "화이트데이/봄", "colors": ["#FFFFFF", "#F0F8FF"], "mood": "순수한, 상쾌한"},
|
13 |
-
4: {"theme": "벚꽃/봄나들이", "colors": ["#FFB7C5", "#98FB98"], "mood": "생기발랄, 활기찬"},
|
14 |
-
5: {"theme": "로즈데이/가정의달", "colors": ["#FF1493", "#FF69B4"], "mood": "감사한, 사랑스러운"},
|
15 |
-
6: {"theme": "결혼시즌/초여름", "colors": ["#87CEEB", "#F0E68C"], "mood": "청량한, 행복한"},
|
16 |
-
7: {"theme": "여름휴가", "colors": ["#00CED1", "#FFE4B5"], "mood": "시원한, 자유로운"},
|
17 |
-
8: {"theme": "무더위극복", "colors": ["#20B2AA", "#F0FFFF"], "mood": "시원한, 에너지 넘치는"},
|
18 |
-
9: {"theme": "가을시작", "colors": ["#DEB887", "#CD853F"], "mood": "따뜻한, 아늑한"},
|
19 |
-
10: {"theme": "할로윈", "colors": ["#FF4500", "#8B0000"], "mood": "신비로운, 재미있는"},
|
20 |
-
11: {"theme": "단풍/감사", "colors": ["#DAA520", "#B22222"], "mood": "감사한, 따뜻한"},
|
21 |
-
12: {"theme": "크리스마스/연말", "colors": ["#DC143C", "#228B22"], "mood": "축제같은, 따뜻한"}
|
22 |
-
}
|
23 |
-
|
24 |
-
# 이벤트 타입별 기본 설정
|
25 |
-
self.event_types = {
|
26 |
-
"댓글이벤트": {
|
27 |
-
"action": "댓글 작성",
|
28 |
-
"reward_frequency": "1시간마다",
|
29 |
-
"participation": "유익하고 착한 댓글 남기기"
|
30 |
-
},
|
31 |
-
"채용공고": {
|
32 |
-
"action": "채용공고 확인",
|
33 |
-
"reward_frequency": "일별",
|
34 |
-
"participation": "채용공고 열람 및 지원"
|
35 |
-
},
|
36 |
-
"게시글작성": {
|
37 |
-
"action": "게시글 작성",
|
38 |
-
"reward_frequency": "일별",
|
39 |
-
"participation": "양질의 게시글 작성"
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
def calculate_event_duration(self, start_date: str, end_date: str) -> Tuple[int, int]:
|
44 |
-
"""이벤트 기간 계산"""
|
45 |
-
try:
|
46 |
-
start = datetime.datetime.strptime(start_date, "%Y-%m-%d")
|
47 |
-
end = datetime.datetime.strptime(end_date, "%Y-%m-%d")
|
48 |
-
duration = (end - start).days + 1
|
49 |
-
month = start.month
|
50 |
-
return duration, month
|
51 |
-
except:
|
52 |
-
return 0, 0
|
53 |
-
|
54 |
-
def generate_monthly_concept(self, month: int) -> Dict:
|
55 |
-
"""월별 컨셉 생성"""
|
56 |
-
if month in self.monthly_concepts:
|
57 |
-
concept = self.monthly_concepts[month]
|
58 |
-
return {
|
59 |
-
"theme": concept["theme"],
|
60 |
-
"colors": concept["colors"],
|
61 |
-
"mood": concept["mood"],
|
62 |
-
"month_name": calendar.month_name[month]
|
63 |
-
}
|
64 |
-
return {}
|
65 |
-
|
66 |
-
def generate_event_copy(self, event_type: str, concept: Dict, duration: int,
|
67 |
-
custom_details: str = "") -> str:
|
68 |
-
"""이벤트 카피 생성"""
|
69 |
-
if not concept:
|
70 |
-
return "먼저 이벤트 기간을 설정해주세요."
|
71 |
-
|
72 |
-
theme = concept.get("theme", "특별한")
|
73 |
-
mood = concept.get("mood", "즐거운")
|
74 |
-
|
75 |
-
base_copy = f"""✨ {theme} 특별 이벤트 ✨
|
76 |
-
{mood} {theme} 시즌을 맞아 특별한 이벤트를 준비했어요!
|
77 |
-
|
78 |
-
🎯 이벤트 참여방법
|
79 |
-
{self.event_types.get(event_type, {}).get('participation', '이벤트에 참여하세요')}
|
80 |
-
|
81 |
-
⏰ 이벤트 기간
|
82 |
-
{duration}일간 진행되는 특별한 이벤트입니다!
|
83 |
-
|
84 |
-
🎁 혜택
|
85 |
-
{self.event_types.get(event_type, {}).get('reward_frequency', '정기적으로')} 선물을 드려요!
|
86 |
-
"""
|
87 |
-
|
88 |
-
if custom_details:
|
89 |
-
base_copy += f"\n📝 추가 정보\n{custom_details}"
|
90 |
-
|
91 |
-
return base_copy
|
92 |
-
|
93 |
-
def generate_design_advice(self, concept: Dict) -> str:
|
94 |
-
"""디자인 조언 생성"""
|
95 |
-
if not concept:
|
96 |
-
return "컨셉 정보가 필요합니다."
|
97 |
-
|
98 |
-
colors = concept.get("colors", ["#000000", "#FFFFFF"])
|
99 |
-
mood = concept.get("mood", "")
|
100 |
-
theme = concept.get("theme", "")
|
101 |
-
|
102 |
-
advice = f"""🎨 디자인 조언
|
103 |
-
|
104 |
-
🎯 컬러 팔레트
|
105 |
-
- 메인 컬러: {colors[0]}
|
106 |
-
- 서브 컬러: {colors[1]}
|
107 |
-
- 20-40대 여성에게 어필하는 {mood} 느낌
|
108 |
-
|
109 |
-
📐 레이아웃 추천
|
110 |
-
- 제목: 큰 폰트로 임팩트 있게
|
111 |
-
- 핵심 정보: 시각적으로 구분되는 박스 활용
|
112 |
-
- CTA 버튼: 눈에 띄는 컬러로 강조
|
113 |
-
- 이미지: {theme} 테마에 맞는 일러스트 활용
|
114 |
-
|
115 |
-
👀 가독성 향상
|
116 |
-
- 충분한 여백 활용
|
117 |
-
- 계층적 정보 구조
|
118 |
-
- ��캔하기 쉬운 레이아웃
|
119 |
-
- 모바일 친화적 디자인"""
|
120 |
-
|
121 |
-
return advice
|
122 |
-
|
123 |
-
def create_interface():
|
124 |
-
event_manager = EventManager()
|
125 |
-
|
126 |
-
with gr.Blocks(title="이벤트 관리 시스템", theme=gr.themes.Soft()) as demo:
|
127 |
-
gr.Markdown("# 🎉 이벤트 관리 시스템")
|
128 |
-
gr.Markdown("월별 이벤트 기획부터 디자인 조언까지 한 번에!")
|
129 |
-
|
130 |
-
with gr.Row():
|
131 |
-
with gr.Column(scale=1):
|
132 |
-
gr.Markdown("## 📅 이벤트 기본 정보")
|
133 |
-
|
134 |
-
start_date = gr.Textbox(
|
135 |
-
label="이벤트 시작일",
|
136 |
-
placeholder="YYYY-MM-DD (예: 2025-05-15)",
|
137 |
-
value="2025-05-15"
|
138 |
-
)
|
139 |
-
|
140 |
-
end_date = gr.Textbox(
|
141 |
-
label="이벤트 종료일",
|
142 |
-
placeholder="YYYY-MM-DD (예: 2025-05-25)",
|
143 |
-
value="2025-05-25"
|
144 |
-
)
|
145 |
-
|
146 |
-
event_type = gr.Dropdown(
|
147 |
-
choices=list(event_manager.event_types.keys()),
|
148 |
-
label="이벤트 종류",
|
149 |
-
value="댓글이벤트"
|
150 |
-
)
|
151 |
-
|
152 |
-
custom_details = gr.Textbox(
|
153 |
-
label="추가 상세내용",
|
154 |
-
placeholder="특별한 조건이나 상세 내용을 입력하세요",
|
155 |
-
lines=3
|
156 |
-
)
|
157 |
-
|
158 |
-
generate_btn = gr.Button("✨ 이벤트 생성하기", variant="primary")
|
159 |
-
|
160 |
-
with gr.Column(scale=2):
|
161 |
-
gr.Markdown("## 📊 생성 결과")
|
162 |
-
|
163 |
-
duration_info = gr.Textbox(
|
164 |
-
label="이벤트 기간 정보",
|
165 |
-
interactive=False
|
166 |
-
)
|
167 |
-
|
168 |
-
concept_info = gr.Textbox(
|
169 |
-
label="월별 컨셉 정보",
|
170 |
-
interactive=False,
|
171 |
-
lines=3
|
172 |
-
)
|
173 |
-
|
174 |
-
event_copy = gr.Textbox(
|
175 |
-
label="이벤트 카피",
|
176 |
-
interactive=False,
|
177 |
-
lines=8
|
178 |
-
)
|
179 |
-
|
180 |
-
design_advice = gr.Textbox(
|
181 |
-
label="디자인 조언",
|
182 |
-
interactive=False,
|
183 |
-
lines=10
|
184 |
-
)
|
185 |
-
|
186 |
-
def generate_event_content(start_date_val, end_date_val, event_type_val, custom_details_val):
|
187 |
-
# 기간 계산
|
188 |
-
duration, month = event_manager.calculate_event_duration(start_date_val, end_date_val)
|
189 |
-
|
190 |
-
if duration == 0:
|
191 |
-
return "날짜 형식을 확인해주세요", "", "", ""
|
192 |
-
|
193 |
-
duration_text = f"{duration}일간 ({start_date_val} ~ {end_date_val})"
|
194 |
-
|
195 |
-
# 월별 컨셉 생성
|
196 |
-
concept = event_manager.generate_monthly_concept(month)
|
197 |
-
concept_text = f"테마: {concept.get('theme', '')}\n분위기: {concept.get('mood', '')}\n컬러: {', '.join(concept.get('colors', []))}"
|
198 |
-
|
199 |
-
# 카피 생성
|
200 |
-
copy_text = event_manager.generate_event_copy(event_type_val, concept, duration, custom_details_val)
|
201 |
-
|
202 |
-
# 디자인 조언 생성
|
203 |
-
design_text = event_manager.generate_design_advice(concept)
|
204 |
-
|
205 |
-
return duration_text, concept_text, copy_text, design_text
|
206 |
-
|
207 |
-
generate_btn.click(
|
208 |
-
fn=generate_event_content,
|
209 |
-
inputs=[start_date, end_date, event_type, custom_details],
|
210 |
-
outputs=[duration_info, concept_info, event_copy, design_advice]
|
211 |
-
)
|
212 |
-
|
213 |
-
gr.Markdown("""
|
214 |
-
## 📝 사용 가이드
|
215 |
-
1. **이벤트 기간 설정**: 시작일과 종료일을 YYYY-MM-DD 형식으로 입력
|
216 |
-
2. **이벤트 종류 선택**: 드롭다운에서 이벤트 타입 선택
|
217 |
-
3. **추가 정보 입력**: 특별한 조건이나 상세내용 입력 (선택사항)
|
218 |
-
4. **생성하기 클릭**: 자동으로 컨셉, 카피, 디자인 조언 생성
|
219 |
-
|
220 |
-
### 🎯 다음 단계 개발 예정
|
221 |
-
- 이미지 레퍼런스 분석 기능
|
222 |
-
- 상세한 공지사항 템플릿
|
223 |
-
- 이벤트 종류별 맞춤 설정
|
224 |
-
""")
|
225 |
-
|
226 |
-
return demo
|
227 |
-
|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