mirror of
https://github.com/langgenius/dify.git
synced 2026-05-27 20:36:18 +08:00
Merge branch 'main' into 4-27-app-deploy
This commit is contained in:
@ -618,26 +618,27 @@ class RagPipelineService:
|
||||
for key, value in datasource_parameters.items():
|
||||
param_value = value.get("value")
|
||||
|
||||
if not param_value:
|
||||
variables_map[key] = param_value
|
||||
elif isinstance(param_value, str):
|
||||
# handle string type parameter value, check if it contains variable reference pattern
|
||||
pattern = r"\{\{#([a-zA-Z0-9_]{1,50}(?:\.[a-zA-Z0-9_][a-zA-Z0-9_]{0,29}){1,10})#\}\}"
|
||||
match = re.match(pattern, param_value)
|
||||
if match:
|
||||
# extract variable path and try to get value from user inputs
|
||||
full_path = match.group(1)
|
||||
last_part = full_path.split(".")[-1]
|
||||
variables_map[key] = user_inputs.get(last_part, param_value)
|
||||
else:
|
||||
match param_value:
|
||||
case None | "" | [] | {}:
|
||||
variables_map[key] = param_value
|
||||
case str():
|
||||
# handle string type parameter value, check if it contains variable reference pattern
|
||||
pattern = r"\{\{#([a-zA-Z0-9_]{1,50}(?:\.[a-zA-Z0-9_][a-zA-Z0-9_]{0,29}){1,10})#\}\}"
|
||||
match_result = re.match(pattern, param_value)
|
||||
if match_result:
|
||||
# extract variable path and try to get value from user inputs
|
||||
full_path = match_result.group(1)
|
||||
last_part = full_path.split(".")[-1]
|
||||
variables_map[key] = user_inputs.get(last_part, param_value)
|
||||
else:
|
||||
variables_map[key] = param_value
|
||||
case list() if param_value:
|
||||
# handle list type parameter value, check if the last element is in user inputs
|
||||
last_part = param_value[-1]
|
||||
variables_map[key] = user_inputs.get(last_part, param_value)
|
||||
case _:
|
||||
# other type directly use original value
|
||||
variables_map[key] = param_value
|
||||
elif isinstance(param_value, list) and param_value:
|
||||
# handle list type parameter value, check if the last element is in user inputs
|
||||
last_part = param_value[-1]
|
||||
variables_map[key] = user_inputs.get(last_part, param_value)
|
||||
else:
|
||||
# other type directly use original value
|
||||
variables_map[key] = param_value
|
||||
|
||||
from core.datasource.datasource_manager import DatasourceManager
|
||||
|
||||
|
||||
@ -78,32 +78,33 @@ class ToolTransformService:
|
||||
:param tenant_id: the tenant id
|
||||
:param provider: the provider dict
|
||||
"""
|
||||
if isinstance(provider, dict) and "icon" in provider:
|
||||
provider["icon"] = ToolTransformService.get_tool_provider_icon_url(
|
||||
provider_type=provider["type"], provider_name=provider["name"], icon=provider["icon"]
|
||||
)
|
||||
elif isinstance(provider, ToolProviderApiEntity):
|
||||
if provider.plugin_id:
|
||||
if isinstance(provider.icon, str):
|
||||
provider.icon = PluginService.get_plugin_icon_url(tenant_id=tenant_id, filename=provider.icon)
|
||||
if isinstance(provider.icon_dark, str) and provider.icon_dark:
|
||||
provider.icon_dark = PluginService.get_plugin_icon_url(
|
||||
tenant_id=tenant_id, filename=provider.icon_dark
|
||||
)
|
||||
else:
|
||||
provider.icon = ToolTransformService.get_tool_provider_icon_url(
|
||||
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon
|
||||
match provider:
|
||||
case dict() if "icon" in provider:
|
||||
provider["icon"] = ToolTransformService.get_tool_provider_icon_url(
|
||||
provider_type=provider["type"], provider_name=provider["name"], icon=provider["icon"]
|
||||
)
|
||||
if provider.icon_dark:
|
||||
provider.icon_dark = ToolTransformService.get_tool_provider_icon_url(
|
||||
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon_dark
|
||||
)
|
||||
elif isinstance(provider, PluginDatasourceProviderEntity):
|
||||
if provider.plugin_id:
|
||||
if isinstance(provider.declaration.identity.icon, str):
|
||||
provider.declaration.identity.icon = PluginService.get_plugin_icon_url(
|
||||
tenant_id=tenant_id, filename=provider.declaration.identity.icon
|
||||
case ToolProviderApiEntity():
|
||||
if provider.plugin_id:
|
||||
if isinstance(provider.icon, str):
|
||||
provider.icon = PluginService.get_plugin_icon_url(tenant_id=tenant_id, filename=provider.icon)
|
||||
if isinstance(provider.icon_dark, str) and provider.icon_dark:
|
||||
provider.icon_dark = PluginService.get_plugin_icon_url(
|
||||
tenant_id=tenant_id, filename=provider.icon_dark
|
||||
)
|
||||
else:
|
||||
provider.icon = ToolTransformService.get_tool_provider_icon_url(
|
||||
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon
|
||||
)
|
||||
if provider.icon_dark:
|
||||
provider.icon_dark = ToolTransformService.get_tool_provider_icon_url(
|
||||
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon_dark
|
||||
)
|
||||
case PluginDatasourceProviderEntity():
|
||||
if provider.plugin_id:
|
||||
if isinstance(provider.declaration.identity.icon, str):
|
||||
provider.declaration.identity.icon = PluginService.get_plugin_icon_url(
|
||||
tenant_id=tenant_id, filename=provider.declaration.identity.icon
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def builtin_provider_to_user_provider(
|
||||
|
||||
Reference in New Issue
Block a user