Class: Vellum::PdfSearchResultMetaSource

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/pdf_search_result_meta_source.rb

Overview

The source of a search result from a PDF document.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_type:, start_page_num: OMIT, end_page_num: OMIT, additional_properties: nil) ⇒ Vellum::PdfSearchResultMetaSource

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



31
32
33
34
35
36
37
38
39
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 31

def initialize(document_type:, start_page_num: OMIT, end_page_num: OMIT, additional_properties: nil)
  @document_type = document_type
  @start_page_num = start_page_num if start_page_num != OMIT
  @end_page_num = end_page_num if end_page_num != OMIT
  @additional_properties = additional_properties
  @_field_set = { "document_type": document_type, "start_page_num": start_page_num, "end_page_num": end_page_num }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



17
18
19
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 17

def additional_properties
  @additional_properties
end

#document_typeString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 9

def document_type
  @document_type
end

#end_page_numObject (readonly)

for supported chunking strategies and document types.



15
16
17
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 15

def end_page_num
  @end_page_num
end

#start_page_numObject (readonly)

for supported chunking strategies and document types.



12
13
14
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 12

def start_page_num
  @start_page_num
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::PdfSearchResultMetaSource

Parameters:

  • json_object (String)

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 44

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  document_type = parsed_json["document_type"]
  start_page_num = parsed_json["start_page_num"]
  end_page_num = parsed_json["end_page_num"]
  new(
    document_type: document_type,
    start_page_num: start_page_num,
    end_page_num: end_page_num,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


69
70
71
72
73
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 69

def self.validate_raw(obj:)
  obj.document_type.is_a?(String) != false || raise("Passed value for field obj.document_type is not the expected type, validation failed.")
  obj.start_page_num&.is_a?(Integer) != false || raise("Passed value for field obj.start_page_num is not the expected type, validation failed.")
  obj.end_page_num&.is_a?(Integer) != false || raise("Passed value for field obj.end_page_num is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


60
61
62
# File 'lib/vellum_ai/types/pdf_search_result_meta_source.rb', line 60

def to_json
  @_field_set&.to_json
end