Class: Vellum::SlimDocument
- Inherits:
-
Object
- Object
- Vellum::SlimDocument
- Defined in:
- lib/vellum_ai/types/slim_document.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #document_to_document_indexes ⇒ Array<Vellum::SlimDocumentDocumentToDocumentIndex> readonly
-
#external_id ⇒ String
readonly
The external ID that was originally provided when uploading the document.
-
#id ⇒ String
readonly
Vellum-generated ID that uniquely identifies this document.
-
#keywords ⇒ Object
readonly
uploading the document.
-
#label ⇒ String
readonly
Human-friendly name for this document.
-
#last_uploaded_at ⇒ DateTime
readonly
A timestamp representing when this document was most recently uploaded.
-
#metadata ⇒ Object
readonly
when searching.
-
#processing_failure_reason ⇒ Object
readonly
-
‘INVALID_FILE` - Invalid File.
-
- #processing_state ⇒ Vellum::DocumentProcessingState readonly
-
#status ⇒ Object
readonly
-
‘ACTIVE` - Active.
-
Class Method Summary collapse
Instance Method Summary collapse
- #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 constructor
- #to_json ⇒ String
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
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_properties ⇒ OpenStruct (readonly)
Returns 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_indexes ⇒ Array<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_id ⇒ String (readonly)
Returns 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 |
#id ⇒ String (readonly)
Returns 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 |
#keywords ⇒ Object (readonly)
uploading the document.
32 33 34 |
# File 'lib/vellum_ai/types/slim_document.rb', line 32 def keywords @keywords end |
#label ⇒ String (readonly)
Returns 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_at ⇒ DateTime (readonly)
Returns 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 |
#metadata ⇒ Object (readonly)
when searching.
35 36 37 |
# File 'lib/vellum_ai/types/slim_document.rb', line 35 def @metadata end |
#processing_failure_reason ⇒ Object (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_state ⇒ Vellum::DocumentProcessingState (readonly)
21 22 23 |
# File 'lib/vellum_ai/types/slim_document.rb', line 21 def processing_state @processing_state end |
#status ⇒ Object (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
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
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_json ⇒ String
121 122 123 |
# File 'lib/vellum_ai/types/slim_document.rb', line 121 def to_json @_field_set&.to_json end |