Class: Vellum::DocumentRead

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, last_uploaded_at:, label:, document_to_document_indexes:, external_id: nil, processing_state: nil, status: nil, original_file_url: nil, processed_file_url: nil, metadata: nil, additional_properties: nil) ⇒ DocumentRead

Parameters:

  • id (String)
  • external_id (String) (defaults to: nil)

    The unique id of this document as it exists in the user’s system.

  • last_uploaded_at (DateTime)
  • label (String)

    A human-readable label for the document. Defaults to the originally uploaded file’s file name.

  • processing_state (PROCESSING_STATE_ENUM) (defaults to: nil)

    The current processing state of the document

    • ‘QUEUED` - Queued

    • ‘PROCESSING` - Processing

    • ‘PROCESSED` - Processed

    • ‘FAILED` - Failed

  • status (DOCUMENT_STATUS) (defaults to: nil)

    The current status of the document

    • ‘ACTIVE` - Active

  • original_file_url (String) (defaults to: nil)
  • processed_file_url (String) (defaults to: nil)
  • document_to_document_indexes (Array<DocumentDocumentToDocumentIndex>)
  • metadata (Hash{String => String}) (defaults to: nil)

    A previously supplied JSON object containing metadata that can be filtered on when searching.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vellum_ai/types/document_read.rb', line 31

def initialize(id:, last_uploaded_at:, label:, document_to_document_indexes:, external_id: nil, processing_state: nil, status: nil,
               original_file_url: nil, processed_file_url: nil, metadata: nil, additional_properties: nil)
  # @type [String]
  @id = id
  # @type [String] The unique id of this document as it exists in the user's system.
  @external_id = external_id
  # @type [DateTime]
  @last_uploaded_at = last_uploaded_at
  # @type [String] A human-readable label for the document. Defaults to the originally uploaded file's file name.
  @label = label
  # @type [PROCESSING_STATE_ENUM] The current processing state of the document
  #   - `QUEUED` - Queued
  #   - `PROCESSING` - Processing
  #   - `PROCESSED` - Processed
  #   - `FAILED` - Failed
  @processing_state = processing_state
  # @type [DOCUMENT_STATUS] The current status of the document
  #   - `ACTIVE` - Active
  @status = status
  # @type [String]
  @original_file_url = original_file_url
  # @type [String]
  @processed_file_url = processed_file_url
  # @type [Array<DocumentDocumentToDocumentIndex>]
  @document_to_document_indexes = document_to_document_indexes
  # @type [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
  @metadata = 
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def additional_properties
  @additional_properties
end

#document_to_document_indexesObject (readonly)

Returns the value of attribute document_to_document_indexes.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def document_to_document_indexes
  @document_to_document_indexes
end

#external_idObject (readonly)

Returns the value of attribute external_id.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def external_id
  @external_id
end

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def label
  @label
end

#last_uploaded_atObject (readonly)

Returns the value of attribute last_uploaded_at.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def last_uploaded_at
  @last_uploaded_at
end

#metadataObject (readonly)

Returns the value of attribute metadata.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def 
  @metadata
end

#original_file_urlObject (readonly)

Returns the value of attribute original_file_url.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def original_file_url
  @original_file_url
end

#processed_file_urlObject (readonly)

Returns the value of attribute processed_file_url.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def processed_file_url
  @processed_file_url
end

#processing_stateObject (readonly)

Returns the value of attribute processing_state.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def processing_state
  @processing_state
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/vellum_ai/types/document_read.rb', line 11

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ DocumentRead

Deserialize a JSON object to an instance of DocumentRead

Parameters:

  • json_object (JSON)

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/vellum_ai/types/document_read.rb', line 66

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = struct.id
  external_id = struct.external_id
  last_uploaded_at = DateTime.parse(parsed_json["last_uploaded_at"])
  label = struct.label
  processing_state = PROCESSING_STATE_ENUM.key(parsed_json["processing_state"]) || parsed_json["processing_state"]
  status = struct.status
  original_file_url = struct.original_file_url
  processed_file_url = struct.processed_file_url
  document_to_document_indexes = parsed_json["document_to_document_indexes"].map do |v|
    v = v.to_json
    DocumentDocumentToDocumentIndex.from_json(json_object: v)
  end
   = struct.
  new(id: id, external_id: external_id, last_uploaded_at: last_uploaded_at, label: label,
      processing_state: processing_state, status: status, original_file_url: original_file_url, processed_file_url: processed_file_url, document_to_document_indexes: document_to_document_indexes, metadata: , additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/vellum_ai/types/document_read.rb', line 108

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
  obj.last_uploaded_at.is_a?(DateTime) != false || raise("Passed value for field obj.last_uploaded_at is not the expected type, validation failed.")
  obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
  obj.processing_state&.is_a?(PROCESSING_STATE_ENUM) != false || raise("Passed value for field obj.processing_state is not the expected type, validation failed.")
  obj.status&.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.original_file_url&.is_a?(String) != false || raise("Passed value for field obj.original_file_url is not the expected type, validation failed.")
  obj.processed_file_url&.is_a?(String) != false || raise("Passed value for field obj.processed_file_url is not the expected type, validation failed.")
  obj.document_to_document_indexes.is_a?(Array) != false || raise("Passed value for field obj.document_to_document_indexes is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of DocumentRead to a JSON object

Returns:

  • (JSON)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/vellum_ai/types/document_read.rb', line 89

def to_json(*_args)
  {
    "id": @id,
    "external_id": @external_id,
    "last_uploaded_at": @last_uploaded_at,
    "label": @label,
    "processing_state": PROCESSING_STATE_ENUM[@processing_state] || @processing_state,
    "status": @status,
    "original_file_url": @original_file_url,
    "processed_file_url": @processed_file_url,
    "document_to_document_indexes": @document_to_document_indexes,
    "metadata": @metadata
  }.to_json
end