Spaces:
Sleeping
Sleeping
| # modules/profile_utils.py | |
| from typing import Dict, Any | |
| import config | |
| logger = config.get_logger(__name__) | |
| def get_chat_profile_dict(store_profile_dict: Dict[str, Any]) -> Dict[str, Any]: | |
| """ | |
| FastAPI (server.py)์์ ๋ฐ์ 'store_profile' ๋์ ๋๋ฆฌ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก, | |
| visualization.py์ orchestrator.py์์ ๊ณตํต์ผ๋ก ์ฌ์ฉํ | |
| '์ฑํ ์ฉ ํ๋กํ ๋์ ๋๋ฆฌ' (์ฌ์ฅ๋์ด ์์ฒญํ์ ํญ๋ชฉ)๋ฅผ ์์ฑํฉ๋๋ค. | |
| ์ด ํจ์๊ฐ '์ฑํ ์ฉ ํ๋กํ'์ ๋จ์ผ ์ ์(Source of Truth) ์ญํ ์ ํฉ๋๋ค. | |
| """ | |
| try: | |
| # 1. ๊ธฐ๋ณธ ์ ๋ณด | |
| chat_profile_data = { | |
| "๊ฐ๋งน์ ๋ช ": store_profile_dict.get('๊ฐ๋งน์ ๋ช ', 'N/A'), | |
| "๊ฐ๋งน์ ID": store_profile_dict.get('๊ฐ๋งน์ ID', 'N/A'), | |
| "์๊ถ": store_profile_dict.get('์๊ถ', 'N/A'), | |
| "์ ์ข ": store_profile_dict.get('์ ์ข ', 'N/A'), | |
| "์ฃผ์": store_profile_dict.get('๊ฐ๋งน์ ์ฃผ์', 'N/A'), | |
| "์ด์ ๊ธฐ๊ฐ ์์ค": store_profile_dict.get('์ด์๊ฐ์์_์์ค', 'N/A'), | |
| "๋งค์ถ ์์ค": store_profile_dict.get('๋งค์ถ๊ตฌ๊ฐ_์์ค', 'N/A'), | |
| "๋งค์ถ ๊ฑด์ ์์ค": store_profile_dict.get('์๋งค์ถ๊ฑด์_์์ค', 'N/A'), | |
| "๋ฐฉ๋ฌธ ๊ณ ๊ฐ์ ์์ค": store_profile_dict.get('์์ ๋ํฌ๊ณ ๊ฐ์_์์ค', 'N/A'), | |
| "๊ฐ๋จ๊ฐ ์์ค": store_profile_dict.get('์๊ฐ๋จ๊ฐ_์์ค', 'N/A'), | |
| "์ ๊ท/์ฌ๋ฐฉ๋ฌธ์จ": f"์ ๊ท {(store_profile_dict.get('์ ๊ท๊ณ ๊ฐ๋น์จ') or 0):.1f}% / ์ฌ๋ฐฉ๋ฌธ {(store_profile_dict.get('์ฌ์ด์ฉ๊ณ ๊ฐ๋น์จ') or 0):.1f}%", | |
| "๋์ผ ์๊ถ ๋๋น ๋งค์ถ ์์": f"์์ {(store_profile_dict.get('๋์ผ์๊ถ๋ด๋งค์ถ์์๋น์จ') or 0):.1f}%", | |
| "๋์ผ ์ ์ข ๋๋น ๋งค์ถ ์์": f"์์ {(store_profile_dict.get('๋์ผ์ ์ข ๋ด๋งค์ถ์์๋น์จ') or 0):.1f}%" | |
| } | |
| # 2. '์๋์ถ์ถํน์ง' ์ถ๊ฐ | |
| chat_profile_data["์๋์ถ์ถํน์ง"] = store_profile_dict.get('์๋์ถ์ถํน์ง', {}) | |
| return chat_profile_data | |
| except Exception as e: | |
| logger.critical(f"--- [Profile Utils CRITICAL] ์ฑํ ํ๋กํ ๋์ ๋๋ฆฌ ์์ฑ ์คํจ: {e} ---", exc_info=True) | |
| return { | |
| "์ ์ข ": store_profile_dict.get('์ ์ข ', '์ ์ ์์'), | |
| "์๋์ถ์ถํน์ง": store_profile_dict.get('์๋์ถ์ถํน์ง', {}), | |
| "์ฃผ์": store_profile_dict.get('๊ฐ๋งน์ ์ฃผ์', '์ ์ ์์'), | |
| "error": "ํ๋กํ ์์ฝ ์ค ์ค๋ฅ ๋ฐ์" | |
| } |