@@ -62,7 +62,8 @@ def __init__(
62
62
intention_router : Optional [IntentionRouter ] = None ,
63
63
do_init : bool = False ,
64
64
kb_root_path : str = KB_ROOT_PATH ,
65
- initialize_space = True
65
+ initialize_space = True ,
66
+ clear_history_data = True
66
67
):
67
68
68
69
self .db_config = db_config
@@ -83,6 +84,7 @@ def __init__(
83
84
self .model , embed_config = self .embed_config )
84
85
# init db handler
85
86
self .initialize_space = initialize_space
87
+ self .clear_history_data = clear_history_data
86
88
self .init_handler ()
87
89
# load custom keywords
88
90
if os .path .exists (EXTRA_KEYWORDS_PATH ):
@@ -138,7 +140,6 @@ def init_tb(self, do_init: bool=None):
138
140
TextField ("ekg_type" ,),
139
141
]
140
142
141
-
142
143
if self .tb_config :
143
144
tb_dict = {"TbaseHandler" : TbaseHandler }
144
145
tb_class = tb_dict .get (self .tb_config .tb_type , TbaseHandler )
@@ -148,6 +149,11 @@ def init_tb(self, do_init: bool=None):
148
149
definition_value = self .tb_config .extra_kwargs .get (
149
150
"definition_value" , "muagent_ekg" )
150
151
)
152
+
153
+ if self .clear_history_data :
154
+ self .tb .drop_index (self .node_indexname )
155
+ self .tb .drop_index (self .edge_indexname )
156
+
151
157
# # create index
152
158
if not self .tb .is_index_exists (self .node_indexname ):
153
159
res = self .tb .create_index (
@@ -176,8 +182,11 @@ def init_gb(self, do_init: bool=None):
176
182
self .gb .add_hosts ('storaged0' , 9779 )
177
183
print ('增加NebulaGraph Storage主机中,等待20秒' )
178
184
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
+
181
190
self .gb .create_space ('client' )
182
191
183
192
# 创建node tags和edge types
0 commit comments