Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix es search parameter error #3169

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions agent/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,9 @@ def prepare2run(cpns):
self.answer.append(c)
else:
if DEBUG: print("RUN: ", c)
if cpn.component_name == "Generate":
cpids = cpn.get_dependent_components()
if any([c not in self.path[-1] for c in cpids]):
continue
cpids = cpn.get_dependent_components()
if any([c not in self.path[-1] for c in cpids]):
continue
ans = cpn.run(self.history, **kwargs)
self.path[-1].append(c)
ran += 1
Expand Down
4 changes: 4 additions & 0 deletions agent/component/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ def __init__(self, canvas, id, param: ComponentParamBase):
self._param = param
self._param.check()

def get_dependent_components(self):
cpnts = [para["component_id"] for para in self._param.query]
return cpnts

def run(self, history, **kwargs):
flow_logger.info("{}, history: {}, kwargs: {}".format(self, json.dumps(history, ensure_ascii=False),
json.dumps(kwargs, ensure_ascii=False)))
Expand Down
6 changes: 3 additions & 3 deletions graphrag/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def merge_into_first(sres, title=""):
s["knn"]["filter"] = bqry.to_dict()
q_vec = s["knn"]["query_vector"]

ent_res = self.es.search(deepcopy(s), idxnm=idxnm, timeout="600s", src=src)
ent_res = self.es.search(deepcopy(s), idxnms=idxnm, timeout="600s", src=src)
entities = [d["name_kwd"] for d in self.es.getSource(ent_res)]
ent_ids = self.es.getDocIds(ent_res)
if merge_into_first(ent_res, "-Entities-"):
Expand All @@ -81,7 +81,7 @@ def merge_into_first(sres, title=""):
s = Search()
s = s.query(bqry)[0: 32]
s = s.to_dict()
comm_res = self.es.search(deepcopy(s), idxnm=idxnm, timeout="600s", src=src)
comm_res = self.es.search(deepcopy(s), idxnms=idxnm, timeout="600s", src=src)
comm_ids = self.es.getDocIds(comm_res)
if merge_into_first(comm_res, "-Community Report-"):
comm_ids = comm_ids[0:1]
Expand All @@ -92,7 +92,7 @@ def merge_into_first(sres, title=""):
s = Search()
s = s.query(bqry)[0: 6]
s = s.to_dict()
txt_res = self.es.search(deepcopy(s), idxnm=idxnm, timeout="600s", src=src)
txt_res = self.es.search(deepcopy(s), idxnms=idxnm, timeout="600s", src=src)
txt_ids = self.es.getDocIds(txt_res)
if merge_into_first(txt_res, "-Original Content-"):
txt_ids = txt_ids[0:1]
Expand Down