Class: HTM::Workflows::RememberWorkflow

Inherits:
Object
  • Object
show all
Defined in:
lib/htm/workflows/remember_workflow.rb

Overview

RememberWorkflow orchestrates the parallel processing of node enrichment

Uses simple_flow to manage the dependency graph and parallel execution of embedding generation, tag extraction, and proposition extraction.

The workflow structure:

save_node (no deps) -> embedding, tags, propositions (parallel)

Examples:

Basic usage with fiber concurrency

workflow = HTM::Workflows::RememberWorkflow.new(htm_instance)
node_id = workflow.call(content: "PostgreSQL is great", tags: ["database"])

With inline execution (for testing)

workflow = HTM::Workflows::RememberWorkflow.new(htm_instance, concurrency: :threads)
node_id = workflow.call(content: "Test content")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(htm, concurrency: :auto) ⇒ RememberWorkflow

Initialize the remember workflow

Parameters:

  • htm (HTM)

    HTM instance for the robot

  • concurrency (Symbol) (defaults to: :auto)

    Concurrency model (:auto, :threads, :async)



31
32
33
34
35
# File 'lib/htm/workflows/remember_workflow.rb', line 31

def initialize(htm, concurrency: :auto)
  @htm = htm
  @concurrency = concurrency
  @pipeline = build_pipeline
end

Instance Attribute Details

#htmObject (readonly)

Returns the value of attribute htm.



24
25
26
# File 'lib/htm/workflows/remember_workflow.rb', line 24

def htm
  @htm
end

#pipelineObject (readonly)

Returns the value of attribute pipeline.



24
25
26
# File 'lib/htm/workflows/remember_workflow.rb', line 24

def pipeline
  @pipeline
end

Instance Method Details

#call(content:, tags: [], metadata: {}) ⇒ Integer

Execute the remember workflow

Parameters:

  • content (String)

    Content to remember

  • tags (Array<String>) (defaults to: [])

    Manual tags to assign

  • metadata (Hash) (defaults to: {})

    Metadata for the node

Returns:

  • (Integer)

    Node ID of the created memory



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/htm/workflows/remember_workflow.rb', line 44

def call(content:, tags: [], metadata: {})
  initial_data = {
    content: content,
    tags: tags,
    metadata: ,
    robot_id: @htm.robot_id,
    htm: @htm
  }

  result = @pipeline.call_parallel(SimpleFlow::Result.new(initial_data))

  if result.continue?
    result.context[:node_id]
  else
    HTM.logger.error "RememberWorkflow failed: #{result.errors.inspect}"
    raise HTM::Error, "Remember workflow failed: #{result.errors.values.flatten.join(', ')}"
  end
end

#execution_planString

Get execution plan

Returns:

  • (String)

    Execution plan description



75
76
77
# File 'lib/htm/workflows/remember_workflow.rb', line 75

def execution_plan
  @pipeline.execution_plan
end

#to_mermaidString

Get visualization of the workflow as Mermaid diagram

Returns:

  • (String)

    Mermaid diagram source



67
68
69
# File 'lib/htm/workflows/remember_workflow.rb', line 67

def to_mermaid
  @pipeline.visualize_mermaid
end