Load all submodule tools defined in a YAML file. Returns: Tuple of (tools list, registry dict mapping function name to spec)
(
yaml_data: Dict[str, Any],
yaml_file_path: str,
)
| 157 | |
| 158 | |
| 159 | def load_submodule_tools_for_yaml( |
| 160 | yaml_data: Dict[str, Any], |
| 161 | yaml_file_path: str, |
| 162 | ) -> Tuple[List[Dict[str, Any]], Dict[str, SubmoduleFunctionSpec]]: |
| 163 | """ |
| 164 | Load all submodule tools defined in a YAML file. |
| 165 | |
| 166 | Returns: |
| 167 | Tuple of (tools list, registry dict mapping function name to spec) |
| 168 | """ |
| 169 | submodules = normalize_submodule_declarations(yaml_data, yaml_file_path) |
| 170 | if not submodules: |
| 171 | return [], {} |
| 172 | |
| 173 | tools: List[Dict[str, Any]] = [] |
| 174 | registry: Dict[str, SubmoduleFunctionSpec] = {} |
| 175 | parser = YAMLTaskParser() |
| 176 | |
| 177 | for entry in submodules: |
| 178 | declared_name = entry.get("name") |
| 179 | module_path = entry["path"] |
| 180 | module_yaml = parser.load_task(module_path) |
| 181 | spec = parse_submodule_function_declaration( |
| 182 | module_yaml, module_path, declared_name=declared_name |
| 183 | ) |
| 184 | if spec.name in registry: |
| 185 | raise ValueError(f"Duplicate submodule function name: {spec.name}") |
| 186 | registry[spec.name] = spec |
| 187 | tools.append(build_submodule_tool(spec)) |
| 188 | |
| 189 | return tools, registry |