์ด๋ํ
[FEAT] ์ง์ฅ์ธ ์๋๋ฆฌ์ค ๋ฐ๋ชจ ๊ฐํ (๋ถ์ ์์ฌยท๋น์ฆ๋์ค ์ํฉํธยท๋ฉํฐ์ฑ๋)
1503eeb | #!/usr/bin/env python3 | |
| """ | |
| ์ง์ฅ์ธ(worker-v3) ์๋๋ฆฌ์ค ์นดํ๋ก๊ทธ ์์ฑ๊ธฐ. | |
| ๋จ์ผ TAXONOMY ์ ์๋ก๋ถํฐ intents.json / actions.json / behavior_intents.json ์์ฑ. | |
| ์๋๋ฆฌ์ค_์ง์ฅ์ธ: | |
| 1.1 ์ง์ฅ์ธ Domain Intent Taxonomy (L1 2 ยท L2 9) | |
| 3.1 ์ฑ ์ ํ์ง (10๊ฐ ์ฑ ๋จ์ผ ์ ํ) | |
| 4.2 ํ์ฉ ๋ฐฉ์ (MyKT ์ฑ Push ๋จ์ผ ์ฑ๋) | |
| ์คํ: | |
| cd roadshow-server-v3 | |
| python scripts/build_worker_scenario.py | |
| """ | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| from scripts._scenario_common import emit_layers # noqa: E402 | |
| SCENARIO_ID = "worker-v3" | |
| OUT_DIR = Path(__file__).parent.parent / "scenarios" / SCENARIO_ID | |
| L1 = { | |
| "1": ("INT-W100", "๋ฒ์์ ์ฌํ"), | |
| "2": ("INT-W200", "๋ฒ์์ ์ํ ์๋"), | |
| } | |
| # L3(=L2 ์์ค) Intent: | |
| # key : ์ฝ๋ (์ 1์๋ฆฌ๊ฐ L1) | |
| # name : Intent ๋ช | |
| # type : Rule | Model | |
| # features : ์ถ๋ก ํต์ฌ batch feature (Index/Score) | |
| # apps : ์ด Intent๋ก ์ง์ ์ ํธ๋ฅผ ์ฃผ๋ ์ฑ entity | |
| # service : ์ถ์ฒ ์๋น์ค | |
| # push : MyKT ์ฑ Push ๋ฌธ๊ตฌ | |
| # gmusic : ๐ต ์ง๋๋ฎค์ง ์ฑ๋ โ {playlist, desc} (์์ผ๋ฉด ์๋ต) | |
| # genie : ๐ ๊ธฐ๊ฐ์ง๋ยทํIoT ์ฑ๋ โ {command, devices[], desc} (์์ผ๋ฉด ์๋ต) | |
| # biz : ๐ผ ๋น์ฆ๋์ค ์ํฉํธ โ {tag, kpi, note} | |
| TAX = [ | |
| dict(key="110", name="๋๊ตด์ ํด์", type="Model", | |
| features=["Burnout Deep Score", "Isolation Tendency Index", "Sleep Disturbance Index"], | |
| apps=[], service="์ง๋๋ฎค์ง ํ๋งยทASMR ์ฝํ ์ธ ", | |
| push="์ค๋ ํ๋ฃจ๋ ์๊ณ ํ์ จ์ต๋๋ค. MyKT ์ง๋๋ฎค์ง ASMR ํ๋ ์ด๋ฆฌ์คํธ๋ก ์กฐ์ฉํ ํด์ ์๊ฐ์ ๊ฐ์ ธ๋ณด์ธ์.", | |
| genie=dict(command="๋๊ตด ๋ชจ๋ ์ผ์ค", | |
| devices=["๐ช ์ปคํผ ๋ซ๊ธฐ", "๐ก ์กฐ๋ช ์ด๋ก๊ฒ", "๐ ๋์ด๋ฝ ์ด์ค์ ๊ธ"], | |
| desc="์ธ๋ถ๋ฅผ ๋ซ๊ณ ์๋ํ๊ฒ โ ํผ์ ์๊ณ ์ถ์ ์ํ๋ฅผ ์ง ํ๊ฒฝ์ผ๋ก ๋ฐ์ณ์ค๋๋ค."), | |
| biz=dict(tag="ํIoT ํ์ฉ", kpi="๊ธฐ๊ฐ์ง๋ ์ฌ์ฉ โ", note="๋๊ตด ๋ชจ๋ ์๋ ์ธํ ์ผ๋ก ๊ธฐ๊ฐ์ง๋ ํ์ฉ")), | |
| dict(key="120", name="์๋์ง ์ ์ฝ ๋ชจ๋", type="Model", | |
| features=["Fatigue Load Index", "Burnout Deep Score"], | |
| apps=["delivery"], service="๋ฐฐ๋ฌ ์ ํด ํ ์ธ ํํ", | |
| push="์ง์น ์ ๋ , ์ง์ ์ค๋นํ์ง ์์๋ ๊ด์ฐฎ์์. MyKT ๋ฉค๋ฒ์ญ ๋ฐฐ๋ฌ ํ ์ธ ์ฟ ํฐ์ด ๋์ฐฉํ์ต๋๋ค.", | |
| genie=dict(command="์ฒญ์ ์ข ํด์ค", | |
| devices=["๐ค ๋ก๋ด์ฒญ์๊ธฐ ๊ฐ๋"], | |
| desc="๊ธฐ๋ ฅ์ด ์์ ๋ ์ง์์ผ์ ๋์ โ ์ต์ํ์ ๋ถ๋ด์ผ๋ก ์ ๋๋ ํ๊ฒฝ ์ ์ง."), | |
| biz=dict(tag="์ ํด์์ต", kpi="๋ฉค๋ฒ์ญ โ", note="๋ฐฐ๋ฌยท์ํ ์ ํด ์ ํ")), | |
| dict(key="130", name="๋ฆ์ ๋ฐค ๋์งํธ ํ๋", type="Rule", | |
| features=["Sleep Disturbance Index", "Digital Escape Score"], | |
| apps=["sns", "ott"], service="์๋ฉดยท๋ช ์ ์ฝํ ์ธ ", | |
| push="๋ฆ์ ์๊ฐ๊น์ง ๊นจ์ด ๊ณ์๋ค์. ์ง๋๋ฎค์ง ์๋ฉด ์ ๋ ์ฝํ ์ธ ๋ก ํธ์ํ ๋ฐค์ ์ค๋นํด๋ณด์ธ์.", | |
| gmusic=dict(playlist="์๋ฉด ํ๋ ์ด๋ฆฌ์คํธ", | |
| desc="์๋ฒฝ ์๊ฐ๋ ์ฒญ์ทจ ์ด๋ ฅ์ ๋ฐํ์ผ๋ก ์ ๋ค๊ธฐ ์ข์ ์ฌ์ด๋๋ฅผ ํ๋ ์ด์ ."), | |
| genie=dict(command="์ทจ์นจ ํ๊ฒฝ์ผ๋ก ๋ฐ๊ฟ์ค", | |
| devices=["๐บ ์ฌ๋ tv OFF", "๐ต ์ง๋๋ฎค์ง ์๋ฉด์ฌ์ด๋", "๐๏ธ ๋ชจ์ ๋ฒ ๋ ์ฝฐ์ด์ดํธ ์ฌ๋ฆฝ"], | |
| desc="TV์์ ์๋ฉด ์์ ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ํธ๋์คํ โ ํ๋ฉด์ ๋๊ณ ์๋ฉด ๋ชจ๋๋ก."), | |
| biz=dict(tag="๊ตฌ๋ ARPU", kpi="์ง๋๋ฎค์ง โ", note="์๋ฉด ์ฝํ ์ธ ๊ตฌ๋ ์ ํ")), | |
| dict(key="140", name="์ํ ๋ฆฌ๋ฌ ๋ถ๊ท์น", type="Model", | |
| features=["Fatigue Load Index", "Isolation Tendency Index", "weekend_out"], | |
| apps=["sns", "ott"], service="๊ฑด๊ฐยท์ด๋ ์ ํด ํํ", | |
| push="์ต๊ทผ ์ํ ๋ฆฌ๋ฌ์ด ๋ถ๊ท์นํด ๋ณด์ ๋๋ค. ์ด๋ยท๊ฑด๊ฐ ์ ํด ํํ์ผ๋ก ๊ฐ๋ฒผ์ด ์ฐ์ฑ ๋ถํฐ ์์ํด๋ณด์ธ์.", | |
| genie=dict(command="์์นจ ๋ฃจํด ๊ท์น์ ์ผ๋ก", | |
| devices=["โฐ 7์ ์๋", "๐ช 7์ ๋ธ๋ผ์ธ๋ ์ด๊ธฐ", "๐ก ์กฐ๋ช ์ ๋ฑ"], | |
| desc="์์นจ์ ์ผ์ ํ๊ฒ โ ๋ถ๊ท์นํด์ง ์ํ ๋ฆฌ๋ฌ์ ํ๊ฒฝ์ผ๋ก ๋ค์ก์ต๋๋ค."), | |
| biz=dict(tag="ํIoT ํ์ฉ", kpi="๊ธฐ๊ฐ์ง๋ ์ฌ์ฉ โ", note="์์นจ ๋ฃจํด ์๋ํ๋ก ๊ธฐ๊ฐ์ง๋๋ฅผ ๋งค์ผ ํ์ฉ")), | |
| dict(key="210", name="์ฆ๊ฐ ์คํธ๋ ์ค ํด์", type="Rule", | |
| features=["Burnout Deep Score", "Fatigue Load Index"], | |
| apps=["delivery", "shopping"], service="๋ฐฐ๋ฌยท์ผํ ๋ฉค๋ฒ์ญ ํ ์ธ", | |
| push="์ค๋ ์ฌ์ฉํ ์ ์๋ ๋ฐฐ๋ฌยท์ผํ ๋ฉค๋ฒ์ญ ํ ์ธ ํํ์ด ์์ต๋๋ค. ์์ ๋ณด์์ผ๋ก ํ๋ฃจ๋ฅผ ๋ง๋ฌด๋ฆฌํด๋ณด์ธ์.", | |
| gmusic=dict(playlist="์ ๋๋ ํ๋ฆฌ", | |
| desc="๊ธฐ๋ถ ์ ํ์ฉ ์ ๋นํธ โ ๋ํ๋ฏผ์ ๋์ด์ฌ๋ฆฌ๋ ํ๋ ์ด๋ฆฌ์คํธ."), | |
| biz=dict(tag="๊ตฌ๋ ARPU", kpi="์ง๋๋ฎค์ง โ", note="๊ธฐ๋ถ ์ ํ ํ๋ ์ด๋ฆฌ์คํธ๋ก ์ง๋๋ฎค์ง ํ์ฉ")), | |
| dict(key="220", name="ํ๊ฒฝ ์ ํ ์๊ตฌ", type="Rule", | |
| features=["Recovery Motivation Score", "Isolation Tendency Index"], | |
| apps=["travel"], service="์ฌํยท์๋ฐ ํ๋ก๋ชจ์ ", | |
| push="์ด๋ฒ ์ฃผ๋ง ์ ์ ๋ ๋๋ณด๋ ๊ฑด ์ด๋จ๊น์? MyKT ์ ์ฉ ์๋ฐ ํ ์ธ ํํ์ ํ์ธํด๋ณด์ธ์.", | |
| genie=dict(command="์ธ์ถ๋ชจ๋๋ก ๋ฐ๊ฟ์ค", | |
| devices=["๐ก ์กฐ๋ช OFF", "๐ ํ๋ฌ๊ทธ OFF", "๐ ๋์ด๋ฝ ์ ๊ธ"], | |
| desc="์ฆํฅ ๋๋ค์ด๋ฅผ ๊ฐ๋ณ๊ฒ โ ๊ธธ์๋ดยท๋ ์จ์ ํจ๊ป ์ธ์ถ ํ๊ฒฝ์ ํ ๋ฒ์ ์ ๋ฆฌ."), | |
| biz=dict(tag="์ ํด์์ต", kpi="์ฌํยท์๋ฐ โ", note="์ฌํยท์๋ฐ ์ ํด ํ๋ก๋ชจ์ ์ ํ")), | |
| dict(key="230", name="์ ์ฒด ํ๋ณต ์๋", type="Rule", | |
| features=["Recovery Motivation Score", "Fatigue Load Index"], | |
| apps=["exercise"], service="ํฌ์คยท๋ฌ๋ ์ ํด ์ฟ ํฐ", | |
| push="์ด๋์ ์์ํ๊ธฐ ์ข์ ํ์ด๋ฐ์ ๋๋ค. ํฌ์คยท๋ฌ๋ ์ ํด ์ฟ ํฐ์ด ์ค๋น๋์ด ์์ต๋๋ค.", | |
| gmusic=dict(playlist="์ด๋ํ ๋ ๋ฃ๋ ์์ ", | |
| desc="๋ฌ๋ยทํํธ ํ ํฌ์ ๋ง์ถ ์ด๋ ํ๋ ์ด๋ฆฌ์คํธ."), | |
| genie=dict(command="์ด๋ ํ์ด๋จธ ๋ง์ถฐ์ค", | |
| devices=["โฑ๏ธ ์ด๋ ํ์ด๋จธ ์ค์ "], | |
| desc="๊ฐ๋ณ๊ฒ ๋ชธ์ ์์ง์ด๋ ๋ฃจํด์ ์ง์."), | |
| biz=dict(tag="์ ํด์์ต", kpi="ํฌ์ค ์ ํด โ", note="ํฌ์คยท๋ฌ๋ ์ ํด ์ ํ")), | |
| dict(key="240", name="์ฌ๋ฆฌยท๊ฐ์ ํ๋ณต", type="Rule", | |
| features=["Recovery Motivation Score", "Isolation Tendency Index"], | |
| apps=["mental_recovery", "music"], service="์ง๋๋ฎค์ง ๋ช ์ยทํ๋ง ์ฝํ ์ธ ", | |
| push="๋ง์์ ์ฌ๊ฒ ํด์ค ์๊ฐ์ด ํ์ํด ๋ณด์ ๋๋ค. ์ง๋๋ฎค์ง ๋ช ์ ์ฝํ ์ธ ๋ฅผ ์ถ์ฒ๋๋ฆฝ๋๋ค.", | |
| gmusic=dict(playlist="ํ๋ง ์์ ", | |
| desc="๋ง์์ ๊ฐ๋ผ์ํ๋ ๋ช ์ยทํ๋ง ์ฌ์ด๋."), | |
| genie=dict(command="ํ๋ง ๋ชจ๋๋ก ๋ฐ๊ฟ์ค", | |
| devices=["๐ซ๏ธ ๋ํจ์ ON", "๐ก ์กฐ๋ช ๋ฐ๋ปํ๊ฒยท๋ฎ์ถค"], | |
| desc="๊ฐ์ ์ ์ฌ๊ฒ ํ๋ ๋ถ์๊ธฐ๋ก โ ํฅ๊ณผ ๋น์ผ๋ก ์์ ๊ฐ์ ๋ํฉ๋๋ค."), | |
| biz=dict(tag="๊ตฌ๋ ARPU", kpi="์ง๋๋ฎค์ง โ", note="ํ๋งยท๋ช ์ ๊ตฌ๋ ์ ํ")), | |
| dict(key="250", name="์ผ์ ํ๋ณต", type="Rule", | |
| features=["Recovery Motivation Score", "Isolation Tendency Index"], | |
| apps=["messenger", "reading", "exercise"], service="์นดํยท๋ฌธํ ๋ฉค๋ฒ์ญ ํํ", | |
| push="์ค๋๋ง์ ์ง์ธ๊ณผ ์ฐ๋ฝํด๋ณด๋ ๊ฑด ์ด๋จ๊น์? ์นดํ ๋ฉค๋ฒ์ญ ํ ์ธ ํํ์ ํ์ฉํด๋ณด์ธ์.", | |
| genie=dict(command="์๋ถ ์ฑ๊ธฐ๊ธฐ ์ผ์ ์ถ๊ฐํด์ค", | |
| devices=["๐ ์บ๋ฆฐ๋: ์ด๋ฒ ์ฃผ๋ง ์น๊ตฌ ๋ง๋๊ธฐ"], | |
| desc="๊ด๊ณ ํ๋ณต์ ์ฒซ๊ฑธ์์ ์ผ์ ์ผ๋ก โ ์ผ์์ผ๋ก ๋์์ค๋ ์์ ๊ณ๊ธฐ."), | |
| biz=dict(tag="ํIoT ํ์ฉ", kpi="๊ธฐ๊ฐ์ง๋ ์ฌ์ฉ โ", note="์๋ถ ์ผ์ ๋ฑ๋ก์ผ๋ก ๊ธฐ๊ฐ์ง๋ ํ์ฉ")), | |
| ] | |
| def build_intents(): | |
| intents = [] | |
| for t in TAX: | |
| l1_id, l1_name = L1[t["key"][0]] | |
| iid = f"INT-W{t['key']}" | |
| intents.append({ | |
| "id": iid, "name": t["name"], | |
| "L1_id": l1_id, "L1_name": l1_name, | |
| "L2_id": iid, "L2_name": t["name"], | |
| "inference_type": t["type"], "features": t["features"], | |
| }) | |
| return {"scenario_id": SCENARIO_ID, "version": "0.1.0", | |
| "description": "์ง์ฅ์ธ ๋ฒ์์/ํ๋ณต ์๋๋ฆฌ์ค Intent Taxonomy", | |
| "intents": intents} | |
| # ์ฑ๋ โ kind: ํ๋ก ํธ์ ๋ฒ์ฉ ๋ ๋๋ฌ๊ฐ ์ฑ๋ ์ข ๋ฅ๋ณ ๋ชฉ์ ์ ๊ฒฐ์ (์๋๋ฆฌ์ค ํนํ ์ฝ๋ ์ง์) | |
| # phone-push : ํด๋ํฐ ๋ฝ์คํฌ๋ฆฐ ํธ์ ๋ชฉ์ | |
| # music-card : ์ง๋๋ฎค์ง ํ๋ ์ด๋ฆฌ์คํธ ์นด๋ | |
| # device-voice: ๊ธฐ๊ฐ์ง๋ ์์ฑ ๋ช ๋ น + ํIoT ๊ธฐ๊ธฐ ๋์ ์นฉ | |
| CHANNELS = [ | |
| {"id": "push", "name": "์ฑ Push", "icon": "๐ฑ", "kind": "phone-push", | |
| "characteristic": "๊ณ ๊ฐ ์ํ์ ๋ง๋ ์ถ์ฒ ์๋น์ค๋ฅผ MyKT ์ฑ Push ๋ฉ์์ง๋ก ์ ๊ณต โ ๋ฒ์์ ์ํยท์ผ์ ํ๋ณต ์ง์"}, | |
| {"id": "genie_music", "name": "์ง๋๋ฎค์ง", "icon": "๐ต", "kind": "music-card", | |
| "characteristic": "ํ์ ์ฒญ์ทจ ์ด๋ ฅยท์๊ฐ๋ ์ทจํฅ์ ๋ฐํ์ผ๋ก ์ง๊ธ ์ํ์ ๋ง๋ ํ๋ ์ด๋ฆฌ์คํธ๋ฅผ ํ๋ ์ด์ "}, | |
| {"id": "gigagenie", "name": "๊ธฐ๊ฐ์ง๋ ยท ํIoT", "icon": "๐ ", "kind": "device-voice", | |
| "characteristic": "์์ฑ ํ๋ง๋๋ก ์ง์ ํ๊ฒฝ(์กฐ๋ช ยท์ปคํผยท๋์ด๋ฝยท๊ฐ์ )์ ์ํ์ ๋ง๊ฒ ์๋ ์ธํ "}, | |
| ] | |
| def build_actions(): | |
| actions = {} | |
| for t in TAX: | |
| iid = f"INT-W{t['key']}" | |
| act = {"push": t["push"], "service": t["service"]} | |
| if t.get("gmusic"): | |
| act["genie_music"] = t["gmusic"] | |
| if t.get("genie"): | |
| act["gigagenie"] = t["genie"] | |
| if t.get("biz"): | |
| act["business_value"] = t["biz"] | |
| actions[iid] = act | |
| return {"scenario_id": SCENARIO_ID, "version": "0.1.0", | |
| "description": "์ง์ฅ์ธ ์๋๋ฆฌ์ค Intent๋ณ ๋ฉํฐ์ฑ๋ ํ์ฉ ์์ (Pushยท์ง๋๋ฎค์งยท๊ธฐ๊ฐ์ง๋) + ๋น์ฆ๋์ค ์ํฉํธ", | |
| "channels": CHANNELS, "actions": actions} | |
| def build_behavior_intents(): | |
| entity_intents = {} | |
| for t in TAX: | |
| iid = f"INT-W{t['key']}" | |
| for app in t["apps"]: | |
| entity_intents.setdefault(app, []).append(iid) | |
| return {"scenario_id": SCENARIO_ID, "version": "0.1.0", | |
| "description": "์ง์ฅ์ธ ์ฑ ์ ํ(entity) โ ์ง์ ์ ํธ Intent ๋งคํ", | |
| "entity_intents": entity_intents} | |
| def main(): | |
| emit_layers( | |
| OUT_DIR / "engine", | |
| taxonomy=build_intents(), | |
| context_library=build_actions(), | |
| behavior_signals=build_behavior_intents()["entity_intents"], | |
| ) | |
| from collections import Counter | |
| ints = build_intents()["intents"] | |
| print("inference_type:", Counter(i["inference_type"] for i in ints)) | |
| bi = build_behavior_intents()["entity_intents"] | |
| print("app entities mapped:", list(bi.keys())) | |
| if __name__ == "__main__": | |
| main() | |