Kevin Hu commited on
Commit
8130a85
·
1 Parent(s): e1f775a

fix es search parameter error (#3169)

Browse files

### What problem does this PR solve?

#3151

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

agent/canvas.py CHANGED
@@ -194,10 +194,9 @@ class Canvas(ABC):
194
  self.answer.append(c)
195
  else:
196
  if DEBUG: print("RUN: ", c)
197
- if cpn.component_name == "Generate":
198
- cpids = cpn.get_dependent_components()
199
- if any([c not in self.path[-1] for c in cpids]):
200
- continue
201
  ans = cpn.run(self.history, **kwargs)
202
  self.path[-1].append(c)
203
  ran += 1
 
194
  self.answer.append(c)
195
  else:
196
  if DEBUG: print("RUN: ", c)
197
+ cpids = cpn.get_dependent_components()
198
+ if any([c not in self.path[-1] for c in cpids]):
199
+ continue
 
200
  ans = cpn.run(self.history, **kwargs)
201
  self.path[-1].append(c)
202
  ran += 1
agent/component/base.py CHANGED
@@ -397,6 +397,10 @@ class ComponentBase(ABC):
397
  self._param = param
398
  self._param.check()
399
 
 
 
 
 
400
  def run(self, history, **kwargs):
401
  flow_logger.info("{}, history: {}, kwargs: {}".format(self, json.dumps(history, ensure_ascii=False),
402
  json.dumps(kwargs, ensure_ascii=False)))
 
397
  self._param = param
398
  self._param.check()
399
 
400
+ def get_dependent_components(self):
401
+ cpnts = [para["component_id"] for para in self._param.query]
402
+ return cpnts
403
+
404
  def run(self, history, **kwargs):
405
  flow_logger.info("{}, history: {}, kwargs: {}".format(self, json.dumps(history, ensure_ascii=False),
406
  json.dumps(kwargs, ensure_ascii=False)))
graphrag/search.py CHANGED
@@ -68,7 +68,7 @@ class KGSearch(Dealer):
68
  s["knn"]["filter"] = bqry.to_dict()
69
  q_vec = s["knn"]["query_vector"]
70
 
71
- ent_res = self.es.search(deepcopy(s), idxnm=idxnm, timeout="600s", src=src)
72
  entities = [d["name_kwd"] for d in self.es.getSource(ent_res)]
73
  ent_ids = self.es.getDocIds(ent_res)
74
  if merge_into_first(ent_res, "-Entities-"):
@@ -81,7 +81,7 @@ class KGSearch(Dealer):
81
  s = Search()
82
  s = s.query(bqry)[0: 32]
83
  s = s.to_dict()
84
- comm_res = self.es.search(deepcopy(s), idxnm=idxnm, timeout="600s", src=src)
85
  comm_ids = self.es.getDocIds(comm_res)
86
  if merge_into_first(comm_res, "-Community Report-"):
87
  comm_ids = comm_ids[0:1]
@@ -92,7 +92,7 @@ class KGSearch(Dealer):
92
  s = Search()
93
  s = s.query(bqry)[0: 6]
94
  s = s.to_dict()
95
- txt_res = self.es.search(deepcopy(s), idxnm=idxnm, timeout="600s", src=src)
96
  txt_ids = self.es.getDocIds(txt_res)
97
  if merge_into_first(txt_res, "-Original Content-"):
98
  txt_ids = txt_ids[0:1]
 
68
  s["knn"]["filter"] = bqry.to_dict()
69
  q_vec = s["knn"]["query_vector"]
70
 
71
+ ent_res = self.es.search(deepcopy(s), idxnms=idxnm, timeout="600s", src=src)
72
  entities = [d["name_kwd"] for d in self.es.getSource(ent_res)]
73
  ent_ids = self.es.getDocIds(ent_res)
74
  if merge_into_first(ent_res, "-Entities-"):
 
81
  s = Search()
82
  s = s.query(bqry)[0: 32]
83
  s = s.to_dict()
84
+ comm_res = self.es.search(deepcopy(s), idxnms=idxnm, timeout="600s", src=src)
85
  comm_ids = self.es.getDocIds(comm_res)
86
  if merge_into_first(comm_res, "-Community Report-"):
87
  comm_ids = comm_ids[0:1]
 
92
  s = Search()
93
  s = s.query(bqry)[0: 6]
94
  s = s.to_dict()
95
+ txt_res = self.es.search(deepcopy(s), idxnms=idxnm, timeout="600s", src=src)
96
  txt_ids = self.es.getDocIds(txt_res)
97
  if merge_into_first(txt_res, "-Original Content-"):
98
  txt_ids = txt_ids[0:1]