Class: ComposableAgents::Instructions
- Inherits:
-
Object
- Object
- ComposableAgents::Instructions
- Includes:
- Enumerable
- Defined in:
- lib/composable_agents/instructions.rb
Overview
Provide a way to define instructions to be used by system and user prompts. Instructions are always normalized as a list of individual instructions that each can be rendered differently depending on the rendering strategy. This is used by PromptDrivenAgent agents only.
Instance Method Summary collapse
-
#each {|instruction_type, instruction| ... } ⇒ Object
Iterate over all instructions.
-
#initialize(instructions) ⇒ Instructions
constructor
Constructor.
Constructor Details
#initialize(instructions) ⇒ Instructions
Constructor
22 23 24 25 26 27 |
# File 'lib/composable_agents/instructions.rb', line 22 def initialize(instructions) # Normalize system instructions to [Array<Hash{Symbol => Object}>]. @instructions = (instructions.is_a?(Array) ? instructions : [instructions]).map do |instructions_set| instructions_set.is_a?(Hash) ? instructions_set : { text: instructions_set } end end |
Instance Method Details
#each {|instruction_type, instruction| ... } ⇒ Object
Iterate over all instructions
34 35 36 37 38 39 40 |
# File 'lib/composable_agents/instructions.rb', line 34 def each(&) return enum_for(:each) unless block_given? @instructions.each do |instructions_set| instructions_set.each(&) end end |