Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: api tool provider not found (#2782)

Yeuolyf8951d7f57a0
diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py
index 4b648a4e287..fb697b6418a 100644
--- a/api/controllers/console/app/app.py
+++ b/api/controllers/console/app/app.py
@@ -247,27 +247,30 @@ class AppApi(Resource):
for tool in agent_mode.get('tools') or []:
agent_tool_entity = AgentToolEntity(**tool)
# get tool
- tool_runtime = ToolManager.get_agent_tool_runtime(
- tenant_id=current_user.current_tenant_id,
- agent_tool=agent_tool_entity,
- agent_callback=None
- )
- manager = ToolParameterConfigurationManager(
- tenant_id=current_user.current_tenant_id,
- tool_runtime=tool_runtime,
- provider_name=agent_tool_entity.provider_id,
- provider_type=agent_tool_entity.provider_type,
- )
+ try:
+ tool_runtime = ToolManager.get_agent_tool_runtime(
+ tenant_id=current_user.current_tenant_id,
+ agent_tool=agent_tool_entity,
+ agent_callback=None
+ )
+ manager = ToolParameterConfigurationManager(
+ tenant_id=current_user.current_tenant_id,
+ tool_runtime=tool_runtime,
+ provider_name=agent_tool_entity.provider_id,
+ provider_type=agent_tool_entity.provider_type,
+ )
- # get decrypted parameters
- if agent_tool_entity.tool_parameters:
- parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {})
- masked_parameter = manager.mask_tool_parameters(parameters or {})
- else:
- masked_parameter = {}
+ # get decrypted parameters
+ if agent_tool_entity.tool_parameters:
+ parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {})
+ masked_parameter = manager.mask_tool_parameters(parameters or {})
+ else:
+ masked_parameter = {}
- # override tool parameters
- tool['tool_parameters'] = masked_parameter
+ # override tool parameters
+ tool['tool_parameters'] = masked_parameter
+ except Exception as e:
+ pass
# override agent mode
model_config.agent_mode = json.dumps(agent_mode)
diff --git a/api/controllers/console/app/model_config.py b/api/controllers/console/app/model_config.py
index 117007d055a..436f8c14478 100644
--- a/api/controllers/console/app/model_config.py
+++ b/api/controllers/console/app/model_config.py
@@ -54,17 +54,20 @@ class ModelConfigResource(Resource):
for tool in agent_mode.get('tools') or []:
agent_tool_entity = AgentToolEntity(**tool)
# get tool
- tool_runtime = ToolManager.get_agent_tool_runtime(
- tenant_id=current_user.current_tenant_id,
- agent_tool=agent_tool_entity,
- agent_callback=None
- )
- manager = ToolParameterConfigurationManager(
- tenant_id=current_user.current_tenant_id,
- tool_runtime=tool_runtime,
- provider_name=agent_tool_entity.provider_id,
- provider_type=agent_tool_entity.provider_type,
- )
+ try:
+ tool_runtime = ToolManager.get_agent_tool_runtime(
+ tenant_id=current_user.current_tenant_id,
+ agent_tool=agent_tool_entity,
+ agent_callback=None
+ )
+ manager = ToolParameterConfigurationManager(
+ tenant_id=current_user.current_tenant_id,
+ tool_runtime=tool_runtime,
+ provider_name=agent_tool_entity.provider_id,
+ provider_type=agent_tool_entity.provider_type,
+ )
+ except Exception as e:
+ continue
# get decrypted parameters
if agent_tool_entity.tool_parameters:
@@ -89,11 +92,14 @@ class ModelConfigResource(Resource):
if key in tool_map:
tool_runtime = tool_map[key]
else:
- tool_runtime = ToolManager.get_agent_tool_runtime(
- tenant_id=current_user.current_tenant_id,
- agent_tool=agent_tool_entity,
- agent_callback=None
- )
+ try:
+ tool_runtime = ToolManager.get_agent_tool_runtime(
+ tenant_id=current_user.current_tenant_id,
+ agent_tool=agent_tool_entity,
+ agent_callback=None
+ )
+ except Exception as e:
+ continue
manager = ToolParameterConfigurationManager(
tenant_id=current_user.current_tenant_id,