fix: api tool encoding (#2296)

This commit is contained in:
Yeuoly
2024-01-30 22:22:58 +08:00
committed by GitHub
parent 0a4dfaeaf9
commit 6d24a2cb87
3 changed files with 29 additions and 6 deletions

View File

@@ -485,10 +485,10 @@ class ToolManageService:
if schema_type not in [member.value for member in ApiProviderSchemaType]:
raise ValueError(f'invalid schema type {schema_type}')
if schema_type == ApiProviderSchemaType.OPENAPI.value:
tool_bundles = ApiBasedToolSchemaParser.parse_openapi_yaml_to_tool_bundle(schema)
else:
raise ValueError(f'invalid schema type {schema_type}')
try:
tool_bundles, _ = ApiBasedToolSchemaParser.auto_parse_to_tool_bundle(schema)
except Exception as e:
raise ValueError(f'invalid schema')
# get tool bundle
tool_bundle = next(filter(lambda tb: tb.operation_id == tool_name, tool_bundles), None)