Verify tools, raise error if any tool is invalid :param tools: the tools :return: None
(tools: List[ToolRef])
| 16 | |
| 17 | |
| 18 | async def verify_tools(tools: List[ToolRef]): |
| 19 | """ |
| 20 | Verify tools, raise error if any tool is invalid |
| 21 | :param tools: the tools |
| 22 | :return: None |
| 23 | """ |
| 24 | |
| 25 | for tool in tools: |
| 26 | if tool.type == "action": |
| 27 | await action_ops.get(action_id=tool.id) |
| 28 | |
| 29 | elif tool.type == "plugin": |
| 30 | if "/" not in tool.id: |
| 31 | raise_request_validation_error(f"Invalid plugin tool ID: {tool.id}") |
| 32 | bundle_instance_id, plugin_id = tool.id.split("/") |
| 33 | bundle: BundleInstance = await bundle_instance_ops.get(bundle_instance_id=bundle_instance_id) |
| 34 | get_plugin(bundle_id=bundle.bundle_id, plugin_id=plugin_id) |
| 35 | |
| 36 | else: |
| 37 | raise_request_validation_error(f"Invalid tool type: {tool.type}") |
| 38 | |
| 39 | |
| 40 | async def fetch_tools(tool_refs: List[ToolRef]) -> List[Tool]: |
no test coverage detected