Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,4 @@
|
|
1 |
-
|
2 |
-
"""이벤트 기간 변경시 월 자동 인식"""
|
3 |
-
detected_month = extract_month_from_period(period_text)
|
4 |
-
if detected_month:
|
5 |
-
return gr.update(value=detected_month)
|
6 |
-
return gr.update()
|
7 |
-
|
8 |
-
def hanimport gradio as gr
|
9 |
from datetime import datetime
|
10 |
import re
|
11 |
|
@@ -265,7 +258,7 @@ def analyze_concepts(month):
|
|
265 |
|
266 |
return result, concept_names
|
267 |
|
268 |
-
def generate_notice(concept, event_type, event_period):
|
269 |
"""기본 공지사항 생성"""
|
270 |
|
271 |
if not concept:
|
@@ -280,6 +273,16 @@ def generate_notice(concept, event_type, event_period):
|
|
280 |
else:
|
281 |
period_text = event_period
|
282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
notice = f"""💕 {concept}에 참여하세요!
|
284 |
|
285 |
🎉 {concept} 🎉
|
@@ -299,9 +302,7 @@ def generate_notice(concept, event_type, event_period):
|
|
299 |
|
300 |
=================
|
301 |
🎁 당첨혜택
|
302 |
-
|
303 |
-
🎉 2등 (3명): 베스킨라빈스 쿠폰
|
304 |
-
💝 3등 (10명): 편의점 5천원 상품권
|
305 |
|
306 |
📋 추첨: 참여자 중 무작위 추첨
|
307 |
========================
|
@@ -363,6 +364,19 @@ def create_interface():
|
|
363 |
value="댓글 달기"
|
364 |
)
|
365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
generate_btn = gr.Button("공지사항 생성하기", variant="secondary", visible=False)
|
367 |
|
368 |
with gr.Column():
|
@@ -384,6 +398,13 @@ def create_interface():
|
|
384 |
concepts_state = gr.State([])
|
385 |
selected_concept_state = gr.State("")
|
386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
def handle_analyze(month):
|
388 |
"""분석 처리"""
|
389 |
result, concepts = analyze_concepts(month)
|
@@ -398,12 +419,18 @@ def create_interface():
|
|
398 |
"""컨셉 변경 처리"""
|
399 |
return concept
|
400 |
|
401 |
-
def handle_generate(concept, event_type, event_period):
|
402 |
"""생성 처리"""
|
403 |
-
notice = generate_notice(concept, event_type, event_period)
|
404 |
return notice
|
405 |
|
406 |
# 이벤트 연결
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
analyze_btn.click(
|
408 |
handle_analyze,
|
409 |
inputs=[month_dropdown],
|
@@ -418,7 +445,7 @@ def create_interface():
|
|
418 |
|
419 |
generate_btn.click(
|
420 |
handle_generate,
|
421 |
-
inputs=[selected_concept_state, event_type_dropdown, event_period_input],
|
422 |
outputs=[notice_output]
|
423 |
)
|
424 |
|
|
|
1 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from datetime import datetime
|
3 |
import re
|
4 |
|
|
|
258 |
|
259 |
return result, concept_names
|
260 |
|
261 |
+
def generate_notice(concept, event_type, event_period, prize_benefits):
|
262 |
"""기본 공지사항 생성"""
|
263 |
|
264 |
if not concept:
|
|
|
273 |
else:
|
274 |
period_text = event_period
|
275 |
|
276 |
+
# 당첨 혜택이 입력되지 않았으면 기본값 사용
|
277 |
+
if not prize_benefits or prize_benefits.strip() == "":
|
278 |
+
default_benefits = """✨ 1등 (1명): 스타벅스 5만원 기프트카드
|
279 |
+
🎉 2등 (3명): 베스킨라빈스 아이스크림 쿠폰
|
280 |
+
💝 3등 (10명): 편의점 5천원 상품권
|
281 |
+
🌟 참가상 (50명): 모바일 치킨 쿠폰"""
|
282 |
+
benefits_text = default_benefits
|
283 |
+
else:
|
284 |
+
benefits_text = prize_benefits
|
285 |
+
|
286 |
notice = f"""💕 {concept}에 참여하세요!
|
287 |
|
288 |
🎉 {concept} 🎉
|
|
|
302 |
|
303 |
=================
|
304 |
🎁 당첨혜택
|
305 |
+
{benefits_text}
|
|
|
|
|
306 |
|
307 |
📋 추첨: 참여자 중 무작위 추첨
|
308 |
========================
|
|
|
364 |
value="댓글 달기"
|
365 |
)
|
366 |
|
367 |
+
gr.Markdown("## 🎁 당첨 혜택 설정")
|
368 |
+
|
369 |
+
prize_benefits_input = gr.Textbox(
|
370 |
+
label="당첨 혜택",
|
371 |
+
placeholder="""예시:
|
372 |
+
✨ 1등 (1명): 아이폰 15 Pro
|
373 |
+
🎉 2등 (3명): 에어팟 프로
|
374 |
+
💝 3등 (10명): 스타벅스 1만원 기프트카드
|
375 |
+
🌟 참가상 (50명): 카페 아메리카노 쿠폰""",
|
376 |
+
lines=6,
|
377 |
+
info="당첨 혜택을 입력하지 않으면 기본 혜택이 적용됩니다"
|
378 |
+
)
|
379 |
+
|
380 |
generate_btn = gr.Button("공지사항 생성하기", variant="secondary", visible=False)
|
381 |
|
382 |
with gr.Column():
|
|
|
398 |
concepts_state = gr.State([])
|
399 |
selected_concept_state = gr.State("")
|
400 |
|
401 |
+
def handle_period_change(period_text):
|
402 |
+
"""이벤트 기간 변경시 월 자동 인식"""
|
403 |
+
detected_month = extract_month_from_period(period_text)
|
404 |
+
if detected_month:
|
405 |
+
return gr.update(value=detected_month)
|
406 |
+
return gr.update()
|
407 |
+
|
408 |
def handle_analyze(month):
|
409 |
"""분석 처리"""
|
410 |
result, concepts = analyze_concepts(month)
|
|
|
419 |
"""컨셉 변경 처리"""
|
420 |
return concept
|
421 |
|
422 |
+
def handle_generate(concept, event_type, event_period, prize_benefits):
|
423 |
"""생성 처리"""
|
424 |
+
notice = generate_notice(concept, event_type, event_period, prize_benefits)
|
425 |
return notice
|
426 |
|
427 |
# 이벤트 연결
|
428 |
+
event_period_input.change(
|
429 |
+
handle_period_change,
|
430 |
+
inputs=[event_period_input],
|
431 |
+
outputs=[month_dropdown]
|
432 |
+
)
|
433 |
+
|
434 |
analyze_btn.click(
|
435 |
handle_analyze,
|
436 |
inputs=[month_dropdown],
|
|
|
445 |
|
446 |
generate_btn.click(
|
447 |
handle_generate,
|
448 |
+
inputs=[selected_concept_state, event_type_dropdown, event_period_input, prize_benefits_input],
|
449 |
outputs=[notice_output]
|
450 |
)
|
451 |
|