Class: Maglev::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/maglev/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/maglev/response.rb', line 5

def 
  @metadata
end

#sourcesObject (readonly)

Returns the value of attribute sources.



5
6
7
# File 'lib/maglev/response.rb', line 5

def sources
  @sources
end

#textObject (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_sObject



22
23
24
# File 'lib/maglev/response.rb', line 22

def to_s
  text
end