Unverified Commit f8951d7f authored by Yeuoly's avatar Yeuoly Committed by GitHub

fix: api tool provider not found (#2782)

parent 6454e1d6
...@@ -247,27 +247,30 @@ class AppApi(Resource): ...@@ -247,27 +247,30 @@ class AppApi(Resource):
for tool in agent_mode.get('tools') or []: for tool in agent_mode.get('tools') or []:
agent_tool_entity = AgentToolEntity(**tool) agent_tool_entity = AgentToolEntity(**tool)
# get tool # get tool
tool_runtime = ToolManager.get_agent_tool_runtime( try:
tenant_id=current_user.current_tenant_id, tool_runtime = ToolManager.get_agent_tool_runtime(
agent_tool=agent_tool_entity, tenant_id=current_user.current_tenant_id,
agent_callback=None agent_tool=agent_tool_entity,
) agent_callback=None
manager = ToolParameterConfigurationManager( )
tenant_id=current_user.current_tenant_id, manager = ToolParameterConfigurationManager(
tool_runtime=tool_runtime, tenant_id=current_user.current_tenant_id,
provider_name=agent_tool_entity.provider_id, tool_runtime=tool_runtime,
provider_type=agent_tool_entity.provider_type, provider_name=agent_tool_entity.provider_id,
) provider_type=agent_tool_entity.provider_type,
)
# get decrypted parameters # get decrypted parameters
if agent_tool_entity.tool_parameters: if agent_tool_entity.tool_parameters:
parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {}) parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {})
masked_parameter = manager.mask_tool_parameters(parameters or {}) masked_parameter = manager.mask_tool_parameters(parameters or {})
else: else:
masked_parameter = {} masked_parameter = {}
# override tool parameters # override tool parameters
tool['tool_parameters'] = masked_parameter tool['tool_parameters'] = masked_parameter
except Exception as e:
pass
# override agent mode # override agent mode
model_config.agent_mode = json.dumps(agent_mode) model_config.agent_mode = json.dumps(agent_mode)
......
...@@ -54,17 +54,20 @@ class ModelConfigResource(Resource): ...@@ -54,17 +54,20 @@ class ModelConfigResource(Resource):
for tool in agent_mode.get('tools') or []: for tool in agent_mode.get('tools') or []:
agent_tool_entity = AgentToolEntity(**tool) agent_tool_entity = AgentToolEntity(**tool)
# get tool # get tool
tool_runtime = ToolManager.get_agent_tool_runtime( try:
tenant_id=current_user.current_tenant_id, tool_runtime = ToolManager.get_agent_tool_runtime(
agent_tool=agent_tool_entity, tenant_id=current_user.current_tenant_id,
agent_callback=None agent_tool=agent_tool_entity,
) agent_callback=None
manager = ToolParameterConfigurationManager( )
tenant_id=current_user.current_tenant_id, manager = ToolParameterConfigurationManager(
tool_runtime=tool_runtime, tenant_id=current_user.current_tenant_id,
provider_name=agent_tool_entity.provider_id, tool_runtime=tool_runtime,
provider_type=agent_tool_entity.provider_type, provider_name=agent_tool_entity.provider_id,
) provider_type=agent_tool_entity.provider_type,
)
except Exception as e:
continue
# get decrypted parameters # get decrypted parameters
if agent_tool_entity.tool_parameters: if agent_tool_entity.tool_parameters:
...@@ -89,11 +92,14 @@ class ModelConfigResource(Resource): ...@@ -89,11 +92,14 @@ class ModelConfigResource(Resource):
if key in tool_map: if key in tool_map:
tool_runtime = tool_map[key] tool_runtime = tool_map[key]
else: else:
tool_runtime = ToolManager.get_agent_tool_runtime( try:
tenant_id=current_user.current_tenant_id, tool_runtime = ToolManager.get_agent_tool_runtime(
agent_tool=agent_tool_entity, tenant_id=current_user.current_tenant_id,
agent_callback=None agent_tool=agent_tool_entity,
) agent_callback=None
)
except Exception as e:
continue
manager = ToolParameterConfigurationManager( manager = ToolParameterConfigurationManager(
tenant_id=current_user.current_tenant_id, tenant_id=current_user.current_tenant_id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment