Documentation
¶
Overview ¶
Package nmemory provides the Memory node implementation for flow execution. Memory nodes are passive configuration providers that supply conversation history to connected AI Agent nodes via HandleAiMemory edges.
Index ¶
- type Message
- type NodeMemory
- func (n *NodeMemory) AddMessage(role, content string)
- func (n *NodeMemory) Clear()
- func (n *NodeMemory) GetID() idwrap.IDWrap
- func (n *NodeMemory) GetMessages() []Message
- func (n *NodeMemory) GetName() string
- func (n *NodeMemory) Len() int
- func (n *NodeMemory) RunAsync(ctx context.Context, req *node.FlowNodeRequest, ...)
- func (n *NodeMemory) RunSync(_ context.Context, req *node.FlowNodeRequest) node.FlowNodeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NodeMemory ¶
type NodeMemory struct {
FlowNodeID idwrap.IDWrap
Name string
MemoryType mflow.AiMemoryType
WindowSize int32
Messages []Message
// contains filtered or unexported fields
}
NodeMemory represents a Memory node that provides conversation history to AI Agent nodes. It is a passive node - it does not execute but provides and manages conversation memory when discovered by AI nodes via HandleAiMemory edges.
func New ¶
func New( id idwrap.IDWrap, name string, memoryType mflow.AiMemoryType, windowSize int32, ) *NodeMemory
New creates a new NodeMemory with the given configuration. For WindowBuffer memory type, windowSize must be at least 1. Invalid windowSize values are automatically corrected to a minimum of 1.
func (*NodeMemory) AddMessage ¶
func (n *NodeMemory) AddMessage(role, content string)
AddMessage appends a message to the conversation history. For WindowBuffer memory type, it enforces the window size limit by removing the oldest messages when the limit is exceeded.
func (*NodeMemory) GetID ¶
func (n *NodeMemory) GetID() idwrap.IDWrap
GetID returns the node's unique identifier.
func (*NodeMemory) GetMessages ¶
func (n *NodeMemory) GetMessages() []Message
GetMessages returns a copy of the current conversation history. Returns a copy to prevent concurrent modification issues.
func (*NodeMemory) GetName ¶
func (n *NodeMemory) GetName() string
GetName returns the node's display name.
func (*NodeMemory) Len ¶
func (n *NodeMemory) Len() int
Len returns the current number of messages in the history.
func (*NodeMemory) RunAsync ¶
func (n *NodeMemory) RunAsync(ctx context.Context, req *node.FlowNodeRequest, resultChan chan node.FlowNodeResult)
RunAsync runs the node asynchronously by calling RunSync and sending the result.
func (*NodeMemory) RunSync ¶
func (n *NodeMemory) RunSync(_ context.Context, req *node.FlowNodeRequest) node.FlowNodeResult
RunSync is a no-op for Memory nodes. Memory nodes are passive state containers and do not execute directly. They are discovered by AI Agent nodes via HandleAiMemory edges.