Delete a saved UI template. Args: template_id: The ID of the template to delete
(template_id: str, runtime: ToolRuntime)
| 216 | |
| 217 | @tool |
| 218 | def delete_template(template_id: str, runtime: ToolRuntime) -> Command: |
| 219 | """ |
| 220 | Delete a saved UI template. |
| 221 | |
| 222 | Args: |
| 223 | template_id: The ID of the template to delete |
| 224 | """ |
| 225 | templates = list(runtime.state.get("templates", [])) |
| 226 | original_len = len(templates) |
| 227 | templates = [t for t in templates if t["id"] != template_id] |
| 228 | |
| 229 | if len(templates) == original_len: |
| 230 | return Command(update={ |
| 231 | "messages": [ |
| 232 | ToolMessage( |
| 233 | content=f"Template with id '{template_id}' not found", |
| 234 | tool_call_id=runtime.tool_call_id, |
| 235 | ) |
| 236 | ], |
| 237 | }) |
| 238 | |
| 239 | return Command(update={ |
| 240 | "templates": templates, |
| 241 | "messages": [ |
| 242 | ToolMessage( |
| 243 | content=f"Template deleted successfully", |
| 244 | tool_call_id=runtime.tool_call_id, |
| 245 | ) |
| 246 | ], |
| 247 | }) |
| 248 | |
| 249 | |
| 250 | @tool |
nothing calls this directly
no outgoing calls
no test coverage detected