Class: RagRuby::Answer
- Inherits:
-
Object
- Object
- RagRuby::Answer
- Defined in:
- lib/rag_ruby/answer.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tokens_used ⇒ Object
readonly
Returns the value of attribute tokens_used.
Instance Method Summary collapse
-
#initialize(text:, sources: [], tokens_used: {}, duration: nil, query: nil) ⇒ Answer
constructor
A new instance of Answer.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text:, sources: [], tokens_used: {}, duration: nil, query: nil) ⇒ Answer
Returns a new instance of Answer.
7 8 9 10 11 12 13 |
# File 'lib/rag_ruby/answer.rb', line 7 def initialize(text:, sources: [], tokens_used: {}, duration: nil, query: nil) @text = text @sources = sources @tokens_used = tokens_used @duration = duration @query = query end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/rag_ruby/answer.rb', line 5 def duration @duration end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
5 6 7 |
# File 'lib/rag_ruby/answer.rb', line 5 def query @query end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
5 6 7 |
# File 'lib/rag_ruby/answer.rb', line 5 def sources @sources end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/rag_ruby/answer.rb', line 5 def text @text end |
#tokens_used ⇒ Object (readonly)
Returns the value of attribute tokens_used.
5 6 7 |
# File 'lib/rag_ruby/answer.rb', line 5 def tokens_used @tokens_used end |
Instance Method Details
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/rag_ruby/answer.rb', line 19 def to_h { text: text, sources: sources.map(&:to_h), tokens_used: tokens_used, duration: duration, query: query } end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/rag_ruby/answer.rb', line 15 def to_s text end |