Fixes you have not added provider None (#10501)

This commit is contained in:
smyhw 2024-11-11 21:50:32 +08:00 committed by GitHub
parent 570f10d91c
commit f19c18dc14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -555,6 +555,7 @@ class ToolManager:
"""
get tool provider
"""
provider_name = provider
provider: ApiToolProvider = (
db.session.query(ApiToolProvider)
.filter(
@ -565,7 +566,7 @@ class ToolManager:
)
if provider is None:
raise ValueError(f"you have not added provider {provider}")
raise ValueError(f"you have not added provider {provider_name}")
try:
credentials = json.loads(provider.credentials_str) or {}

View File

@ -113,6 +113,8 @@ class ApiToolManageService:
if schema_type not in [member.value for member in ApiProviderSchemaType]:
raise ValueError(f"invalid schema type {schema}")
provider_name = provider_name.strip()
# check if the provider exists
provider: ApiToolProvider = (
db.session.query(ApiToolProvider)
@ -203,6 +205,7 @@ class ApiToolManageService:
"""
list api tool provider tools
"""
provider_name = provider
provider: ApiToolProvider = (
db.session.query(ApiToolProvider)
.filter(
@ -213,7 +216,7 @@ class ApiToolManageService:
)
if provider is None:
raise ValueError(f"you have not added provider {provider}")
raise ValueError(f"you have not added provider {provider_name}")
controller = ToolTransformService.api_provider_to_controller(db_provider=provider)
labels = ToolLabelManager.get_tool_labels(controller)
@ -246,6 +249,8 @@ class ApiToolManageService:
if schema_type not in [member.value for member in ApiProviderSchemaType]:
raise ValueError(f"invalid schema type {schema}")
provider_name = provider_name.strip()
# check if the provider exists
provider: ApiToolProvider = (
db.session.query(ApiToolProvider)