Class: Boxcars::ZeroShot
- Inherits:
-
Train
- Object
- Boxcar
- EngineBoxcar
- Train
- Boxcars::ZeroShot
- Defined in:
- lib/boxcars/train/zero_shot.rb
Overview
A Train using the zero-shot react method.
Instance Attribute Summary collapse
-
#boxcars ⇒ Object
readonly
Returns the value of attribute boxcars.
-
#observation_prefix ⇒ Object
readonly
Returns the value of attribute observation_prefix.
-
#wants_next_actions ⇒ Object
Returns the value of attribute wants_next_actions.
Attributes inherited from Train
#answer_prefix, #early_stopping_method, #engine_prefix, #final_answer_prefix, #max_iterations, #name_to_boxcar_map, #question_prefix, #return_intermediate_steps, #return_values, #thought_prefix, #using_xml
Attributes inherited from EngineBoxcar
#engine, #prompt, #stop, #top_k
Attributes inherited from Boxcar
#description, #name, #parameters, #return_direct
Instance Method Summary collapse
-
#extract_boxcar_and_input(text) ⇒ Array<Boxcars::Boxcar, String>
Extract the boxcar and input from the engine output.
-
#initialize(boxcars:, engine: nil, name: 'Zero Shot', description: 'Zero Shot Train', prompt: nil, **kwargs) ⇒ ZeroShot
constructor
A new instance of ZeroShot.
-
#prediction_additional(_inputs) ⇒ Object
Hash The additional variables for this boxcar.
Methods inherited from Train
#boxcar_descriptions, #boxcar_names, #call, #construct_scratchpad, #finish_boxcar_name, #get_boxcar_result, #get_next_action, #init_prefixes, #input_keys, #key_and_value_text, #next_actions, #observation_text, #output_keys, #plan, #pre_return, #prepare_for_new_call, #question_text, #return_stopped_response, #should_continue?, #validate_prompt
Methods inherited from EngineBoxcar
#apply, #call, #check_output_keys, #extract_code, #generate, #input_key, #input_keys, #output_key, #output_keys, #predict, #prediction_input, #prediction_variables
Methods inherited from Boxcar
#apply, assi, #call, #conduct, hist, #input_keys, #load, #output_keys, #run, #save, #schema, syst, user, #validate_inputs, #validate_outputs
Constructor Details
#initialize(boxcars:, engine: nil, name: 'Zero Shot', description: 'Zero Shot Train', prompt: nil, **kwargs) ⇒ ZeroShot
Returns a new instance of ZeroShot.
16 17 18 19 20 |
# File 'lib/boxcars/train/zero_shot.rb', line 16 def initialize(boxcars:, engine: nil, name: 'Zero Shot', description: 'Zero Shot Train', prompt: nil, **kwargs) @wants_next_actions = kwargs.fetch(:wants_next_actions, false) prompt ||= my_prompt super(engine: engine, boxcars: boxcars, prompt: prompt, name: name, description: description, **kwargs) end |
Instance Attribute Details
#boxcars ⇒ Object (readonly)
Returns the value of attribute boxcars.
7 8 9 |
# File 'lib/boxcars/train/zero_shot.rb', line 7 def boxcars @boxcars end |
#observation_prefix ⇒ Object (readonly)
Returns the value of attribute observation_prefix.
7 8 9 |
# File 'lib/boxcars/train/zero_shot.rb', line 7 def observation_prefix @observation_prefix end |
#wants_next_actions ⇒ Object
Returns the value of attribute wants_next_actions.
8 9 10 |
# File 'lib/boxcars/train/zero_shot.rb', line 8 def wants_next_actions @wants_next_actions end |
Instance Method Details
#extract_boxcar_and_input(text) ⇒ Array<Boxcars::Boxcar, String>
Extract the boxcar and input from the engine output.
30 31 32 33 34 |
# File 'lib/boxcars/train/zero_shot.rb', line 30 def extract_boxcar_and_input(text) get_action_and_input(engine_output: text) rescue StandardError => e [:error, e.] end |
#prediction_additional(_inputs) ⇒ Object
Returns Hash The additional variables for this boxcar.
23 24 25 |
# File 'lib/boxcars/train/zero_shot.rb', line 23 def prediction_additional(_inputs) { boxcar_names: boxcar_names, boxcar_descriptions: boxcar_descriptions, next_actions: next_actions }.merge super end |