diff --git a/core/state/pool.go b/core/state/pool.go index 12654f3..c5deb75 100644 --- a/core/state/pool.go +++ b/core/state/pool.go @@ -149,6 +149,7 @@ func (a *AgentPool) CreateAgent(name string, agentConfig *AgentConfig) error { a.Lock() defer a.Unlock() name = replaceInvalidChars(name) + agentConfig.Name = name if _, ok := a.pool[name]; ok { return fmt.Errorf("agent %s already exists", name) } @@ -157,17 +158,17 @@ func (a *AgentPool) CreateAgent(name string, agentConfig *AgentConfig) error { return err } - go func() { + go func(ac AgentConfig) { // Create the agent avatar - if err := a.createAgentAvatar(agentConfig); err != nil { + if err := a.createAgentAvatar(ac); err != nil { xlog.Error("Failed to create agent avatar", "error", err) } - }() + }(*agentConfig) return a.startAgentWithConfig(name, agentConfig) } -func (a *AgentPool) createAgentAvatar(agent *AgentConfig) error { +func (a *AgentPool) createAgentAvatar(agent AgentConfig) error { client := llm.NewClient(a.apiKey, a.apiURL+"/v1", "10m") if a.imageModel == "" { diff --git a/webui/app.go b/webui/app.go index c62a7fa..141755b 100644 --- a/webui/app.go +++ b/webui/app.go @@ -405,7 +405,7 @@ type AgentRole struct { SystemPrompt string `json:"system_prompt"` } -func (a *App) CreateGroup(pool *state.AgentPool) func(c *fiber.Ctx) error { +func (a *App) GenerateGroupProfiles(pool *state.AgentPool) func(c *fiber.Ctx) error { return func(c *fiber.Ctx) error { var request struct { Descript string `json:"description"` @@ -451,18 +451,32 @@ func (a *App) CreateGroup(pool *state.AgentPool) func(c *fiber.Ctx) error { return errorJSONMessage(c, err.Error()) } - for _, agent := range results.Agents { + return c.JSON(results.Agents) + } +} + +func (a *App) CreateGroup(pool *state.AgentPool) func(c *fiber.Ctx) error { + return func(c *fiber.Ctx) error { + + var config struct { + Agents []AgentRole `json:"agents"` + AgentConfig state.AgentConfig `json:"agent_config"` + } + if err := c.BodyParser(&config); err != nil { + return errorJSONMessage(c, err.Error()) + } + + agentConfig := &config.AgentConfig + for _, agent := range config.Agents { xlog.Info("Creating agent", "name", agent.Name, "description", agent.Description) - config := state.AgentConfig{ - Name: agent.Name, - Description: agent.Description, - SystemPrompt: agent.SystemPrompt, - } - if err := pool.CreateAgent(agent.Name, &config); err != nil { + agentConfig.Name = agent.Name + agentConfig.Description = agent.Description + agentConfig.SystemPrompt = agent.SystemPrompt + if err := pool.CreateAgent(agent.Name, agentConfig); err != nil { return errorJSONMessage(c, err.Error()) } } - return c.JSON(results) + return statusJSONMessage(c, "ok") } } diff --git a/webui/routes.go b/webui/routes.go index 09f9119..29836fa 100644 --- a/webui/routes.go +++ b/webui/routes.go @@ -142,6 +142,14 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) { return c.Render("views/actions", fiber.Map{}) }) + webapp.Get("/group-create", func(c *fiber.Ctx) error { + return c.Render("views/group-create", fiber.Map{ + "Actions": services.AvailableActions, + "Connectors": services.AvailableConnectors, + "PromptBlocks": services.AvailableBlockPrompts, + }) + }) + // New API endpoints for getting and updating agent configuration webapp.Get("/api/agent/:name/config", app.GetAgentConfig(pool)) webapp.Put("/api/agent/:name/config", app.UpdateAgentConfig(pool)) @@ -149,6 +157,7 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) { webapp.Post("/action/:name/run", app.ExecuteAction(pool)) webapp.Get("/actions", app.ListActions()) + webapp.Post("/api/agent/group/generateProfiles", app.GenerateGroupProfiles(pool)) webapp.Post("/api/agent/group/create", app.CreateGroup(pool)) webapp.Post("/settings/import", app.ImportAgent(pool)) diff --git a/webui/views/group-create.html b/webui/views/group-create.html new file mode 100644 index 0000000..ad596ba --- /dev/null +++ b/webui/views/group-create.html @@ -0,0 +1,599 @@ + + + + Create Agent Group + {{template "views/partials/header"}} + + + + + + + {{template "views/partials/menu"}} +
+
+

Create Agent Group

+ + +
+
+
1
+
Generate Profiles
+
+
+
2
+
Review & Select
+
+
+
3
+
Configure Settings
+
+
+ + +
+

Generate Agent Profiles

+

Describe the group of agents you want to create. Be specific about their roles, relationships, and purpose.

+ +
+ +
+ +
+ +
+
+ + +
+ +

Generating agent profiles...

+
+ + +
+

Review & Select Agent Profiles

+

Select the agents you want to create. You can customize their details before creation.

+ +
+ +
+ +
+ +
+ +
+ + +
+
+ + +
+

Configure Common Settings

+

Configure common settings for all selected agents. These settings will be applied to each agent.

+ +
+ +
+ +
+

Basic Information from Profiles

+

The name, description, and system prompt for each agent will be taken from the profiles you selected in the previous step.

+
+
+ + +
+ {{template "views/partials/agent-form" . }} +
+
+ +
+ + +
+
+
+ + +
+ + + + +
+
+ + +
+ +
+ + + + \ No newline at end of file diff --git a/webui/views/partials/menu.html b/webui/views/partials/menu.html index 92c8c7f..84eaaed 100644 --- a/webui/views/partials/menu.html +++ b/webui/views/partials/menu.html @@ -39,6 +39,12 @@ + + Create Agent Group + + + @@ -80,6 +86,12 @@ + + Create Agent Group + + +