Class: Maglev::Response
- Inherits:
-
Object
- Object
- Maglev::Response
- Defined in:
- lib/maglev/response.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text:, sources:, metadata: {}) ⇒ Response
constructor
A new instance of Response.
- #to_s ⇒ Object
Constructor Details
#initialize(text:, sources:, metadata: {}) ⇒ Response
Returns a new instance of Response.
15 16 17 18 19 20 |
# File 'lib/maglev/response.rb', line 15 def initialize(text:, sources:, metadata: {}) @text = text @sources = sources.freeze @metadata = .freeze freeze end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/maglev/response.rb', line 5 def @metadata end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
5 6 7 |
# File 'lib/maglev/response.rb', line 5 def sources @sources end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/maglev/response.rb', line 5 def text @text end |
Class Method Details
.insufficient_context(question:) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/maglev/response.rb', line 7 def self.insufficient_context(question:) new( text: "Insufficient context to answer the question.", sources: [], metadata: {question: question, reason: "insufficient_context"} ) end |
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/maglev/response.rb', line 22 def to_s text end |