mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix:update agent variable name rule (#11124)
### What problem does this PR solve? change: 1. update agent variable name rule. 2. reset() in Canvas doesn't reset the env var. 3. correct log input binding in message component ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -154,7 +154,7 @@ class Graph:
|
|||||||
return self._tenant_id
|
return self._tenant_id
|
||||||
|
|
||||||
def get_value_with_variable(self,value: str) -> Any:
|
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_]+)\} *\}*")
|
pat = re.compile(r"\{* *\{([a-zA-Z:0-9]+@[A-Za-z0-9_.]+|sys\.[A-Za-z0-9_.]+|env\.[A-Za-z0-9_.]+)\} *\}*")
|
||||||
out_parts = []
|
out_parts = []
|
||||||
last = 0
|
last = 0
|
||||||
|
|
||||||
@ -256,6 +256,7 @@ class Canvas(Graph):
|
|||||||
self.retrieval = []
|
self.retrieval = []
|
||||||
self.memory = []
|
self.memory = []
|
||||||
for k in self.globals.keys():
|
for k in self.globals.keys():
|
||||||
|
if k.startswith("sys."):
|
||||||
if isinstance(self.globals[k], str):
|
if isinstance(self.globals[k], str):
|
||||||
self.globals[k] = ""
|
self.globals[k] = ""
|
||||||
elif isinstance(self.globals[k], int):
|
elif isinstance(self.globals[k], int):
|
||||||
|
|||||||
@ -393,7 +393,7 @@ class ComponentParamBase(ABC):
|
|||||||
class ComponentBase(ABC):
|
class ComponentBase(ABC):
|
||||||
component_name: str
|
component_name: str
|
||||||
thread_limiter = trio.CapacityLimiter(int(os.environ.get('MAX_CONCURRENT_CHATS', 10)))
|
thread_limiter = trio.CapacityLimiter(int(os.environ.get('MAX_CONCURRENT_CHATS', 10)))
|
||||||
variable_ref_patt = r"\{* *\{([a-zA-Z:0-9]+@[A-Za-z:0-9_.-]+|sys\.[a-z_]+)\} *\}*"
|
variable_ref_patt = r"\{* *\{([a-zA-Z:0-9]+@[A-Za-z0-9_.]+|sys\.[A-Za-z0-9_.]+|env\.[A-Za-z0-9_.]+)\} *\}*"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class Message(ComponentBase):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
v = self._canvas.get_variable_value(exp)
|
v = self._canvas.get_variable_value(exp)
|
||||||
if not v:
|
if v is None:
|
||||||
v = ""
|
v = ""
|
||||||
if isinstance(v, partial):
|
if isinstance(v, partial):
|
||||||
cnt = ""
|
cnt = ""
|
||||||
@ -107,7 +107,7 @@ class Message(ComponentBase):
|
|||||||
all_content += t
|
all_content += t
|
||||||
cnt += t
|
cnt += t
|
||||||
yield t
|
yield t
|
||||||
|
self.set_input_value(exp, cnt)
|
||||||
continue
|
continue
|
||||||
elif not isinstance(v, str):
|
elif not isinstance(v, str):
|
||||||
try:
|
try:
|
||||||
@ -115,6 +115,7 @@ class Message(ComponentBase):
|
|||||||
except Exception:
|
except Exception:
|
||||||
v = str(v)
|
v = str(v)
|
||||||
yield v
|
yield v
|
||||||
|
self.set_input_value(exp, v)
|
||||||
all_content += v
|
all_content += v
|
||||||
cache[exp] = v
|
cache[exp] = v
|
||||||
|
|
||||||
|
|||||||
@ -135,7 +135,7 @@ class Retrieval(ToolBase, ABC):
|
|||||||
elif self._param.meta_data_filter.get("method") == "manual":
|
elif self._param.meta_data_filter.get("method") == "manual":
|
||||||
filters=self._param.meta_data_filter["manual"]
|
filters=self._param.meta_data_filter["manual"]
|
||||||
for flt in filters:
|
for flt in filters:
|
||||||
pat = re.compile(r"\{* *\{([a-zA-Z:0-9]+@[A-Za-z:0-9_.-]+|sys\.[a-z_]+)\} *\}*")
|
pat = re.compile(self.variable_ref_patt)
|
||||||
s = flt["value"]
|
s = flt["value"]
|
||||||
out_parts = []
|
out_parts = []
|
||||||
last = 0
|
last = 0
|
||||||
|
|||||||
@ -187,7 +187,7 @@ function start_mcp_server() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ensure_docling() {
|
function ensure_docling() {
|
||||||
[[ "${USE_DOCLING}" == "true" ]] || return 0
|
[[ "${USE_DOCLING}" == "true" ]] || { echo "[docling] disabled by USE_DOCLING"; return 0; }
|
||||||
python3 -c 'import pip' >/dev/null 2>&1 || python3 -m ensurepip --upgrade || true
|
python3 -c 'import pip' >/dev/null 2>&1 || python3 -m ensurepip --upgrade || true
|
||||||
DOCLING_PIN="${DOCLING_VERSION:-==2.58.0}"
|
DOCLING_PIN="${DOCLING_VERSION:-==2.58.0}"
|
||||||
python3 -c "import importlib.util,sys; sys.exit(0 if importlib.util.find_spec('docling') else 1)" \
|
python3 -c "import importlib.util,sys; sys.exit(0 if importlib.util.find_spec('docling') else 1)" \
|
||||||
|
|||||||
Reference in New Issue
Block a user