Class: ConsoleAgent::ContextBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/console_agent/context_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = ConsoleAgent.configuration) ⇒ ContextBuilder

Returns a new instance of ContextBuilder.



3
4
5
# File 'lib/console_agent/context_builder.rb', line 3

def initialize(config = ConsoleAgent.configuration)
  @config = config
end

Instance Method Details

#buildObject



7
8
9
10
11
12
# File 'lib/console_agent/context_builder.rb', line 7

def build
  build_smart
rescue => e
  ConsoleAgent.logger.warn("ConsoleAgent: context build error: #{e.message}")
  smart_system_instructions + "\n\n" + environment_context
end

#build_smartObject



14
15
16
17
18
19
20
# File 'lib/console_agent/context_builder.rb', line 14

def build_smart
  parts = []
  parts << smart_system_instructions
  parts << environment_context
  parts << memory_context
  parts.compact.join("\n\n")
end