feat(project): 项目完结
This commit is contained in:
29
internal/domain/agent/service/armory/agent_node.go
Normal file
29
internal/domain/agent/service/armory/agent_node.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package armory
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ai-agent-scaffold-go/internal/domain/agent/model"
|
||||
"ai-agent-scaffold-go/internal/domain/agent/ports"
|
||||
"ai-agent-scaffold-go/internal/domain/shared/tree"
|
||||
)
|
||||
|
||||
type AgentNode struct {
|
||||
agentFactory ports.AgentFactory
|
||||
next Handler
|
||||
}
|
||||
|
||||
func NewAgentNode(agentFactory ports.AgentFactory, next Handler) AgentNode {
|
||||
return AgentNode{agentFactory: agentFactory, next: next}
|
||||
}
|
||||
|
||||
func (n AgentNode) Apply(ctx context.Context, command model.ArmoryCommand, dynamic *DynamicContext) (model.RegisteredAgent, error) {
|
||||
for _, config := range command.Table.Module.Agents {
|
||||
agent, err := n.agentFactory.NewLLMAgent(ctx, config, dynamic.ChatModel)
|
||||
if err != nil {
|
||||
return model.RegisteredAgent{}, err
|
||||
}
|
||||
dynamic.AddAgent(agent)
|
||||
}
|
||||
return tree.Route(ctx, n.next, command, dynamic)
|
||||
}
|
||||
Reference in New Issue
Block a user