Class: Vellum::SlimDocument

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, external_id: OMIT, last_uploaded_at:, label:, processing_state:, processing_failure_reason: OMIT, status: OMIT, keywords: OMIT, metadata: OMIT, document_to_document_indexes:, additional_properties: nil) ⇒ Vellum::SlimDocument

Parameters:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vellum_ai/types/slim_document.rb', line 64

def initialize(id:, external_id: OMIT, last_uploaded_at:, label:, processing_state:, processing_failure_reason: OMIT, status: OMIT, keywords: OMIT, metadata: OMIT, document_to_document_indexes:, additional_properties: nil)
  @id = id
  @external_id = external_id if external_id != OMIT
  @last_uploaded_at = last_uploaded_at
  @label = label
  @processing_state = processing_state
  @processing_failure_reason = processing_failure_reason if processing_failure_reason != OMIT
  @status = status if status != OMIT
  @keywords = keywords if keywords != OMIT
  @metadata =  if  != OMIT
  @document_to_document_indexes = document_to_document_indexes
  @additional_properties = additional_properties
  @_field_set = { "id": id, "external_id": external_id, "last_uploaded_at": last_uploaded_at, "label": label, "processing_state": processing_state, "processing_failure_reason": processing_failure_reason, "status": status, "keywords": keywords, "metadata": , "document_to_document_indexes": document_to_document_indexes }.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



39
40
41
# File 'lib/vellum_ai/types/slim_document.rb', line 39

def additional_properties
  @additional_properties
end

#document_to_document_indexesArray<Vellum::SlimDocumentDocumentToDocumentIndex> (readonly)



37
38
39
# File 'lib/vellum_ai/types/slim_document.rb', line 37

def document_to_document_indexes
  @document_to_document_indexes
end

#external_idString (readonly)

Returns The external ID that was originally provided when uploading the document.

Returns:

  • (String)

    The external ID that was originally provided when uploading the document.



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

def external_id
  @external_id
end

#idString (readonly)

Returns Vellum-generated ID that uniquely identifies this document.

Returns:

  • (String)

    Vellum-generated ID that uniquely identifies this document.



13
14
15
# File 'lib/vellum_ai/types/slim_document.rb', line 13

def id
  @id
end

#keywordsObject (readonly)

uploading the document.



32
33
34
# File 'lib/vellum_ai/types/slim_document.rb', line 32

def keywords
  @keywords
end

#labelString (readonly)

Returns Human-friendly name for this document.

Returns:

  • (String)

    Human-friendly name for this document.



19
20
21
# File 'lib/vellum_ai/types/slim_document.rb', line 19

def label
  @label
end

#last_uploaded_atDateTime (readonly)

Returns A timestamp representing when this document was most recently uploaded.

Returns:

  • (DateTime)

    A timestamp representing when this document was most recently uploaded.



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

def last_uploaded_at
  @last_uploaded_at
end

#metadataObject (readonly)

when searching.



35
36
37
# File 'lib/vellum_ai/types/slim_document.rb', line 35

def 
  @metadata
end

#processing_failure_reasonObject (readonly)

  • ‘INVALID_FILE` - Invalid File



26
27
28
# File 'lib/vellum_ai/types/slim_document.rb', line 26

def processing_failure_reason
  @processing_failure_reason
end

#processing_stateVellum::DocumentProcessingState (readonly)



21
22
23
# File 'lib/vellum_ai/types/slim_document.rb', line 21

def processing_state
  @processing_state
end

#statusObject (readonly)

  • ‘ACTIVE` - Active



29
30
31
# File 'lib/vellum_ai/types/slim_document.rb', line 29

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::SlimDocument

Parameters:

  • json_object (String)

Returns:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/vellum_ai/types/slim_document.rb', line 84

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  external_id = parsed_json["external_id"]
  last_uploaded_at = unless parsed_json["last_uploaded_at"].nil?
  DateTime.parse(parsed_json["last_uploaded_at"])
else
  nil
end
  label = parsed_json["label"]
  processing_state = parsed_json["processing_state"]
  processing_failure_reason = parsed_json["processing_failure_reason"]
  status = parsed_json["status"]
  keywords = parsed_json["keywords"]
   = parsed_json["metadata"]
  document_to_document_indexes = parsed_json["document_to_document_indexes"]&.map do | item |
  item = item.to_json
  Vellum::SlimDocumentDocumentToDocumentIndex.from_json(json_object: item)
end
  new(
    id: id,
    external_id: external_id,
    last_uploaded_at: last_uploaded_at,
    label: label,
    processing_state: processing_state,
    processing_failure_reason: processing_failure_reason,
    status: status,
    keywords: keywords,
    metadata: ,
    document_to_document_indexes: document_to_document_indexes,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vellum_ai/types/slim_document.rb', line 130

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?(Vellum::DocumentProcessingState) != false || raise("Passed value for field obj.processing_state is not the expected type, validation failed.")
  obj.processing_failure_reason&.is_a?(Vellum::ProcessingFailureReasonEnum) != false || raise("Passed value for field obj.processing_failure_reason 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.keywords&.is_a?(Array) != false || raise("Passed value for field obj.keywords 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.")
  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.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


121
122
123
# File 'lib/vellum_ai/types/slim_document.rb', line 121

def to_json
  @_field_set&.to_json
end