From a3423f33e1e2e611d44823ba17560a43d2c1d431 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 30 Nov 2025 14:09:25 +0100 Subject: [PATCH] feat(agent-jobs): add multimedia support (#7398) * feat(agent-jobs): add multimedia support Signed-off-by: Ettore Di Giacinto * Refactoring Signed-off-by: Ettore Di Giacinto --------- Signed-off-by: Ettore Di Giacinto --- core/http/endpoints/localai/agent_jobs.go | 18 +- core/http/views/agent-jobs.html | 145 ++++++++++- core/http/views/agent-task-details.html | 257 ++++++++++++++++++-- core/http/views/backends.html | 5 +- core/http/views/chat.html | 5 +- core/http/views/models.html | 5 +- core/http/views/text2image.html | 5 +- core/schema/agent_jobs.go | 32 +++ core/services/agent_jobs.go | 208 +++++++++++++++- core/services/agent_jobs_test.go | 280 +++++++++++++++++++++- 10 files changed, 913 insertions(+), 47 deletions(-) diff --git a/core/http/endpoints/localai/agent_jobs.go b/core/http/endpoints/localai/agent_jobs.go index 0e65a241d..c46a0208a 100644 --- a/core/http/endpoints/localai/agent_jobs.go +++ b/core/http/endpoints/localai/agent_jobs.go @@ -147,7 +147,18 @@ func ExecuteJobEndpoint(app *application.Application) echo.HandlerFunc { req.Parameters = make(map[string]string) } - jobID, err := app.AgentJobService().ExecuteJob(req.TaskID, req.Parameters, "api") + // Build multimedia struct from request + var multimedia *schema.MultimediaAttachment + if len(req.Images) > 0 || len(req.Videos) > 0 || len(req.Audios) > 0 || len(req.Files) > 0 { + multimedia = &schema.MultimediaAttachment{ + Images: req.Images, + Videos: req.Videos, + Audios: req.Audios, + Files: req.Files, + } + } + + jobID, err := app.AgentJobService().ExecuteJob(req.TaskID, req.Parameters, "api", multimedia) if err != nil { return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()}) } @@ -281,7 +292,7 @@ func ExecuteTaskByNameEndpoint(app *application.Application) echo.HandlerFunc { return func(c echo.Context) error { name := c.Param("name") var params map[string]string - + // Try to bind parameters from request body // If body is empty or invalid, use empty params if c.Request().ContentLength > 0 { @@ -323,7 +334,7 @@ func ExecuteTaskByNameEndpoint(app *application.Application) echo.HandlerFunc { return c.JSON(http.StatusNotFound, map[string]string{"error": "Task not found: " + name}) } - jobID, err := app.AgentJobService().ExecuteJob(task.ID, params, "api") + jobID, err := app.AgentJobService().ExecuteJob(task.ID, params, "api", nil) if err != nil { return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()}) } @@ -336,4 +347,3 @@ func ExecuteTaskByNameEndpoint(app *application.Application) echo.HandlerFunc { }) } } - diff --git a/core/http/views/agent-jobs.html b/core/http/views/agent-jobs.html index b650e1a4c..a439f6bd2 100644 --- a/core/http/views/agent-jobs.html +++ b/core/http/views/agent-jobs.html @@ -365,21 +365,40 @@ x-cloak @click.away="showExecuteTaskModal = false; selectedTaskForExecution = null; executionParameters = {}; executionParametersText = ''" class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"> -
-
+
+

Execute Task

-