aitest / app.py
taeyeol's picture
Update app.py
af4d27d verified
import gradio as gr
# MBTI ์œ ํ˜•๋ณ„ ํ•ด์„
mbti_interpretations = {
"INTJ": "์ „๋žต๊ฐ€: ํ˜์‹ ์ ์ด๊ณ  ๋…๋ฆฝ์ ์ธ ์‚ฌ๊ณ ๋ฅผ ๊ฐ€์ง„ ๋น„์ „์˜ ์ฐฝ์กฐ์ž์ž…๋‹ˆ๋‹ค.",
"INFP": "์ค‘์žฌ์ž: ์ด์ƒ์ ์ด๊ณ  ์ฐฝ์˜์ ์ธ, ํ•ญ์ƒ ์„ ์„ ์ถ”๊ตฌํ•˜๋Š” ์‚ฌ๋žŒ์ž…๋‹ˆ๋‹ค.",
"INFJ": "์˜นํ˜ธ์ž: ์กฐ์šฉํ•˜๊ณ  ์‹ ๋น„๋กœ์šด, ์˜๊ฐ์„ ์ฃผ๋Š” ์ด์ƒ์ฃผ์˜์ž์ž…๋‹ˆ๋‹ค.",
"INTP": "๋…ผ๋ฆฌํ•™์ž: ํ˜์‹ ์ ์ธ ๋ฐœ๋ช…๊ฐ€๋กœ, ๋…์ฐฝ์ ์ธ ์ง€์‹์„ ์ถ”๊ตฌํ•ฉ๋‹ˆ๋‹ค.",
"ENTJ": "ํ†ต์†”์ž: ๋Œ€๋‹ดํ•˜๊ณ  ์ƒ์ƒ๋ ฅ์ด ํ’๋ถ€ํ•˜๋ฉฐ, ํ•ญ์ƒ ๋ชฉํ‘œ๋ฅผ ํ–ฅํ•ด ๋‚˜์•„๊ฐ‘๋‹ˆ๋‹ค.",
"ENFP": "ํ™œ๋™๊ฐ€: ์—ด์ •์ ์ด๊ณ  ์ฐฝ์˜์ ์œผ๋กœ, ์ž์œ ๋กœ์šด ์˜ํ˜ผ์„ ๊ฐ€์ง„ ์‚ฌ๋žŒ์ž…๋‹ˆ๋‹ค.",
"ENFJ": "์„ ๋„์ž: ์นด๋ฆฌ์Šค๋งˆ์™€ ์˜๊ฐ์„ ์ฃผ๋Š” ๋ฆฌ๋”, ํƒ€์ธ์˜ ์„ฑ์žฅ์„ ๋•์Šต๋‹ˆ๋‹ค.",
"ENTP": "๋ณ€๋ก ๊ฐ€: ๋˜‘๋˜‘ํ•˜๊ณ  ํ˜ธ๊ธฐ์‹ฌ์ด ๋งŽ์œผ๋ฉฐ, ์ง€์  ๋„์ „์„ ์ฆ๊น๋‹ˆ๋‹ค.",
"ISFJ": "์ˆ˜ํ˜ธ์ž: ์„ธ์‹ฌํ•˜๊ณ  ํ—Œ์‹ ์ ์ด๋ฉฐ, ๋”ฐ๋œปํ•œ ๋ณดํ˜ธ์ž์ž…๋‹ˆ๋‹ค.",
"ISTJ": "๋…ผ๋ฆฌ์ฃผ์˜์ž: ์‹ค์šฉ์ ์ด๊ณ  ์‚ฌ์‹ค์— ๊ธฐ๋ฐ˜ํ•œ ๊ฒฐ์ •์„ ๋‚ด๋ฆฝ๋‹ˆ๋‹ค.",
"ISFP": "๋ชจํ—˜๊ฐ€: ์œ ์—ฐํ•˜๊ณ  ๋งค๋ ฅ์ ์ด๋ฉฐ, ์ƒˆ๋กœ์šด ๊ฒฝํ—˜์„ ์ฆ๊น๋‹ˆ๋‹ค.",
"ISTP": "์žฅ์ธ: ์‹คํ—˜์„ ์ฆ๊ธฐ๊ณ  ์†์œผ๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ์„ ์ข‹์•„ํ•˜๋Š” ์‚ฌ๋žŒ์ž…๋‹ˆ๋‹ค.",
"ESFJ": "์‚ฌ๊ต์ ์ธ ์™ธ๊ต๊ด€: ํ˜‘๋ ฅ์ ์ด๊ณ  ๋”ฐ๋œปํ•˜๋ฉฐ, ํƒ€์ธ๊ณผ์˜ ์กฐํ™”๋ฅผ ์ค‘์‹œํ•ฉ๋‹ˆ๋‹ค.",
"ESTJ": "๊ฒฝ์˜์ž: ์งˆ์„œ์ •์—ฐํ•˜๊ณ  ์ฑ…์ž„๊ฐ์ด ๊ฐ•ํ•˜๋ฉฐ, ์‚ฌ๋ฌผ์„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ๋Šฅ์ˆ™ํ•ฉ๋‹ˆ๋‹ค.",
"ESFP": "์—ฐ์˜ˆ์ธ: ์‚ฌ๊ต์ ์ด๊ณ  ํ™œ๋™์ ์ด๋ฉฐ, ์ฆ๊ฑฐ์›€์„ ์ถ”๊ตฌํ•˜๋Š” ์‚ฌ๋žŒ์ž…๋‹ˆ๋‹ค.",
"ESTP": "์‚ฌ์—…๊ฐ€: ์—๋„ˆ์ง€๊ฐ€ ๋„˜์น˜๊ณ  ๋Œ€๋‹ดํ•˜๋ฉฐ, ํ–‰๋™์œผ๋กœ ์ƒ๊ฐ์„ ์˜ฎ๊น๋‹ˆ๋‹ค."
}
def calculate_mbti(*args):
# ๋‹จ์ˆœํ™”๋œ MBTI ์œ ํ˜• ๊ณ„์‚ฐ ๋กœ์ง
# args๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ๊ฐ ์งˆ๋ฌธ์— ๋Œ€ํ•ด ์„ ํƒํ•œ ์˜ต์…˜๋“ค์˜ ๋ฆฌ์ŠคํŠธ
# ์—ฌ๊ธฐ์„œ๋Š” ๋‹จ์ˆœํ™”๋ฅผ ์œ„ํ•ด ํ•ญ์ƒ "INTJ"๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์„ค์ •
mbti_type = "INTJ" # ์˜ˆ์‹œ๋กœ INTJ๋ฅผ ์„ ํƒ
# MBTI ์œ ํ˜•๊ณผ ํ•ด์„์„ ๋ฐ˜ํ™˜
interpretation = mbti_interpretations[mbti_type]
detailed_interpretation = f"{mbti_type}: {interpretation}\n\n์ง„๋‹จ ํ…Œ์ŠคํŠธ ๋‚ด์šฉ ์ถ”๊ฐ€:\n{mbti_type} ์œ ํ˜•์€ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ฆฌ๋”์‹ญ์„ ๋ฐœํœ˜ํ•˜๋ฉฐ, ๋ณต์žกํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐ ๋Šฅ์ˆ™ํ•ฉ๋‹ˆ๋‹ค. ๋…๋ฆฝ์ ์ธ ์‚ฌ๊ณ ์™€ ๊ฐ•ํ•œ ์˜์ง€๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, ์ž์‹ ์˜ ๋น„์ „์„ ํ˜„์‹ค๋กœ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ๋Š์ž„์—†์ด ๋…ธ๋ ฅํ•ฉ๋‹ˆ๋‹ค."
return mbti_type, detailed_interpretation
# ์งˆ๋ฌธ ๋ฆฌ์ŠคํŠธ
questions = [
"์ƒˆ๋กœ์šด ์‚ฌ๋žŒ๋“ค์„ ๋งŒ๋‚  ๋•Œ ์ฃผ๋กœ ์–ด๋–ป๊ฒŒ ํ–‰๋™ํ•˜๋‚˜์š”?",
"๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ๋•Œ ์–ด๋–ค ์ ‘๊ทผ ๋ฐฉ์‹์„ ์„ ํ˜ธํ•˜๋‚˜์š”?",
"์—ฌ๊ฐ€ ์‹œ๊ฐ„์„ ์–ด๋–ป๊ฒŒ ๋ณด๋‚ด๋Š” ๊ฒƒ์„ ์„ ํ˜ธํ•˜๋‚˜์š”?",
"์˜์‚ฌ ๊ฒฐ์ •์„ ํ•  ๋•Œ ๋ฌด์—‡์„ ๋” ์ค‘์š”ํ•˜๊ฒŒ ์—ฌ๊ธฐ๋‚˜์š”?",
"ํŒ€ ํ”„๋กœ์ ํŠธ๋ฅผ ํ•  ๋•Œ ์–ด๋–ค ์—ญํ• ์„ ์„ ํ˜ธํ•˜๋‚˜์š”?",
"์ƒˆ๋กœ์šด ์•„์ด๋””์–ด๋‚˜ ํ”„๋กœ์ ํŠธ์— ๋Œ€ํ•ด ์–ด๋–ป๊ฒŒ ๋Š๋ผ๋‚˜์š”?",
"์ŠคํŠธ๋ ˆ์Šค๋ฅผ ๋ฐ›์„ ๋•Œ ์–ด๋–ป๊ฒŒ ๋Œ€์ฒ˜ํ•˜๋‚˜์š”?",
"ํ•™์Šตํ•  ๋•Œ ์–ด๋–ค ๋ฐฉ์‹์„ ์„ ํ˜ธํ•˜๋‚˜์š”?",
"์ผ์ƒ์—์„œ ์–ด๋–ค ๊ฒƒ๋“ค์— ๊ฐ€์žฅ ๊ฐ€์น˜๋ฅผ ๋‘๋‚˜์š”?",
"๋ณ€ํ™”์— ๋Œ€ํ•ด ์–ด๋–ป๊ฒŒ ๋ฐ˜์‘ํ•˜๋‚˜์š”?"
]
# ์˜ต์…˜์„ MBTI ์„ฑํ–ฅ์— ๋งž๊ฒŒ ์ˆ˜์ •
options = {
"E/I": ["์™ธํ–ฅ์ (E)", "๋‚ดํ–ฅ์ (I)"],
"S/N": ["๊ฐ๊ฐ์ (S)", "์ง๊ด€์ (N)"],
"T/F": ["์‚ฌ๊ณ ์ (T)", "๊ฐ์ •์ (F)"],
"J/P": ["ํŒ๋‹จ์ (J)", "์ธ์‹์ (P)"]
}
# Gradio ์•ฑ ์ •์˜
with gr.Blocks() as app:
gr.Markdown("# MBTI ์ง„๋‹จ ํ…Œ์ŠคํŠธ")
with gr.Row():
# ๊ฐ ์งˆ๋ฌธ์— ๋Œ€ํ•ด MBTI ์„ฑํ–ฅ์— ๋งž๋Š” ์˜ต์…˜์„ ์ œ๊ณต
answers = [gr.Radio(options[key], label=question) for key, question in zip(options.keys(), questions)]
submit_button = gr.Button("๊ฒฐ๊ณผ ๋ณด๊ธฐ")
output_mbti, output_interpretation = gr.Textbox(label="๋‹น์‹ ์˜ MBTI ์œ ํ˜•"), gr.Textbox(label="์œ ํ˜• ํ•ด์„ ๋ฐ ์ง„๋‹จ ํ…Œ์ŠคํŠธ ๋‚ด์šฉ", lines=10)
submit_button.click(fn=calculate_mbti, inputs=answers, outputs=[output_mbti, output_interpretation])
if __name__ == "__main__":
app.launch()