mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 03:35:51 +08:00
Metadata variable value fix (#16665)
This commit is contained in:
parent
360986f38d
commit
86a1859d02
@ -900,7 +900,10 @@ class DatasetRetrieval:
|
|||||||
return str(inputs.get(key, f"{{{{{key}}}}}"))
|
return str(inputs.get(key, f"{{{{{key}}}}}"))
|
||||||
|
|
||||||
pattern = re.compile(r"\{\{(\w+)\}\}")
|
pattern = re.compile(r"\{\{(\w+)\}\}")
|
||||||
return pattern.sub(replacer, text)
|
output = pattern.sub(replacer, text)
|
||||||
|
if isinstance(output, str):
|
||||||
|
output = re.sub(r"[\r\n\t]+", " ", output).strip()
|
||||||
|
return output
|
||||||
|
|
||||||
def _automatic_metadata_filter_func(
|
def _automatic_metadata_filter_func(
|
||||||
self, dataset_ids: list, query: str, tenant_id: str, user_id: str, metadata_model_config: ModelConfig
|
self, dataset_ids: list, query: str, tenant_id: str, user_id: str, metadata_model_config: ModelConfig
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Mapping, Sequence
|
from collections.abc import Mapping, Sequence
|
||||||
@ -360,8 +361,13 @@ class KnowledgeRetrievalNode(LLMNode):
|
|||||||
if isinstance(expected_value, str):
|
if isinstance(expected_value, str):
|
||||||
expected_value = self.graph_runtime_state.variable_pool.convert_template(
|
expected_value = self.graph_runtime_state.variable_pool.convert_template(
|
||||||
expected_value
|
expected_value
|
||||||
).text
|
).value[0]
|
||||||
|
if expected_value.value_type == "number":
|
||||||
|
expected_value = expected_value.value
|
||||||
|
elif expected_value.value_type == "string":
|
||||||
|
expected_value = re.sub(r"[\r\n\t]+", " ", expected_value.text).strip()
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid expected metadata value type")
|
||||||
filters = self._process_metadata_filter_func(
|
filters = self._process_metadata_filter_func(
|
||||||
condition.comparison_operator, metadata_name, expected_value, filters
|
condition.comparison_operator, metadata_name, expected_value, filters
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user