Class: ConsoleAgent::ContextBuilder
- Inherits:
-
Object
- Object
- ConsoleAgent::ContextBuilder
- Defined in:
- lib/console_agent/context_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
- #build_full ⇒ Object
- #build_smart ⇒ Object
-
#initialize(config = ConsoleAgent.configuration) ⇒ ContextBuilder
constructor
A new instance of ContextBuilder.
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
#build ⇒ Object
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.}") system_instructions + "\n\n" + environment_context end |
#build_full ⇒ Object
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_smart ⇒ Object
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 |