Class: Boxcars::XMLEngineBoxcar
- Inherits:
-
EngineBoxcar
- Object
- Boxcar
- EngineBoxcar
- Boxcars::XMLEngineBoxcar
- Defined in:
- lib/boxcars/boxcar/xml_engine_boxcar.rb
Overview
For Boxcars that use an engine to do their work.
Instance Attribute Summary
Attributes inherited from EngineBoxcar
#engine, #prompt, #stop, #top_k
Attributes inherited from Boxcar
#description, #name, #parameters, #return_direct
Instance Method Summary collapse
-
#get_answer(engine_output) ⇒ Array<String>
Parse out the action and input from the engine output.
-
#xn_get_answer(xnode) ⇒ Array<String, String>
get answer an XNode.
Methods inherited from EngineBoxcar
#apply, #call, #check_output_keys, #extract_code, #generate, #initialize, #input_key, #input_keys, #output_key, #output_keys, #predict, #prediction_additional, #prediction_input, #prediction_variables
Methods inherited from Boxcar
#apply, assi, #call, #conduct, hist, #initialize, #input_keys, #load, #output_keys, #run, #save, #schema, syst, user, #validate_inputs, #validate_outputs
Constructor Details
This class inherits a constructor from Boxcars::EngineBoxcar
Instance Method Details
#get_answer(engine_output) ⇒ Array<String>
Parse out the action and input from the engine output.
12 13 14 15 16 |
# File 'lib/boxcars/boxcar/xml_engine_boxcar.rb', line 12 def get_answer(engine_output) xn_get_answer(XNode.from_xml(engine_output)) rescue StandardError => e Result.from_error("Error: #{e.}:\n#{engine_output}") end |
#xn_get_answer(xnode) ⇒ Array<String, String>
get answer an XNode
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/boxcars/boxcar/xml_engine_boxcar.rb', line 21 def xn_get_answer(xnode) reply = xnode.xtext("//reply") if reply.present? Result.new(status: :ok, answer: reply, explanation: reply) else # we have an unexpected output from the engine Result.new(status: :error, answer: nil, explanation: "You gave me an improperly formatted answer or didn't use tags. I was expecting a reply.") end end |