MCPcopy Create free account
hub / github.com/CopilotKit/OpenGenerativeUI / delete_template

Function delete_template

apps/agent/src/templates.py:218–247  ·  view source on GitHub ↗

Delete a saved UI template. Args: template_id: The ID of the template to delete

(template_id: str, runtime: ToolRuntime)

Source from the content-addressed store, hash-verified

216
217@tool
218def 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected