mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-10 03:51:47 +08:00
New: a new interpretor based on Andrew Ng theory. (#3532)
### What problem does this PR solve? ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
541272eb99
commit
362db857d0
@ -199,7 +199,7 @@ class Canvas(ABC):
|
|||||||
if any([cc not in self.path[-1] for cc in cpids]):
|
if any([cc not in self.path[-1] for cc in cpids]):
|
||||||
if c not in waiting: waiting.append(c)
|
if c not in waiting: waiting.append(c)
|
||||||
continue
|
continue
|
||||||
yield "'{}' is running...".format(self.get_compnent_name(c))
|
yield "*'{}'* is running...🕞".format(self.get_compnent_name(c))
|
||||||
ans = cpn.run(self.history, **kwargs)
|
ans = cpn.run(self.history, **kwargs)
|
||||||
self.path[-1].append(c)
|
self.path[-1].append(c)
|
||||||
ran += 1
|
ran += 1
|
||||||
@ -224,28 +224,16 @@ class Canvas(ABC):
|
|||||||
for m in prepare2run([switch_out]):
|
for m in prepare2run([switch_out]):
|
||||||
yield {"content": m, "running_status": True}
|
yield {"content": m, "running_status": True}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
for p in [c for p in self.path for c in p][::-1]:
|
yield {"content": "*Exception*: {}".format(e), "running_status": True}
|
||||||
if p.lower().find("answer") >= 0:
|
|
||||||
self.get_component(p)["obj"].set_exception(e)
|
|
||||||
for m in prepare2run([p]):
|
|
||||||
yield {"content": m, "running_status": True}
|
|
||||||
break
|
|
||||||
logging.exception("Canvas.run got exception")
|
logging.exception("Canvas.run got exception")
|
||||||
break
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for m in prepare2run(cpn["downstream"]):
|
for m in prepare2run(cpn["downstream"]):
|
||||||
yield {"content": m, "running_status": True}
|
yield {"content": m, "running_status": True}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
for p in [c for p in self.path for c in p][::-1]:
|
yield {"content": "*Exception*: {}".format(e), "running_status": True}
|
||||||
if p.lower().find("answer") >= 0:
|
|
||||||
self.get_component(p)["obj"].set_exception(e)
|
|
||||||
for m in prepare2run([p]):
|
|
||||||
yield {"content": m, "running_status": True}
|
|
||||||
break
|
|
||||||
logging.exception("Canvas.run got exception")
|
logging.exception("Canvas.run got exception")
|
||||||
break
|
|
||||||
|
|
||||||
if ran >= len(self.path[-1]) and waiting:
|
if ran >= len(self.path[-1]) and waiting:
|
||||||
without_dependent_checking = waiting
|
without_dependent_checking = waiting
|
||||||
|
@ -454,7 +454,7 @@ class ComponentBase(ABC):
|
|||||||
outs = []
|
outs = []
|
||||||
for q in self._param.query:
|
for q in self._param.query:
|
||||||
if q["component_id"]:
|
if q["component_id"]:
|
||||||
if q["component_id"].split("@")[0].lower().find("begin") > 0:
|
if q["component_id"].split("@")[0].lower().find("begin") >= 0:
|
||||||
cpn_id, key = q["component_id"].split("@")
|
cpn_id, key = q["component_id"].split("@")
|
||||||
for p in self._canvas.get_component(cpn_id)["obj"]._param.query:
|
for p in self._canvas.get_component(cpn_id)["obj"]._param.query:
|
||||||
if p["key"] == key:
|
if p["key"] == key:
|
||||||
|
@ -124,11 +124,16 @@ class Generate(ComponentBase):
|
|||||||
|
|
||||||
cpn = self._canvas.get_component(component_id)["obj"]
|
cpn = self._canvas.get_component(component_id)["obj"]
|
||||||
if cpn.component_name.lower() == "answer":
|
if cpn.component_name.lower() == "answer":
|
||||||
kwargs[para["key"]] = self._canvas.get_history(1)[0]["content"]
|
hist = self._canvas.get_history(1)
|
||||||
|
if hist:
|
||||||
|
hist = hist[0]["content"]
|
||||||
|
else:
|
||||||
|
hist = ""
|
||||||
|
kwargs[para["key"]] = hist
|
||||||
continue
|
continue
|
||||||
_, out = cpn.output(allow_partial=False)
|
_, out = cpn.output(allow_partial=False)
|
||||||
if "content" not in out.columns:
|
if "content" not in out.columns:
|
||||||
kwargs[para["key"]] = "Nothing"
|
kwargs[para["key"]] = ""
|
||||||
else:
|
else:
|
||||||
if cpn.component_name.lower() == "retrieval":
|
if cpn.component_name.lower() == "retrieval":
|
||||||
retrieval_res.append(out)
|
retrieval_res.append(out)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -134,6 +134,8 @@ def run():
|
|||||||
cvs.dsl = json.loads(str(canvas))
|
cvs.dsl = json.loads(str(canvas))
|
||||||
UserCanvasService.update_by_id(req["id"], cvs.to_dict())
|
UserCanvasService.update_by_id(req["id"], cvs.to_dict())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
cvs.dsl = json.loads(str(canvas))
|
||||||
|
UserCanvasService.update_by_id(req["id"], cvs.to_dict())
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
yield "data:" + json.dumps({"code": 500, "message": str(e),
|
yield "data:" + json.dumps({"code": 500, "message": str(e),
|
||||||
"data": {"answer": "**ERROR**: " + str(e), "reference": []}},
|
"data": {"answer": "**ERROR**: " + str(e), "reference": []}},
|
||||||
|
@ -111,12 +111,6 @@ def tenant_list():
|
|||||||
@manager.route("/agree/<tenant_id>", methods=["PUT"])
|
@manager.route("/agree/<tenant_id>", methods=["PUT"])
|
||||||
@login_required
|
@login_required
|
||||||
def agree(tenant_id):
|
def agree(tenant_id):
|
||||||
if current_user.id != tenant_id:
|
|
||||||
return get_json_result(
|
|
||||||
data=False,
|
|
||||||
message='No authorization.',
|
|
||||||
code=settings.RetCode.AUTHENTICATION_ERROR)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
UserTenantService.filter_update([UserTenant.tenant_id == tenant_id, UserTenant.user_id == current_user.id], {"role": UserTenantRole.NORMAL})
|
UserTenantService.filter_update([UserTenant.tenant_id == tenant_id, UserTenant.user_id == current_user.id], {"role": UserTenantRole.NORMAL})
|
||||||
return get_json_result(data=True)
|
return get_json_result(data=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user