From bf2268b0af275a7fa6d7ec1d7463070c47ec1a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Fri, 5 Jul 2024 17:11:59 +0800 Subject: [PATCH] fix API tool's schema not support array (#6006) --- api/core/tools/tool/api_tool.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/core/tools/tool/api_tool.py b/api/core/tools/tool/api_tool.py index 0448a5df0c..c8b683f9ef 100644 --- a/api/core/tools/tool/api_tool.py +++ b/api/core/tools/tool/api_tool.py @@ -249,9 +249,12 @@ class ApiTool(Tool): elif property['type'] == 'null': if value is None: return None - elif property['type'] == 'object': + elif property['type'] == 'object' or property['type'] == 'array': if isinstance(value, str): try: + # an array str like '[1,2]' also can convert to list [1,2] through json.loads + # json not support single quote, but we can support it + value = value.replace("'", '"') return json.loads(value) except ValueError: return value