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
13
14
15
16
17
# File 'lib/console_agent/context_builder.rb', line 7

def build
  case @config.context_mode
  when :smart
    build_smart
  else
    build_full
  end
rescue => e
  ConsoleAgent.logger.warn("ConsoleAgent: context build error: #{e.message}")
  system_instructions + "\n\n" + environment_context
end

#build_fullObject



19
20
21
22
23
24
25
26
27
# File 'lib/console_agent/context_builder.rb', line 19

def build_full
  parts = []
  parts << system_instructions
  parts << environment_context
  parts << schema_context
  parts << models_context
  parts << routes_context
  parts.compact.join("\n\n")
end

#build_smartObject



29
30
31
32
33
34
35
# File 'lib/console_agent/context_builder.rb', line 29

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