Feat/api tool custom timeout (#3420)

This commit is contained in:
Yeuoly 2024-04-12 17:46:39 +08:00 committed by GitHub
parent 25dea232d6
commit ae1f3780f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -149,3 +149,7 @@ TEMPLATE_TRANSFORM_MAX_LENGTH=80000
CODE_MAX_STRING_ARRAY_LENGTH=30 CODE_MAX_STRING_ARRAY_LENGTH=30
CODE_MAX_OBJECT_ARRAY_LENGTH=30 CODE_MAX_OBJECT_ARRAY_LENGTH=30
CODE_MAX_NUMBER_ARRAY_LENGTH=1000 CODE_MAX_NUMBER_ARRAY_LENGTH=1000
# API Tool configuration
API_TOOL_DEFAULT_CONNECT_TIMEOUT=10
API_TOOL_DEFAULT_READ_TIMEOUT=60

View File

@ -1,5 +1,6 @@
import json import json
from json import dumps from json import dumps
from os import getenv
from typing import Any, Union from typing import Any, Union
from urllib.parse import urlencode from urllib.parse import urlencode
@ -13,7 +14,10 @@ from core.tools.entities.user_entities import UserToolProvider
from core.tools.errors import ToolInvokeError, ToolParameterValidationError, ToolProviderCredentialValidationError from core.tools.errors import ToolInvokeError, ToolParameterValidationError, ToolProviderCredentialValidationError
from core.tools.tool.tool import Tool from core.tools.tool.tool import Tool
API_TOOL_DEFAULT_TIMEOUT = (10, 60) API_TOOL_DEFAULT_TIMEOUT = (
int(getenv('API_TOOL_DEFAULT_CONNECT_TIMEOUT', '10')),
int(getenv('API_TOOL_DEFAULT_READ_TIMEOUT', '60'))
)
class ApiTool(Tool): class ApiTool(Tool):
api_bundle: ApiBasedToolBundle api_bundle: ApiBasedToolBundle