MCPcopy
hub / github.com/mudler/LocalAI / DeleteTaskEndpoint

Function DeleteTaskEndpoint

core/http/endpoints/localai/agent_jobs.go:96–108  ·  view source on GitHub ↗

DeleteTaskEndpoint deletes an agent task. @Summary Delete an agent task @Tags agent-jobs @Produce json @Param id path string true "Task ID" @Success 200 {object} map[string]string "message" @Failure 404 {object} map[string]string "error" @Router /api/agent/tasks/{id} [delete]

(app *application.Application)

Source from the content-addressed store, hash-verified

94// @Failure 404 {object} map[string]string "error"
95// @Router /api/agent/tasks/{id} [delete]
96func DeleteTaskEndpoint(app *application.Application) echo.HandlerFunc {
97 return func(c echo.Context) error {
98 id := c.Param("id")
99 if err := getJobService(app, c).DeleteTask(id); err != nil {
100 if errors.Is(err, agentpool.ErrTaskNotFound) {
101 return c.JSON(http.StatusNotFound, map[string]string{"error": err.Error()})
102 }
103 return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
104 }
105
106 return c.JSON(http.StatusOK, map[string]string{"message": "Task deleted"})
107 }
108}
109
110// ListTasksEndpoint lists all agent tasks for the current user.
111// @Summary List agent tasks

Callers 1

RegisterLocalAIRoutesFunction · 0.92

Calls 5

getJobServiceFunction · 0.85
JSONMethod · 0.80
DeleteTaskMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected