mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 03:46:00 +08:00
fix generate bug (#2614)
### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
09d1f7f333
commit
35598c04ce
@ -122,13 +122,13 @@ class Generate(ComponentBase):
|
|||||||
if "empty_response" in retrieval_res.columns and not "".join(retrieval_res["content"]):
|
if "empty_response" in retrieval_res.columns and not "".join(retrieval_res["content"]):
|
||||||
res = {"content": "\n- ".join(retrieval_res["empty_response"]) if "\n- ".join(
|
res = {"content": "\n- ".join(retrieval_res["empty_response"]) if "\n- ".join(
|
||||||
retrieval_res["empty_response"]) else "Nothing found in knowledgebase!", "reference": []}
|
retrieval_res["empty_response"]) else "Nothing found in knowledgebase!", "reference": []}
|
||||||
return Generate.be_output(res)
|
return pd.DataFrame([res])
|
||||||
|
|
||||||
ans = chat_mdl.chat(prompt, self._canvas.get_history(self._param.message_history_window_size),
|
ans = chat_mdl.chat(prompt, self._canvas.get_history(self._param.message_history_window_size),
|
||||||
self._param.gen_conf())
|
self._param.gen_conf())
|
||||||
if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
|
if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
|
||||||
df = self.set_cite(retrieval_res, ans)
|
res = self.set_cite(retrieval_res, ans)
|
||||||
return pd.DataFrame(df)
|
return pd.DataFrame([res])
|
||||||
|
|
||||||
return Generate.be_output(ans)
|
return Generate.be_output(ans)
|
||||||
|
|
||||||
|
@ -49,34 +49,15 @@ class Switch(ComponentBase, ABC):
|
|||||||
|
|
||||||
def _run(self, history, **kwargs):
|
def _run(self, history, **kwargs):
|
||||||
for cond in self._param.conditions:
|
for cond in self._param.conditions:
|
||||||
|
res = []
|
||||||
if len(cond["items"]) == 1:
|
|
||||||
out = self._canvas.get_component(cond["items"][0]["cpn_id"])["obj"].output()[1]
|
|
||||||
cpn_input = "" if "content" not in out.columns else " ".join(out["content"])
|
|
||||||
if self.process_operator(cpn_input, cond["items"][0]["operator"], cond["items"][0]["value"]):
|
|
||||||
return Switch.be_output(cond["to"])
|
|
||||||
continue
|
|
||||||
|
|
||||||
if cond["logical_operator"] == "and":
|
|
||||||
res = True
|
|
||||||
for item in cond["items"]:
|
|
||||||
out = self._canvas.get_component(item["cpn_id"])["obj"].output()[1]
|
|
||||||
cpn_input = "" if "content" not in out.columns else " ".join(out["content"])
|
|
||||||
if not self.process_operator(cpn_input, item["operator"], item["value"]):
|
|
||||||
res = False
|
|
||||||
break
|
|
||||||
if res:
|
|
||||||
return Switch.be_output(cond["to"])
|
|
||||||
continue
|
|
||||||
|
|
||||||
res = False
|
|
||||||
for item in cond["items"]:
|
for item in cond["items"]:
|
||||||
out = self._canvas.get_component(item["cpn_id"])["obj"].output()[1]
|
out = self._canvas.get_component(item["cpn_id"])["obj"].output()[1]
|
||||||
cpn_input = "" if "content" not in out.columns else " ".join(out["content"])
|
cpn_input = "" if "content" not in out.columns else " ".join(out["content"])
|
||||||
if self.process_operator(cpn_input, item["operator"], item["value"]):
|
res.append(self.process_operator(cpn_input, item["operator"], item["value"]))
|
||||||
res = True
|
if cond["logical_operator"] != "and" and any(res):
|
||||||
break
|
return Switch.be_output(cond["to"])
|
||||||
if res:
|
|
||||||
|
if all(res):
|
||||||
return Switch.be_output(cond["to"])
|
return Switch.be_output(cond["to"])
|
||||||
|
|
||||||
return Switch.be_output(self._param.end_cpn_id)
|
return Switch.be_output(self._param.end_cpn_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user