Spaces:
Running
Running
humanda5
commited on
Commit
·
3e5e60d
1
Parent(s):
d28f7eb
이슈 수정
Browse files- npc_social_network/data/saves/simulation_state.pkl +0 -0
- npc_social_network/data/vectorstores/alice.faiss +0 -0
- npc_social_network/data/vectorstores/bob.faiss +0 -0
- npc_social_network/data/vectorstores/charlie.faiss +0 -0
- npc_social_network/data/vectorstores/diana.faiss +0 -0
- npc_social_network/data/vectorstores/elin.faiss +0 -0
- npc_social_network/npc/npc_memory_embedder.py +3 -0
- npc_social_network/routes/npc_route.py +3 -3
npc_social_network/data/saves/simulation_state.pkl
ADDED
Binary file (13 kB). View file
|
|
npc_social_network/data/vectorstores/alice.faiss
ADDED
Binary file (3.12 kB). View file
|
|
npc_social_network/data/vectorstores/bob.faiss
ADDED
Binary file (6.19 kB). View file
|
|
npc_social_network/data/vectorstores/charlie.faiss
ADDED
Binary file (7.73 kB). View file
|
|
npc_social_network/data/vectorstores/diana.faiss
ADDED
Binary file (7.73 kB). View file
|
|
npc_social_network/data/vectorstores/elin.faiss
ADDED
Binary file (12.3 kB). View file
|
|
npc_social_network/npc/npc_memory_embedder.py
CHANGED
@@ -80,6 +80,9 @@ def load_or_create_faiss_index(npc_name:str) -> faiss.Index:
|
|
80 |
|
81 |
def add_memory_to_index(npc: "NPC", memory: "Memory"):
|
82 |
"""단일 기억을 기존 FAISS 인덱스에 추가하고 다시 저장"""
|
|
|
|
|
|
|
83 |
# 1. 기존 인덱스를 불러오거나 새로 생성
|
84 |
index = load_or_create_faiss_index(npc.name)
|
85 |
|
|
|
80 |
|
81 |
def add_memory_to_index(npc: "NPC", memory: "Memory"):
|
82 |
"""단일 기억을 기존 FAISS 인덱스에 추가하고 다시 저장"""
|
83 |
+
if not os.path.exists(VECTOR_DIR):
|
84 |
+
os.makedirs(VECTOR_DIR)
|
85 |
+
|
86 |
# 1. 기존 인덱스를 불러오거나 새로 생성
|
87 |
index = load_or_create_faiss_index(npc.name)
|
88 |
|
npc_social_network/routes/npc_route.py
CHANGED
@@ -86,15 +86,15 @@ def manual_tick():
|
|
86 |
|
87 |
@npc_bp.route("/api/inject_event", methods=['POST'])
|
88 |
def inject_event():
|
89 |
-
"""플레이어가 NPC에게
|
90 |
data = request.json
|
91 |
npc_name, event_text = data.get("npc_name"), data.get("event_text")
|
92 |
|
93 |
with simulation_core.simulation_lock:
|
94 |
npc = simulation_core.npc_manager.get_npc_by_korean_name(npc_name)
|
95 |
if npc and event_text:
|
96 |
-
npc.remember(content=
|
97 |
-
simulation_core.add_log(f"
|
98 |
return jsonify({"success": True})
|
99 |
return jsonify({"success": False, "error": "Invalid data"}), 400
|
100 |
|
|
|
86 |
|
87 |
@npc_bp.route("/api/inject_event", methods=['POST'])
|
88 |
def inject_event():
|
89 |
+
"""플레이어가 NPC에게 '과거 기억'을 자연스럽게 주입하는 함수"""
|
90 |
data = request.json
|
91 |
npc_name, event_text = data.get("npc_name"), data.get("event_text")
|
92 |
|
93 |
with simulation_core.simulation_lock:
|
94 |
npc = simulation_core.npc_manager.get_npc_by_korean_name(npc_name)
|
95 |
if npc and event_text:
|
96 |
+
npc.remember(content=event_text, importance=8, emotion="nostalgia", memory_type="Recalled_Past") # 이벤트 타입: 상기된 과거
|
97 |
+
simulation_core.add_log(f"플레이어 개입 -> {npc_name}에게 '상기된 과거' 주입: '{event_text}'")
|
98 |
return jsonify({"success": True})
|
99 |
return jsonify({"success": False, "error": "Invalid data"}), 400
|
100 |
|