Class: Boxcars::VectorAnswer
- Inherits:
-
EngineBoxcar
- Object
- Boxcar
- EngineBoxcar
- Boxcars::VectorAnswer
- Defined in:
- lib/boxcars/boxcar/vector_answer.rb
Overview
A Boxcar that interprets a prompt and executes ruby code to do math
Constant Summary collapse
- DESC =
the description of this engine boxcar
"useful for when you need to answer questions from vector search results."
Instance Attribute Summary collapse
-
#embeddings ⇒ Object
readonly
Returns the value of attribute embeddings.
-
#search_content ⇒ Object
readonly
Returns the value of attribute search_content.
-
#vector_documents ⇒ Object
readonly
Returns the value of attribute vector_documents.
Attributes inherited from EngineBoxcar
#engine, #prompt, #stop, #top_k
Attributes inherited from Boxcar
#description, #name, #parameters, #return_direct
Instance Method Summary collapse
-
#initialize(embeddings:, vector_documents:, engine: nil, prompt: nil, **kwargs) ⇒ VectorAnswer
constructor
A new instance of VectorAnswer.
-
#prediction_additional(inputs) ⇒ Object
Hash The additional variables for this boxcar.
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(embeddings:, vector_documents:, engine: nil, prompt: nil, **kwargs) ⇒ VectorAnswer
Returns a new instance of VectorAnswer.
17 18 19 20 21 22 23 24 25 |
# File 'lib/boxcars/boxcar/vector_answer.rb', line 17 def initialize(embeddings:, vector_documents:, engine: nil, prompt: nil, **kwargs) the_prompt = prompt || my_prompt @embeddings = @vector_documents = vector_documents kwargs[:stop] ||= ["```output"] kwargs[:name] ||= "VectorAnswer" kwargs[:description] ||= DESC super(engine: engine, prompt: the_prompt, **kwargs) end |
Instance Attribute Details
#embeddings ⇒ Object (readonly)
Returns the value of attribute embeddings.
10 11 12 |
# File 'lib/boxcars/boxcar/vector_answer.rb', line 10 def @embeddings end |
#search_content ⇒ Object (readonly)
Returns the value of attribute search_content.
10 11 12 |
# File 'lib/boxcars/boxcar/vector_answer.rb', line 10 def search_content @search_content end |
#vector_documents ⇒ Object (readonly)
Returns the value of attribute vector_documents.
10 11 12 |
# File 'lib/boxcars/boxcar/vector_answer.rb', line 10 def vector_documents @vector_documents end |
Instance Method Details
#prediction_additional(inputs) ⇒ Object
Returns Hash The additional variables for this boxcar.
29 30 31 |
# File 'lib/boxcars/boxcar/vector_answer.rb', line 29 def prediction_additional(inputs) { search_content: get_search_content(inputs[:question]) }.merge super end |