Skip to content

Commit 2c997c4

Browse files
committed
add clear history data
1 parent df5d3aa commit 2c997c4

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

examples/ekg_examples/start.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,14 @@ def embed_query(self, text: str) -> List[float]:
273273
# )
274274
embed_config = None
275275

276+
clear_history_data = os.environ.get('clear_history_data', 'False') == 'True'
276277

277278
ekg_construct_service = EKGConstructService(
278279
embed_config=embed_config,
279280
llm_config=llm_config,
280281
tb_config=tb_config,
281282
gb_config=gb_config,
283+
clear_history_data=clear_history_data
282284
)
283285

284286

examples/test_config.py.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ os.environ["tb_index_name"] = "ekg_migration_new"
4141
os.environ['tb_definition_value'] = 'message_test_new'
4242
os.environ['tb_expire_time'] = '604800' #86400*7
4343

44+
# clear history data in tb and gb
45+
os.environ['clear_history_data'] = 'True'
4446

4547

4648
########################################

muagent/service/ekg_construct/ekg_construct_base.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def __init__(
6262
intention_router: Optional[IntentionRouter] = None,
6363
do_init: bool = False,
6464
kb_root_path: str = KB_ROOT_PATH,
65-
initialize_space=True
65+
initialize_space=True,
66+
clear_history_data=True
6667
):
6768

6869
self.db_config = db_config
@@ -83,6 +84,7 @@ def __init__(
8384
self.model, embed_config=self.embed_config)
8485
# init db handler
8586
self.initialize_space = initialize_space
87+
self.clear_history_data = clear_history_data
8688
self.init_handler()
8789
# load custom keywords
8890
if os.path.exists(EXTRA_KEYWORDS_PATH):
@@ -138,7 +140,6 @@ def init_tb(self, do_init: bool=None):
138140
TextField("ekg_type",),
139141
]
140142

141-
142143
if self.tb_config:
143144
tb_dict = {"TbaseHandler": TbaseHandler}
144145
tb_class = tb_dict.get(self.tb_config.tb_type, TbaseHandler)
@@ -148,6 +149,11 @@ def init_tb(self, do_init: bool=None):
148149
definition_value=self.tb_config.extra_kwargs.get(
149150
"definition_value", "muagent_ekg")
150151
)
152+
153+
if self.clear_history_data:
154+
self.tb.drop_index(self.node_indexname)
155+
self.tb.drop_index(self.edge_indexname)
156+
151157
# # create index
152158
if not self.tb.is_index_exists(self.node_indexname):
153159
res = self.tb.create_index(
@@ -176,8 +182,11 @@ def init_gb(self, do_init: bool=None):
176182
self.gb.add_hosts('storaged0', 9779)
177183
print('增加NebulaGraph Storage主机中,等待20秒')
178184
time.sleep(20)
179-
# 初始化space
180-
self.gb.drop_space('client')
185+
186+
if self.clear_history_data:
187+
# 初始化space
188+
self.gb.drop_space('client')
189+
181190
self.gb.create_space('client')
182191

183192
# 创建node tags和edge types

0 commit comments

Comments
 (0)