@@ -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