This commit is contained in:
Ethan T. 2026-03-24 08:44:37 +08:00 committed by GitHub
commit b738f66472
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 8 deletions

View File

@ -163,7 +163,7 @@ class MCPAppApi(Resource):
def _create_variable_entity(self, item: dict) -> VariableEntity:
"""Create a single VariableEntity from raw form item"""
variable_type = item.get("type", "") or list(item.keys())[0]
variable_type = item.get("type", "") or next(iter(item), "")
variable = item[variable_type]
return VariableEntity(

View File

@ -54,7 +54,7 @@ class DatasetConfigManager:
for tool in agent_dict.get("tools", []):
if len(tool) == 1:
# old standard
key = list(tool.keys())[0]
key = next(iter(tool))
if key != "dataset":
continue
@ -211,7 +211,9 @@ class DatasetConfigManager:
PlanningStrategy.REACT_ROUTER,
}:
for tool in config.get("agent_mode", {}).get("tools", []):
key = list(tool.keys())[0]
if not tool:
continue
key = next(iter(tool))
if key == "dataset":
# old style, use tool name as key
tool_item = tool[key]

View File

@ -45,7 +45,9 @@ class BasicVariablesConfigManager:
# variables and external_data_tools
for variables in config.get("user_input_form", []):
variable_type = list(variables.keys())[0]
if not variables:
continue
variable_type = next(iter(variables))
if variable_type == VariableEntityType.EXTERNAL_DATA_TOOL:
variable = variables[variable_type]
if "config" not in variable:
@ -112,7 +114,9 @@ class BasicVariablesConfigManager:
variables = []
for item in config["user_input_form"]:
key = list(item.keys())[0]
if not item:
continue
key = next(iter(item))
# if key not in {"text-input", "select", "paragraph", "number", "external_data_tool"}:
if key not in {
VariableEntityType.TEXT_INPUT,

View File

@ -200,7 +200,9 @@ class AgentChatAppConfigManager(BaseAppConfigManager):
raise ValueError("tools in agent_mode must be a list of objects")
for tool in agent_mode["tools"]:
key = list(tool.keys())[0]
if not tool:
continue
key = next(iter(tool))
if key in OLD_TOOLS:
# old style, use tool name as key
tool_item = tool[key]

View File

@ -55,8 +55,8 @@ def get_dataset_ids_from_model_config(app_model_config: AppModelConfig) -> set[s
if len(list(tool.keys())) != 1:
continue
tool_type = list(tool.keys())[0]
tool_config = cast(dict[str, Any], list(tool.values())[0])
tool_type = next(iter(tool))
tool_config = cast(dict[str, Any], next(iter(tool.values())))
if tool_type == "dataset":
dataset_id = tool_config.get("id")
if isinstance(dataset_id, str):