Class: Vellum::SearchResultRequest
- Inherits:
-
Object
- Object
- Vellum::SearchResultRequest
- Defined in:
- lib/vellum_ai/types/search_result_request.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#document ⇒ Vellum::SearchResultDocumentRequest
readonly
The document that contains the chunk that matched the search query.
- #keywords ⇒ Array<String> readonly
-
#meta ⇒ Vellum::SearchResultMetaRequest
readonly
Additional information about the search result.
-
#score ⇒ Float
readonly
A score representing how well the chunk matches the search query.
-
#text ⇒ String
readonly
The text of the chunk that matched the search query.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(text:, score:, keywords:, document:, meta: OMIT, additional_properties: nil) ⇒ Vellum::SearchResultRequest constructor
- #to_json ⇒ String
Constructor Details
#initialize(text:, score:, keywords:, document:, meta: OMIT, additional_properties: nil) ⇒ Vellum::SearchResultRequest
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 34 def initialize(text:, score:, keywords:, document:, meta: OMIT, additional_properties: nil) @text = text @score = score @keywords = keywords @document = document @meta = if != OMIT @additional_properties = additional_properties @_field_set = { "text": text, "score": score, "keywords": keywords, "document": document, "meta": }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 20 def additional_properties @additional_properties end |
#document ⇒ Vellum::SearchResultDocumentRequest (readonly)
Returns The document that contains the chunk that matched the search query.
16 17 18 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 16 def document @document end |
#keywords ⇒ Array<String> (readonly)
14 15 16 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 14 def keywords @keywords end |
#meta ⇒ Vellum::SearchResultMetaRequest (readonly)
Returns Additional information about the search result.
18 19 20 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 18 def @meta end |
#score ⇒ Float (readonly)
Returns A score representing how well the chunk matches the search query.
12 13 14 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 12 def score @score end |
#text ⇒ String (readonly)
Returns The text of the chunk that matched the search query.
10 11 12 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 10 def text @text end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::SearchResultRequest
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 49 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) text = parsed_json["text"] score = parsed_json["score"] keywords = parsed_json["keywords"] unless parsed_json["document"].nil? document = parsed_json["document"].to_json document = Vellum::SearchResultDocumentRequest.from_json(json_object: document) else document = nil end unless parsed_json["meta"].nil? = parsed_json["meta"].to_json = Vellum::SearchResultMetaRequest.from_json(json_object: ) else = nil end new( text: text, score: score, keywords: keywords, document: document, meta: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
88 89 90 91 92 93 94 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 88 def self.validate_raw(obj:) obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.score.is_a?(Float) != false || raise("Passed value for field obj.score is not the expected type, validation failed.") obj.keywords.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.") Vellum::SearchResultDocumentRequest.validate_raw(obj: obj.document) obj..nil? || Vellum::SearchResultMetaRequest.validate_raw(obj: obj.) end |
Instance Method Details
#to_json ⇒ String
79 80 81 |
# File 'lib/vellum_ai/types/search_result_request.rb', line 79 def to_json @_field_set&.to_json end |