fix select tools

pull/17608/head
fuwx 1 year ago
parent aa14568947
commit ddab8771f2
No known key found for this signature in database
GPG Key ID: C8FA8C18DFB4702B

@ -589,6 +589,7 @@ class APOToolBuiltinListApi(Resource):
parser = reqparse.RequestParser() parser = reqparse.RequestParser()
parser.add_argument("tool_type", type=str, required=True, nullable=False, location="args") parser.add_argument("tool_type", type=str, required=True, nullable=False, location="args")
parser.add_argument("query", type=str, required=False, nullable=True, location="args") parser.add_argument("query", type=str, required=False, nullable=True, location="args")
parser.add_argument("language", type=int, required=False, nullable=True, location="args")
args = parser.parse_args() args = parser.parse_args()
@ -600,6 +601,7 @@ class APOToolBuiltinListApi(Resource):
tenant_id, tenant_id,
args["tool_type"], args["tool_type"],
args.get("query", None), args.get("query", None),
args.get("language", "zh")
) )
] ]
) )

@ -289,7 +289,7 @@ class BuiltinToolManageService:
return BuiltinToolProviderSort.sort(result) return BuiltinToolProviderSort.sort(result)
@staticmethod @staticmethod
def list_apo_tools(user_id: str, tenant_id: str, tool_type: str, query: str|None) -> list[ToolProviderApiEntity]: def list_apo_tools(user_id: str, tenant_id: str, tool_type: str, query: str|None, language: str) -> list[ToolProviderApiEntity]:
""" """
list apo tools list apo tools
""" """
@ -348,9 +348,14 @@ class BuiltinToolManageService:
) )
) )
else: else:
if language == "zh":
match_raw = [tool.entity.identity.label.zh_Hans for tool in tools]
else:
match_raw = [tool.entity.identity.label.en_US for tool in tools]
match_tools = process.extract( match_tools = process.extract(
query, query,
[tool.entity.identity.label.zh_Hans for tool in tools], match_raw,
limit=50, limit=50,
) )
for match_name, score, index in match_tools or []: for match_name, score, index in match_tools or []:
@ -368,7 +373,7 @@ class BuiltinToolManageService:
except Exception as e: except Exception as e:
raise e raise e
return BuiltinToolProviderSort.sort(result) return result
@staticmethod @staticmethod
def list_all_apo_tools(user_id: str, tenant_id: str) -> list[ToolProviderApiEntity]: def list_all_apo_tools(user_id: str, tenant_id: str) -> list[ToolProviderApiEntity]:

Loading…
Cancel
Save