feat(agents): Create group of agents (#82)

* feat(ui): add section to create agents in group

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Enhance UX and do not display first form section

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fixups

* Small fixups on avatar creation

---------

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-03-22 21:41:51 +01:00
committed by GitHub
parent 3a921f6241
commit 3a9169bdbe
5 changed files with 648 additions and 13 deletions

View File

@@ -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")
}
}