mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
fix:data operations update (#11013)
### What problem does this PR solve? change:data operations update ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -153,6 +153,33 @@ class Graph:
|
||||
def get_tenant_id(self):
|
||||
return self._tenant_id
|
||||
|
||||
def get_value_with_variable(self,value: str) -> Any:
|
||||
pat = re.compile(r"\{* *\{([a-zA-Z:0-9]+@[A-Za-z:0-9_.-]+|sys\.[a-z_]+)\} *\}*")
|
||||
out_parts = []
|
||||
last = 0
|
||||
|
||||
for m in pat.finditer(value):
|
||||
out_parts.append(value[last:m.start()])
|
||||
key = m.group(1)
|
||||
v = self.get_variable_value(key)
|
||||
if v is None:
|
||||
rep = ""
|
||||
elif isinstance(v, partial):
|
||||
buf = []
|
||||
for chunk in v():
|
||||
buf.append(chunk)
|
||||
rep = "".join(buf)
|
||||
elif isinstance(v, str):
|
||||
rep = v
|
||||
else:
|
||||
rep = json.dumps(v, ensure_ascii=False)
|
||||
|
||||
out_parts.append(rep)
|
||||
last = m.end()
|
||||
|
||||
out_parts.append(value[last:])
|
||||
return("".join(out_parts))
|
||||
|
||||
def get_variable_value(self, exp: str) -> Any:
|
||||
exp = exp.strip("{").strip("}").strip(" ").strip("{").strip("}")
|
||||
if exp.find("@") < 0:
|
||||
|
||||
Reference in New Issue
Block a user