| | import os |
| | import streamlit as st |
| | import google.generativeai as genai |
| | import random |
| |
|
| | |
| | st.set_page_config( |
| | page_title="SDGs ์ ์ฑ
๊ฒฐ์ ๊ฒ์", |
| | page_icon="๐", |
| | layout="wide", |
| | initial_sidebar_state="expanded", |
| | ) |
| |
|
| | |
| | st.markdown( |
| | """ |
| | <style> |
| | /* ์ ์ฒด ํฐํธ */ |
| | body { |
| | font-family: 'Nanum Gothic', sans-serif !important; |
| | } |
| | /* ๋ฒํผ */ |
| | div.stButton > button { |
| | background-color: #007bff; |
| | color: white; |
| | } |
| | </style> |
| | """, |
| | unsafe_allow_html=True, |
| | ) |
| |
|
| | |
| | if "GEMINI_API_KEY" not in os.environ: |
| | st.error( |
| | "GEMINI_API_KEY ํ๊ฒฝ ๋ณ์๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. Hugging Face Secrets ๋๋ ํ๊ฒฝ ๋ณ์์ API ํค๋ฅผ ์ค์ ํด์ฃผ์ธ์." |
| | ) |
| | st.stop() |
| |
|
| | genai.configure(api_key=os.environ["GEMINI_API_KEY"]) |
| |
|
| | |
| | generation_config = { |
| | "temperature": 1.0, |
| | "top_p": 0.95, |
| | "top_k": 64, |
| | "max_output_tokens": 5000, |
| | } |
| | model = genai.GenerativeModel( |
| | model_name="gemini-2.0-flash-exp", |
| | generation_config=generation_config, |
| | ) |
| |
|
| | |
| | if "sdgs_chat_session" not in st.session_state: |
| | st.session_state["sdgs_chat_session"] = model.start_chat(history=[]) |
| | if "current_sdg_scenario" not in st.session_state: |
| | st.session_state["current_sdg_scenario"] = None |
| | if "policy_options" not in st.session_state: |
| | st.session_state["policy_options"] = None |
| | if "policy_result" not in st.session_state: |
| | st.session_state["policy_result"] = None |
| | if "selected_sdg" not in st.session_state: |
| | st.session_state["selected_sdg"] = None |
| | if "user_policy_option" not in st.session_state: |
| | st.session_state["user_policy_option"] = "" |
| | if "points" not in st.session_state: |
| | st.session_state["points"] = 0 |
| | if "level" not in st.session_state: |
| | st.session_state["level"] = 1 |
| |
|
| |
|
| | |
| | sdg_goals = { |
| | "SDG 1": "๋น๊ณค ํด์น", |
| | "SDG 2": "๊ธฐ์ ์ข
์", |
| | "SDG 3": "๊ฑด๊ฐ๊ณผ ์ฐ๋น", |
| | "SDG 4": "์์ง์ ๊ต์ก", |
| | "SDG 5": "์ฑํ๋ฑ", |
| | "SDG 6": "๊นจ๋ํ ๋ฌผ๊ณผ ์์", |
| | "SDG 7": "๊นจ๋ํ ์๋์ง", |
| | "SDG 8": "์์ง์ ์ผ์๋ฆฌ์ ๊ฒฝ์ ์ฑ์ฅ", |
| | "SDG 9": "์ฐ์
, ํ์ , ์ฌํ ๊ธฐ๋ฐ ์์ค", |
| | "SDG 10": "๋ถํ๋ฑ ์ํ", |
| | "SDG 11": "์ง์๊ฐ๋ฅํ ๋์์ ๊ณต๋์ฒด", |
| | "SDG 12": "์ง์๊ฐ๋ฅํ ์๋น, ์์ฐ", |
| | "SDG 13": "๊ธฐํ ๋ณํ ๋์", |
| | "SDG 14": "ํด์ ์ํ๊ณ ๋ณด์ ", |
| | "SDG 15": "์ก์ ์ํ๊ณ ๋ณด์ ", |
| | "SDG 16": "ํํ, ์ ์, ์ ๋", |
| | "SDG 17": "ํํธ๋์ญ", |
| | } |
| |
|
| | sdg_descriptions = { |
| | "SDG 1": "๋ชจ๋ ๊ณณ์์, ๋ชจ๋ ํํ์ ๋น๊ณค์ ๋๋ด๋ ๊ฒ", |
| | "SDG 2": "๊ธฐ์๋ฅผ ์์ ๊ณ , ์๋ ์๋ณด๋ฅผ ์ด๋ฃจ๋ฉฐ, ์์ ์ํ๋ฅผ ๊ฐ์ ํ๊ณ , ์ง์๊ฐ๋ฅํ ๋์
์ ๋ฐ์ ์ํค๋ ๊ฒ", |
| | "SDG 3": "๋ชจ๋ ์ฌ๋์ ๊ฑด๊ฐ๊ณผ ์ฐ๋น์ ์ฆ์ง์ํค๋ ๊ฒ", |
| | "SDG 4": "๋ชจ๋์๊ฒ ์ง ์ข์ ๊ต์ก์ ๋ณด์ฅํ๊ณ , ํ์ ํ์ต ๊ธฐํ๋ฅผ ๋๋ฆฌ๋ ๊ฒ", |
| | "SDG 5": "์ฑํ๋ฑ์ ์ด๋ฃจ๊ณ , ๋ชจ๋ ์ฌ์ฑ๊ณผ ์๋
์ ๊ถํ์ ๊ฐํํ๋ ๊ฒ", |
| | "SDG 6": "๋ชจ๋๊ฐ ๊นจ๋ํ ๋ฌผ๊ณผ ์์ ์์ค์ ์ด์ฉํ ์ ์๋๋ก ํ๋ ๊ฒ", |
| | "SDG 7": "๋ชจ๋์๊ฒ ์ ๋ ดํ๊ณ ๊นจ๋ํ ์๋์ง๋ฅผ ๋ณด์ฅํ๋ ๊ฒ", |
| | "SDG 8": "๋ชจ๋๋ฅผ ์ํ ์ง์์ ์ด๊ณ ํฌ์ฉ์ ์ด๋ฉฐ ์ง์๊ฐ๋ฅํ ๊ฒฝ์ ์ฑ์ฅ, ์์ฐ์ ์ธ ์์ ๊ณ ์ฉ๊ณผ ์์ง์ ์ผ์๋ฆฌ๋ฅผ ์ฆ์ง์ํค๋ ๊ฒ", |
| | "SDG 9": "ํผํผํ ์ฌํ ๊ธฐ๋ฐ ์์ค์ ๊ฑด์คํ๊ณ , ํฌ์ฉ์ ์ด๊ณ ์ง์๊ฐ๋ฅํ ์ฐ์
ํ๋ฅผ ์ฆ์งํ๋ฉฐ, ํ์ ์ ์ฅ๋ คํ๋ ๊ฒ", |
| | "SDG 10": "๊ตญ๊ฐ ๋ด ๊ทธ๋ฆฌ๊ณ ๊ตญ๊ฐ ๊ฐ ๋ถํ๋ฑ์ ์ค์ด๋ ๊ฒ", |
| | "SDG 11": "์์ ํ๊ณ ํ๋ณต๋ ฅ ์๊ณ ์ง์๊ฐ๋ฅํ ๋์์ ์ธ๊ฐ ๊ฑฐ์ฃผ์ง๋ฅผ ๋ง๋๋ ๊ฒ", |
| | "SDG 12": "์ง์๊ฐ๋ฅํ ์๋น์ ์์ฐ ํจํด์ ํ๋ฆฝํ๋ ๊ฒ", |
| | "SDG 13": "๊ธฐํ ๋ณํ์ ๊ทธ ์ํฅ์ ๋ง์ ์ธ์ฐ๊ธฐ ์ํ ๊ธด๊ธ ์กฐ์น๋ฅผ ์ทจํ๋ ๊ฒ", |
| | "SDG 14": "์ง์๊ฐ๋ฅํ ๋ฐ์ ์ ์ํด ํด์๊ณผ ํด์ ์์์ ๋ณด์กดํ๊ณ ์ง์๊ฐ๋ฅํ๊ฒ ์ฌ์ฉํ๋ ๊ฒ", |
| | "SDG 15": "์ก์ง ์ํ๊ณ๋ฅผ ๋ณดํธํ๊ณ ๋ณต์ํ๋ฉฐ ์ง์๊ฐ๋ฅํ๊ฒ ์ฌ์ฉํ๊ณ , ์ฐ๋ฆผ์ ์ง์๊ฐ๋ฅํ๊ฒ ๊ฒฝ์ํ๋ฉฐ, ์ฌ๋งํ๋ฅผ ๋ฐฉ์งํ๊ณ , ํ ์ง ํฉํํ๋ฅผ ์ค์ง์ํค๊ณ ๋์ด๋ฆฌ๋ฉฐ, ์๋ฌผ ๋ค์์ฑ ์์ค์ ๋ฉ์ถ๊ฒ ํ๋ ๊ฒ", |
| | "SDG 16": "์ง์๊ฐ๋ฅํ ๋ฐ์ ์ ์ํด ํํ๋กญ๊ณ ํฌ์ฉ์ ์ธ ์ฌํ๋ฅผ ์ฆ์งํ๊ณ , ๋ชจ๋์๊ฒ ์ ์๋ฅผ ๋ณด์ฅํ๋ฉฐ, ๋ชจ๋ ์์ค์์ ํจ๊ณผ์ ์ด๊ณ ์ฑ
์๊ฐ ์๊ณ ํฌ์ฉ์ ์ธ ์ ๋๋ฅผ ๊ตฌ์ถํ๋ ๊ฒ", |
| | "SDG 17": "์ง์๊ฐ๋ฅํ ๋ฐ์ ์ ์ํ ์ดํ ์๋จ์ ๊ฐํํ๊ณ , ๊ธ๋ก๋ฒ ํํธ๋์ญ์ ํ์ฑํํ๋ ๊ฒ", |
| | } |
| |
|
| | |
| | level_points = { |
| | 2: 20, |
| | 3: 50, |
| | 4: 100, |
| | 5: 200, |
| | } |
| |
|
| | |
| | base_points_per_action = { |
| | "scenario": 5, |
| | "options": 3, |
| | "retry": 1, |
| | } |
| |
|
| | |
| | positive_keywords = ["์ฑ๊ณต", "๊ฐ์ ", "ํฅ์", "๊ธ์ ์ ", "ํจ๊ณผ์ ", "์ฆ์ง", "๋ฐ์ ", "๋์", "๊ธฐ์ฌ", "ํด๊ฒฐ"] |
| | negative_keywords = ["์ด๋ ค์", "๋ฌธ์ ", "์
ํ", "๋ถ์ ์ ", "๋นํจ์จ์ ", "๋ถ์กฑ", "์์ค", "์
์ํฅ", "ํ๊ณ", "์คํจ"] |
| | point_ranges = { |
| | "positive": (10, 15), |
| | "neutral": (5, 10), |
| | "negative": (1, 5), |
| | } |
| |
|
| |
|
| | |
| | def update_level(): |
| | current_level = st.session_state["level"] |
| | current_points = st.session_state["points"] |
| | next_level = current_level + 1 |
| | if next_level in level_points and current_points >= level_points[next_level]: |
| | st.session_state["level"] = next_level |
| | st.success(f"๐ ๋ ๋ฒจ ์
! Level {next_level} ๋ฌ์ฑ! ๐") |
| | st.toast(f"๐ ๋ ๋ฒจ ์
! Level {next_level} ๋ฌ์ฑ! ๐", icon="๐") |
| |
|
| |
|
| | |
| | def generate_sdg_scenario(sdg_goal_name, sdg_goal_text): |
| | prompt = f""" |
| | ์ง์: |
| | ์ด๋ฑํ์ 6ํ๋
์์ค์ ๋ง์ถฐ์, {sdg_goal_text}({sdg_goal_name}) ๋ชฉํ์ ๊ด๋ จ๋ ์ ์ฑ
๊ฒฐ์ ์๋ฎฌ๋ ์ด์
์๋๋ฆฌ์ค๋ฅผ ์์ฑํด์ฃผ์ธ์. |
| | ์๋๋ฆฌ์ค๋ 8~10๋ฌธ์ฅ ์ ๋๋ก ํ์ค์ ์ธ ์ฌํ ๋ฌธ์ ์ํฉ์ ์ค๋ช
ํ๊ณ , ํ์๋ค์ด ์ ์ฑ
๊ฒฐ์ ์ ํ์์ฑ์ ๋๋ ์ ์๋๋ก ์์ฑํด์ฃผ์ธ์. |
| | "## ์๋๋ฆฌ์ค" ๋ก ์์ํด์ฃผ์ธ์. |
| | |
| | **์์ฑ๋ ์๋๋ฆฌ์ค:** |
| | """ |
| | chat_session = st.session_state["sdgs_chat_session"] |
| | response = chat_session.send_message(prompt) |
| | scenario_text = response.text.strip() |
| |
|
| | if scenario_text.startswith("## ์๋๋ฆฌ์ค"): |
| | scenario_content = scenario_text[len("## ์๋๋ฆฌ์ค") :].strip() |
| | st.session_state["points"] += base_points_per_action["scenario"] |
| | update_level() |
| | return scenario_content |
| | return scenario_text |
| |
|
| |
|
| | |
| | def generate_policy_options(scenario_text): |
| | prompt = f""" |
| | **์๋๋ฆฌ์ค:** |
| | {scenario_text} |
| | |
| | **์ง์:** |
| | ์ ์๋๋ฆฌ์ค์ ์ ์๋ ๋ฌธ์ ์ํฉ์ ํด๊ฒฐํ๊ธฐ ์ํ ์ ์ฑ
์ต์
3๊ฐ์ง ์ ๋๋ฅผ ์ด๋ฑํ์ 6ํ๋
์์ค์ ๋ง์ถฐ์ ์์ฑํด์ฃผ์ธ์. |
| | ๊ฐ ์ต์
์ 2~3๋ฌธ์ฅ์ผ๋ก ๊ฐ๊ฒฐํ๊ฒ ์ค๋ช
ํด์ฃผ์ธ์. |
| | ์ต์
์ ๋ฒํธ์ ํจ๊ป "์ต์
[๋ฒํธ]: " ๋ก ์์ํด์ฃผ์ธ์. (์: ์ต์
1: , ์ต์
2: ...) |
| | |
| | **์์ฑ๋ ์ ์ฑ
์ต์
:** |
| | """ |
| | chat_session = st.session_state["sdgs_chat_session"] |
| | response = chat_session.send_message(prompt) |
| | options_text = response.text.strip() |
| |
|
| | policy_options_list = {} |
| | if options_text: |
| | options_lines = [line.strip() for line in options_text.split('\n') if line.strip()] |
| | for line in options_lines: |
| | if line.startswith("์ต์
"): |
| | parts = line.split(":", 1) |
| | if len(parts) == 2: |
| | option_number = parts[0].split(" ")[1] |
| | option_description = parts[1].strip() |
| | policy_options_list[option_number] = option_description |
| | st.session_state["points"] += base_points_per_action["options"] |
| | update_level() |
| |
|
| | return policy_options_list |
| |
|
| |
|
| | |
| | def generate_policy_result(scenario_text, selected_option_text): |
| | prompt = f""" |
| | **์๋๋ฆฌ์ค:** |
| | {scenario_text} |
| | |
| | **์ ํํ ์ ์ฑ
์ต์
:** |
| | {selected_option_text} |
| | |
| | **์ง์:** |
| | ์ ์๋๋ฆฌ์ค ๋ฌธ์ ์ํฉ์์ ์ ํํ ์ ์ฑ
์ต์
์ ์คํํ์ ๋ ์์๋๋ ๊ฒฐ๊ณผ๋ฅผ ์ด๋ฑํ์ 6ํ๋
์์ค์ ๋ง์ถฐ์ 6~8๋ฌธ์ฅ ์ ๋๋ก ์ค๋ช
ํด์ฃผ์ธ์. |
| | ์ ์ฑ
์ ๊ธ์ ์ ์ธ ํจ๊ณผ์ ํจ๊ป ์์๋๋ ์ด๋ ค์์ด๋ ๋ถ์์ฉ๋ **์์งํ๊ฒ** ํจ๊ป ์ค๋ช
ํด์ฃผ์ธ์. |
| | ์ ์ฑ
๊ฒฐ๊ณผ๊ฐ ๊ธ์ ์ ์ธ์ง, ์ค๋ฆฝ์ ์ธ์ง, ๋ถ์ ์ ์ธ์ง ์ค์ค๋ก ํ๊ฐํ์ฌ ํจ๊ป ์๋ ค์ฃผ์ธ์. (์: ๊ธ์ ์ ๊ฒฐ๊ณผ, ์ค๋ฆฝ์ ๊ฒฐ๊ณผ, ๋ถ์ ์ ๊ฒฐ๊ณผ) |
| | "## ์ ์ฑ
๊ฒฐ๊ณผ" ๋ก ์์ํ๊ณ , ๊ทธ ๋ค์์ ์ ์ฑ
ํ๊ฐ(๊ธ์ ์ ๊ฒฐ๊ณผ, ์ค๋ฆฝ์ ๊ฒฐ๊ณผ, ๋ถ์ ์ ๊ฒฐ๊ณผ ์ค ํ๋)๋ฅผ ๊ดํธ ์์ ๋ฃ์ด์ ํ์ํด์ฃผ์ธ์. (์: ## ์ ์ฑ
๊ฒฐ๊ณผ (๊ธ์ ์ ๊ฒฐ๊ณผ)) |
| | ๊ทธ๋ฆฌ๊ณ ์ ์ฑ
๊ฒฐ๊ณผ ํ
์คํธ๋ฅผ ์ด์ด์ ์์ฑํด์ฃผ์ธ์. |
| | |
| | **์์ฑ๋ ์ ์ฑ
๊ฒฐ๊ณผ:** |
| | """ |
| | chat_session = st.session_state["sdgs_chat_session"] |
| | response = chat_session.send_message(prompt) |
| | result_text = response.text.strip() |
| |
|
| | policy_result_text = "" |
| | policy_evaluation = "neutral" |
| |
|
| | if result_text.startswith("## ์ ์ฑ
๊ฒฐ๊ณผ"): |
| | result_content_with_eval = result_text[len("## ์ ์ฑ
๊ฒฐ๊ณผ") :].strip() |
| | if result_content_with_eval.startswith("(๊ธ์ ์ ๊ฒฐ๊ณผ)"): |
| | policy_result_text = result_content_with_eval[len("(๊ธ์ ์ ๊ฒฐ๊ณผ)") :].strip() |
| | policy_evaluation = "positive" |
| | elif result_content_with_eval.startswith("(๋ถ์ ์ ๊ฒฐ๊ณผ)"): |
| | policy_result_text = result_content_with_eval[len("(๋ถ์ ์ ๊ฒฐ๊ณผ)") :].strip() |
| | policy_evaluation = "negative" |
| | elif result_content_with_eval.startswith("(์ค๋ฆฝ์ ๊ฒฐ๊ณผ)"): |
| | policy_result_text = result_content_with_eval[len("(์ค๋ฆฝ์ ๊ฒฐ๊ณผ)") :].strip() |
| | policy_evaluation = "neutral" |
| | else: |
| | policy_result_text = result_content_with_eval.strip() |
| |
|
| | |
| | if policy_evaluation == "positive": |
| | points = random.randint(*point_ranges["positive"]) |
| | elif policy_evaluation == "negative": |
| | points = random.randint(*point_ranges["negative"]) |
| | else: |
| | points = random.randint(*point_ranges["neutral"]) |
| |
|
| | st.session_state["points"] += points |
| | update_level() |
| | return policy_result_text, policy_evaluation, points |
| |
|
| |
|
| | |
| | def main(): |
| | st.sidebar.header("๐ SDGs ์ ์ฑ
๊ฒฐ์ ๊ฒ์") |
| | st.sidebar.markdown(f"### ๐ Level {st.session_state['level']}") |
| | st.sidebar.markdown(f"### โญ ํฌ์ธํธ: {st.session_state['points']}") |
| | st.sidebar.markdown("---") |
| |
|
| | selected_sdg_name = st.sidebar.selectbox("SDGs ๋ชฉํ ์ ํ:", list(sdg_goals.keys())) |
| | sdg_goal_text = sdg_goals[selected_sdg_name] |
| |
|
| | if st.session_state["selected_sdg"] != selected_sdg_name: |
| | st.session_state["current_sdg_scenario"] = None |
| | st.session_state["policy_options"] = None |
| | st.session_state["policy_result"] = None |
| | st.session_state["selected_sdg"] = selected_sdg_name |
| | st.session_state["user_policy_option"] = "" |
| |
|
| |
|
| | with st.sidebar.expander("๐ SDGs ๋ชฉํ ์ค๋ช
"): |
| | for goal_name, goal_text in sdg_goals.items(): |
| | st.markdown(f"**{goal_name}: {goal_text}**") |
| | st.write(sdg_descriptions[goal_name]) |
| | st.markdown("---") |
| |
|
| | with st.sidebar.expander("๐ ์ฑ ์ฌ์ฉ ๊ฐ์ด๋"): |
| | st.markdown( |
| | """ |
| | **SDGs ์ ์ฑ
๊ฒฐ์ ๊ฒ์ ๋ฐฉ๋ฒ** |
| | |
| | 1. **SDGs ๋ชฉํ ์ ํ:** ์ผ์ชฝ ์ฌ์ด๋๋ฐ์์ ์ ์ฑ
๊ฒฐ์ ์ ํด๋ณด๊ณ ์ถ์ SDGs ๋ชฉํ๋ฅผ ์ ํํ์ธ์. |
| | 2. **์๋๋ฆฌ์ค ์์ฑ:** '์๋๋ฆฌ์ค ์์ฑ' ๋ฒํผ์ ํด๋ฆญํ์ฌ ์ ํํ ๋ชฉํ์ ๊ด๋ จ๋ ๋ฌธ์ ์ํฉ ์๋๋ฆฌ์ค๋ฅผ ๋ฐ์๋ณด์ธ์. (โญ **๊ธฐ๋ณธ ํฌ์ธํธ +5**) |
| | 3. **์ ์ฑ
์ต์
์์ฑ:** ์๋๋ฆฌ์ค๋ฅผ ์ฝ๊ณ '์ ์ฑ
์ต์
์์ฑ' ๋ฒํผ์ ํด๋ฆญํ์ฌ AI๊ฐ ์ ์ํ๋ ์ ์ฑ
์ต์
๋ค์ ํ์ธํ์ธ์. (โญ **๊ธฐ๋ณธ ํฌ์ธํธ +3**) |
| | 4. **์ ์ฑ
์ต์
์ ํ ๋๋ ์ง์ ์
๋ ฅ:** |
| | * **AI ์ต์
์ ํ:** ์ ์๋ ์ต์
์ค ํ๋๋ฅผ ์ ํํ์ธ์. |
| | * **์ง์ ์
๋ ฅ:** '์ง์ ์
๋ ฅ'์ ์ ํํ๊ณ , ์๋ ํ
์คํธ ์
๋ ฅ ์ฐฝ์ ์ฌ๋ฌ๋ถ์ด ์๊ฐํ๋ ์ ์ฑ
์์ด๋์ด๋ฅผ ์ง์ ์ ์ด๋ณด์ธ์. |
| | 5. **์ ์ฑ
๊ฒฐ์ ์คํ:** ์ต์
์ ์ ํํ๊ฑฐ๋ ์ง์ ์
๋ ฅํ ํ '์ ์ฑ
๊ฒฐ์ ์คํ' ๋ฒํผ์ ํด๋ฆญํ์ธ์. (โญ **์ ์ฑ
ํ๊ฐ ๊ธฐ๋ฐ ํฌ์ธํธ**) |
| | 6. **์ ์ฑ
๊ฒฐ๊ณผ ํ์ธ:** ์ ํํ ์ ์ฑ
์ ์์ ๊ฒฐ๊ณผ์ ํจ๊ป ํ๋ํ ํฌ์ธํธ๋ฅผ ํ์ธํ์ธ์. ์ ์ฑ
๊ฒฐ๊ณผ๊ฐ ์ข์์๋ก ๋ ๋ง์ ํฌ์ธํธ๋ฅผ ์ป์ ์ ์์ต๋๋ค. |
| | 7. **์๋ก์ด ์๋๋ฆฌ์ค:** '์๋ก์ด ์๋๋ฆฌ์ค๋ก ๋ค์ํ๊ธฐ' ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์๋ก์ด ๋ฌธ์ ์ํฉ์ผ๋ก ๋ค์ ๊ฒ์์ ์์ํ ์ ์์ต๋๋ค. (โญ **์ฌ๋์ ๊ธฐ๋ณธ ํฌ์ธํธ +1**) |
| | |
| | **ํฌ์ธํธ์ ๋ ๋ฒจ:** |
| | |
| | * ๊ฒ์์ ์งํํ๋ฉด์ ํฌ์ธํธ๋ฅผ ์ป๊ณ , ๋ ๋ฒจ์ ์ฌ๋ฆด ์ ์์ต๋๋ค. |
| | * **์ ์ฑ
๊ฒฐ๊ณผ๊ฐ ์ข์์๋ก ๋ ๋ง์ ํฌ์ธํธ๋ฅผ ํ๋**ํ์ฌ ๋ ๋ฒจ์ ๋น ๋ฅด๊ฒ ์ฌ๋ฆด ์ ์์ต๋๋ค. |
| | * ๋ค์ํ SDGs ๋ชฉํ์ ๋์ ํ๊ณ , ์ข์ ์ ์ฑ
๊ฒฐ์ ์ ๋ง์ด ๋ด๋ ค์ ๋์ ๋ ๋ฒจ์ ๋์ ํด๋ณด์ธ์! |
| | |
| | **ํ:** |
| | |
| | * ๊ฐ SDGs ๋ชฉํ๊ฐ ๋ฌด์์ ์๋ฏธํ๋์ง 'SDGs ๋ชฉํ ์ค๋ช
'์ ์ฐธ๊ณ ํ์ธ์. |
| | * ์๋๋ฆฌ์ค๋ฅผ ๊ผผ๊ผผํ ์ฝ๊ณ , ๋ฌธ์ ์ ์์ธ๊ณผ ์ํฅ์ ํ์
ํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. |
| | * ์ ์ฑ
์ต์
์ ๊ธ์ ์ ํจ๊ณผ์ ์์๋๋ ์ด๋ ค์์ ๊ณ ๋ คํ์ฌ ์ ์คํ๊ฒ ์ ํํ์ธ์. |
| | * **๋ ๋์ ์ ์ฑ
์ ์ ํํ๊ฑฐ๋, ์ฐฝ์์ ์ธ ์ ์ฑ
์์ด๋์ด๋ฅผ ์ง์ ์
๋ ฅ**ํ์ฌ ๋์ ์ ์๋ฅผ ํ๋ํด๋ณด์ธ์! |
| | |
| | **์ฌ๋ฏธ์๊ฒ SDGs ์ ์ฑ
๊ฒฐ์ ๊ฒ์์ ์ฆ๊ธฐ๋ฉด์ ์ง์๊ฐ๋ฅํ ์ฌํ๋ฅผ ์ํ ๋ฌธ์ ํด๊ฒฐ ๋ฅ๋ ฅ์ ํค์๋ณด์ธ์!** |
| | """ |
| | ) |
| |
|
| |
|
| | st.title(f"๐ฏ {selected_sdg_name}: {sdg_goal_text} ์ ์ฑ
๊ฒฐ์ ์๋ฎฌ๋ ์ด์
") |
| |
|
| | if not st.session_state["current_sdg_scenario"]: |
| | if st.button("์๋๋ฆฌ์ค ์์ฑ", use_container_width=True): |
| | with st.spinner(f"{selected_sdg_name} ์๋๋ฆฌ์ค ์์ฑ ์ค..."): |
| | scenario = generate_sdg_scenario(selected_sdg_name, sdg_goal_text) |
| | st.session_state["current_sdg_scenario"] = scenario |
| | st.session_state["policy_options"] = None |
| | st.session_state["policy_result"] = None |
| | st.session_state["user_policy_option"] = "" |
| | st.rerun() |
| | else: |
| | st.subheader("๐ ์๋๋ฆฌ์ค") |
| | st.info(st.session_state["current_sdg_scenario"]) |
| |
|
| | if st.session_state["current_sdg_scenario"] and not st.session_state["policy_options"]: |
| | if st.button("์ ์ฑ
์ต์
์์ฑ", use_container_width=True): |
| | with st.spinner("์ ์ฑ
์ต์
์์ฑ ์ค..."): |
| | policy_options = generate_policy_options(st.session_state["current_sdg_scenario"]) |
| | st.session_state["policy_options"] = policy_options |
| | st.session_state["policy_result"] = None |
| | st.session_state["user_policy_option"] = "" |
| | st.rerun() |
| |
|
| | if st.session_state["policy_options"]: |
| | st.subheader("โ๏ธ ์ ์ฑ
์ต์
์ ํ") |
| | policy_option_keys = list(st.session_state["policy_options"].keys()) |
| | policy_option_keys_with_input = ["์ง์ ์
๋ ฅ"] + policy_option_keys |
| | selected_option_key = st.radio("์ ์ฑ
์ต์
์ ์ ํํ์ธ์:", policy_option_keys_with_input) |
| |
|
| | if selected_option_key == "์ง์ ์
๋ ฅ": |
| | user_input_option = st.text_area("์ง์ ์ ์ฑ
์ต์
์
๋ ฅ:", value=st.session_state["user_policy_option"]) |
| | st.session_state["user_policy_option"] = user_input_option |
| | selected_option_text = user_input_option |
| | else: |
| | selected_option_text = st.session_state["policy_options"][selected_option_key] |
| | st.info(f"**์ ํํ ์ต์
{selected_option_key}:** {selected_option_text}") |
| |
|
| |
|
| | if st.button("์ ์ฑ
๊ฒฐ์ ์คํ", use_container_width=True): |
| | with st.spinner("์ ์ฑ
๊ฒฐ๊ณผ ๋ถ์ ์ค..."): |
| | policy_result_text, policy_evaluation, points = generate_policy_result(st.session_state["current_sdg_scenario"], selected_option_text) |
| | st.session_state["policy_result"] = (policy_result_text, policy_evaluation, points) |
| | st.rerun() |
| |
|
| |
|
| | if st.session_state["policy_result"]: |
| | policy_result_text, policy_evaluation, points = st.session_state["policy_result"] |
| | st.subheader("๐ก ์ ์ฑ
๊ฒฐ๊ณผ") |
| | if policy_evaluation == "positive": |
| | st.success(f"โ
{policy_result_text}") |
| | elif policy_evaluation == "negative": |
| | st.warning(f"โ ๏ธ {policy_result_text}") |
| | else: |
| | st.info(f"๐ {policy_result_text}") |
| | st.markdown(f"ํ๋ ํฌ์ธํธ: โญ **{points}** points ({policy_evaluation} ์ ์ฑ
)") |
| |
|
| | if st.button("์๋ก์ด ์๋๋ฆฌ์ค๋ก ๋ค์ํ๊ธฐ", use_container_width=True): |
| | st.session_state["current_sdg_scenario"] = None |
| | st.session_state["policy_options"] = None |
| | st.session_state["policy_result"] = None |
| | st.session_state["user_policy_option"] = "" |
| | st.session_state["points"] += base_points_per_action["retry"] |
| | update_level() |
| | st.rerun() |
| |
|
| |
|
| | if __name__ == "__main__": |
| | main() |