trieve_ruby_client 0.5.0 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/GENERATE_COMMAND.txt +1 -0
  3. data/README.md +21 -10
  4. data/docs/AuthApi.md +1 -1
  5. data/docs/ChunkApi.md +9 -9
  6. data/docs/ChunkGroupApi.md +25 -16
  7. data/docs/DatasetApi.md +9 -9
  8. data/docs/EventsApi.md +1 -1
  9. data/docs/FileApi.md +1 -1
  10. data/docs/GroupScoreChunkDTO.md +2 -0
  11. data/docs/GroupSlimChunksDTO.md +20 -0
  12. data/docs/HealthApi.md +1 -1
  13. data/docs/InvitationApi.md +1 -1
  14. data/docs/MessageApi.md +1 -1
  15. data/docs/OrganizationApi.md +1 -1
  16. data/docs/Range.md +4 -4
  17. data/docs/RangeCondition.md +49 -0
  18. data/docs/ReccomendGroupChunksRequest.md +3 -1
  19. data/docs/RecommendChunksRequest.md +3 -1
  20. data/docs/RecommendChunksResponseTypes.md +49 -0
  21. data/docs/RecommendGroupChunkResponseTypes.md +49 -0
  22. data/docs/ScoreSlimChunks.md +20 -0
  23. data/docs/SearchChunkData.md +4 -0
  24. data/docs/SearchChunkResponseTypes.md +49 -0
  25. data/docs/SearchGroupSlimChunksResult.md +22 -0
  26. data/docs/SearchOverGroupsData.md +5 -1
  27. data/docs/SearchOverGroupsResponseTypes.md +49 -0
  28. data/docs/SearchOverGroupsSlimChunksResponseBody.md +20 -0
  29. data/docs/SearchSlimChunkQueryResponseBody.md +20 -0
  30. data/docs/SearchWithinGroupData.md +4 -0
  31. data/docs/SearchWithinGroupResponseTypes.md +49 -0
  32. data/docs/SlimChunkMetadata.md +36 -0
  33. data/docs/SlimUser.md +1 -7
  34. data/docs/StripeApi.md +1 -1
  35. data/docs/TopicApi.md +9 -9
  36. data/docs/UpdateChunkData.md +2 -0
  37. data/docs/UpdateUserData.md +1 -7
  38. data/docs/UserApi.md +9 -9
  39. data/lib/trieve_ruby_client/api/auth_api.rb +1 -1
  40. data/lib/trieve_ruby_client/api/chunk_api.rb +7 -7
  41. data/lib/trieve_ruby_client/api/chunk_group_api.rb +21 -14
  42. data/lib/trieve_ruby_client/api/dataset_api.rb +11 -16
  43. data/lib/trieve_ruby_client/api/events_api.rb +1 -1
  44. data/lib/trieve_ruby_client/api/file_api.rb +1 -1
  45. data/lib/trieve_ruby_client/api/health_api.rb +1 -1
  46. data/lib/trieve_ruby_client/api/invitation_api.rb +1 -1
  47. data/lib/trieve_ruby_client/api/message_api.rb +1 -1
  48. data/lib/trieve_ruby_client/api/organization_api.rb +1 -1
  49. data/lib/trieve_ruby_client/api/stripe_api.rb +1 -1
  50. data/lib/trieve_ruby_client/api/topic_api.rb +11 -16
  51. data/lib/trieve_ruby_client/api/user_api.rb +11 -16
  52. data/lib/trieve_ruby_client/api_client.rb +1 -1
  53. data/lib/trieve_ruby_client/api_error.rb +1 -1
  54. data/lib/trieve_ruby_client/configuration.rb +7 -7
  55. data/lib/trieve_ruby_client/models/add_chunk_to_group_data.rb +1 -1
  56. data/lib/trieve_ruby_client/models/api_key_dto.rb +1 -1
  57. data/lib/trieve_ruby_client/models/auth_query.rb +1 -1
  58. data/lib/trieve_ruby_client/models/batch_queued_chunk_response.rb +1 -1
  59. data/lib/trieve_ruby_client/models/bookmark_data.rb +1 -1
  60. data/lib/trieve_ruby_client/models/bookmark_group_result.rb +1 -1
  61. data/lib/trieve_ruby_client/models/chat_message_proxy.rb +1 -1
  62. data/lib/trieve_ruby_client/models/chunk_data.rb +1 -1
  63. data/lib/trieve_ruby_client/models/chunk_filter.rb +1 -1
  64. data/lib/trieve_ruby_client/models/chunk_group.rb +1 -1
  65. data/lib/trieve_ruby_client/models/chunk_group_and_file.rb +1 -1
  66. data/lib/trieve_ruby_client/models/chunk_metadata.rb +1 -1
  67. data/lib/trieve_ruby_client/models/chunk_metadata_with_file_data.rb +1 -1
  68. data/lib/trieve_ruby_client/models/client_dataset_configuration.rb +1 -1
  69. data/lib/trieve_ruby_client/models/create_chunk_data.rb +1 -1
  70. data/lib/trieve_ruby_client/models/create_chunk_group_data.rb +1 -1
  71. data/lib/trieve_ruby_client/models/create_dataset_request.rb +1 -1
  72. data/lib/trieve_ruby_client/models/create_message_data.rb +1 -1
  73. data/lib/trieve_ruby_client/models/create_organization_data.rb +1 -1
  74. data/lib/trieve_ruby_client/models/create_topic_data.rb +1 -1
  75. data/lib/trieve_ruby_client/models/dataset.rb +1 -1
  76. data/lib/trieve_ruby_client/models/dataset_and_usage.rb +1 -1
  77. data/lib/trieve_ruby_client/models/dataset_dto.rb +1 -1
  78. data/lib/trieve_ruby_client/models/dataset_usage_count.rb +1 -1
  79. data/lib/trieve_ruby_client/models/delete_topic_data.rb +1 -1
  80. data/lib/trieve_ruby_client/models/delete_user_api_key_request.rb +1 -1
  81. data/lib/trieve_ruby_client/models/edit_message_data.rb +1 -1
  82. data/lib/trieve_ruby_client/models/error_response_body.rb +1 -1
  83. data/lib/trieve_ruby_client/models/event.rb +1 -1
  84. data/lib/trieve_ruby_client/models/event_return.rb +1 -1
  85. data/lib/trieve_ruby_client/models/field_condition.rb +1 -1
  86. data/lib/trieve_ruby_client/models/file.rb +1 -1
  87. data/lib/trieve_ruby_client/models/file_dto.rb +1 -1
  88. data/lib/trieve_ruby_client/models/generate_chunks_request.rb +1 -1
  89. data/lib/trieve_ruby_client/models/get_events_data.rb +1 -1
  90. data/lib/trieve_ruby_client/models/get_groups_for_chunks_data.rb +1 -1
  91. data/lib/trieve_ruby_client/models/group_data.rb +1 -1
  92. data/lib/trieve_ruby_client/models/group_score_chunk_dto.rb +12 -2
  93. data/lib/trieve_ruby_client/models/group_slim_chunks_dto.rb +239 -0
  94. data/lib/trieve_ruby_client/models/invitation_data.rb +1 -1
  95. data/lib/trieve_ruby_client/models/match_condition.rb +1 -1
  96. data/lib/trieve_ruby_client/models/message.rb +1 -1
  97. data/lib/trieve_ruby_client/models/organization.rb +1 -1
  98. data/lib/trieve_ruby_client/models/organization_usage_count.rb +1 -1
  99. data/lib/trieve_ruby_client/models/range.rb +5 -5
  100. data/lib/trieve_ruby_client/models/range_condition.rb +105 -0
  101. data/lib/trieve_ruby_client/models/reccomend_group_chunks_request.rb +17 -6
  102. data/lib/trieve_ruby_client/models/recommend_chunks_request.rb +17 -6
  103. data/lib/trieve_ruby_client/models/recommend_chunks_response_types.rb +105 -0
  104. data/lib/trieve_ruby_client/models/recommend_group_chunk_response_types.rb +105 -0
  105. data/lib/trieve_ruby_client/models/regenerate_message_data.rb +1 -1
  106. data/lib/trieve_ruby_client/models/return_queued_chunk.rb +1 -1
  107. data/lib/trieve_ruby_client/models/score_chunk_dto.rb +1 -1
  108. data/lib/trieve_ruby_client/models/score_slim_chunks.rb +239 -0
  109. data/lib/trieve_ruby_client/models/search_chunk_data.rb +24 -2
  110. data/lib/trieve_ruby_client/models/search_chunk_query_response_body.rb +1 -1
  111. data/lib/trieve_ruby_client/models/search_chunk_response_types.rb +105 -0
  112. data/lib/trieve_ruby_client/models/search_group_slim_chunks_result.rb +255 -0
  113. data/lib/trieve_ruby_client/models/search_groups_result.rb +1 -1
  114. data/lib/trieve_ruby_client/models/search_over_groups_data.rb +27 -5
  115. data/lib/trieve_ruby_client/models/search_over_groups_response_body.rb +1 -1
  116. data/lib/trieve_ruby_client/models/search_over_groups_response_types.rb +105 -0
  117. data/lib/trieve_ruby_client/models/search_over_groups_slim_chunks_response_body.rb +239 -0
  118. data/lib/trieve_ruby_client/models/search_slim_chunk_query_response_body.rb +239 -0
  119. data/lib/trieve_ruby_client/models/search_within_group_data.rb +24 -2
  120. data/lib/trieve_ruby_client/models/search_within_group_response_types.rb +105 -0
  121. data/lib/trieve_ruby_client/models/set_user_api_key_request.rb +1 -1
  122. data/lib/trieve_ruby_client/models/set_user_api_key_response.rb +1 -1
  123. data/lib/trieve_ruby_client/models/single_queued_chunk_response.rb +1 -1
  124. data/lib/trieve_ruby_client/models/slim_chunk_metadata.rb +329 -0
  125. data/lib/trieve_ruby_client/models/slim_group.rb +1 -1
  126. data/lib/trieve_ruby_client/models/slim_user.rb +5 -41
  127. data/lib/trieve_ruby_client/models/stripe_plan.rb +1 -1
  128. data/lib/trieve_ruby_client/models/suggested_queries_request.rb +1 -1
  129. data/lib/trieve_ruby_client/models/suggested_queries_response.rb +1 -1
  130. data/lib/trieve_ruby_client/models/topic.rb +1 -1
  131. data/lib/trieve_ruby_client/models/update_chunk_by_tracking_id_data.rb +1 -1
  132. data/lib/trieve_ruby_client/models/update_chunk_data.rb +15 -2
  133. data/lib/trieve_ruby_client/models/update_chunk_group_data.rb +1 -1
  134. data/lib/trieve_ruby_client/models/update_dataset_request.rb +1 -1
  135. data/lib/trieve_ruby_client/models/update_group_by_tracking_id_data.rb +1 -1
  136. data/lib/trieve_ruby_client/models/update_organization_data.rb +1 -1
  137. data/lib/trieve_ruby_client/models/update_topic_data.rb +1 -1
  138. data/lib/trieve_ruby_client/models/update_user_data.rb +6 -39
  139. data/lib/trieve_ruby_client/models/upload_file_data.rb +1 -1
  140. data/lib/trieve_ruby_client/models/upload_file_result.rb +1 -1
  141. data/lib/trieve_ruby_client/models/user_organization.rb +1 -1
  142. data/lib/trieve_ruby_client/version.rb +2 -2
  143. data/lib/trieve_ruby_client.rb +13 -2
  144. data/openapi-generator.yaml +1 -1
  145. data/openapi.json +636 -217
  146. data/spec/models/group_slim_chunks_dto_spec.rb +42 -0
  147. data/spec/models/range_condition_spec.rb +32 -0
  148. data/spec/models/recommend_chunks_response_types_spec.rb +32 -0
  149. data/spec/models/recommend_group_chunk_response_types_spec.rb +32 -0
  150. data/spec/models/score_slim_chunks_spec.rb +42 -0
  151. data/spec/models/search_chunk_response_types_spec.rb +32 -0
  152. data/spec/models/search_group_slim_chunks_result_spec.rb +48 -0
  153. data/spec/models/search_over_groups_response_types_spec.rb +32 -0
  154. data/spec/models/search_over_groups_slim_chunks_response_body_spec.rb +42 -0
  155. data/spec/models/search_slim_chunk_query_response_body_spec.rb +42 -0
  156. data/spec/models/search_within_group_response_types_spec.rb +32 -0
  157. data/spec/models/slim_chunk_metadata_spec.rb +90 -0
  158. data/spec/spec_helper.rb +1 -1
  159. data/trieve_ruby_client-0.5.0.gem +0 -0
  160. data/trieve_ruby_client.gemspec +1 -1
  161. metadata +52 -4
  162. data/trieve_ruby_client-0.3.5.gem +0 -0
  163. data/trieve_ruby_client-0.4.0.gem +0 -0
@@ -0,0 +1,105 @@
1
+ =begin
2
+ #Trieve API
3
+
4
+ #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
+
6
+ The version of the OpenAPI document: 0.5.7
7
+ Contact: developers@trieve.ai
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TrieveRubyClient
17
+ module RangeCondition
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'Float',
23
+ :'String'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = TrieveRubyClient.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
5
 
6
- The version of the OpenAPI document: 0.5.0
6
+ The version of the OpenAPI document: 0.5.7
7
7
  Contact: developers@trieve.ai
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.4.0
@@ -35,6 +35,9 @@ module TrieveRubyClient
35
35
  # The ids of the groups to be used as positive examples for the recommendation. The groups in this array will be used to find similar groups.
36
36
  attr_accessor :positive_group_tracking_ids
37
37
 
38
+ # Set slim_chunks to true to avoid returning the content and chunk_html of the chunks. This is useful for when you want to reduce amount of data over the wire for latency improvement. Default is false.
39
+ attr_accessor :slim_chunks
40
+
38
41
  # Attribute mapping from ruby-style variable name to JSON key.
39
42
  def self.attribute_map
40
43
  {
@@ -44,7 +47,8 @@ module TrieveRubyClient
44
47
  :'negative_group_ids' => :'negative_group_ids',
45
48
  :'negative_group_tracking_ids' => :'negative_group_tracking_ids',
46
49
  :'positive_group_ids' => :'positive_group_ids',
47
- :'positive_group_tracking_ids' => :'positive_group_tracking_ids'
50
+ :'positive_group_tracking_ids' => :'positive_group_tracking_ids',
51
+ :'slim_chunks' => :'slim_chunks'
48
52
  }
49
53
  end
50
54
 
@@ -62,7 +66,8 @@ module TrieveRubyClient
62
66
  :'negative_group_ids' => :'Array<String>',
63
67
  :'negative_group_tracking_ids' => :'Array<String>',
64
68
  :'positive_group_ids' => :'Array<String>',
65
- :'positive_group_tracking_ids' => :'Array<String>'
69
+ :'positive_group_tracking_ids' => :'Array<String>',
70
+ :'slim_chunks' => :'Boolean'
66
71
  }
67
72
  end
68
73
 
@@ -75,7 +80,8 @@ module TrieveRubyClient
75
80
  :'negative_group_ids',
76
81
  :'negative_group_tracking_ids',
77
82
  :'positive_group_ids',
78
- :'positive_group_tracking_ids'
83
+ :'positive_group_tracking_ids',
84
+ :'slim_chunks'
79
85
  ])
80
86
  end
81
87
 
@@ -129,6 +135,10 @@ module TrieveRubyClient
129
135
  self.positive_group_tracking_ids = value
130
136
  end
131
137
  end
138
+
139
+ if attributes.key?(:'slim_chunks')
140
+ self.slim_chunks = attributes[:'slim_chunks']
141
+ end
132
142
  end
133
143
 
134
144
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -187,7 +197,8 @@ module TrieveRubyClient
187
197
  negative_group_ids == o.negative_group_ids &&
188
198
  negative_group_tracking_ids == o.negative_group_tracking_ids &&
189
199
  positive_group_ids == o.positive_group_ids &&
190
- positive_group_tracking_ids == o.positive_group_tracking_ids
200
+ positive_group_tracking_ids == o.positive_group_tracking_ids &&
201
+ slim_chunks == o.slim_chunks
191
202
  end
192
203
 
193
204
  # @see the `==` method
@@ -199,7 +210,7 @@ module TrieveRubyClient
199
210
  # Calculates hash code according to all attributes.
200
211
  # @return [Integer] Hash code
201
212
  def hash
202
- [filters, group_size, limit, negative_group_ids, negative_group_tracking_ids, positive_group_ids, positive_group_tracking_ids].hash
213
+ [filters, group_size, limit, negative_group_ids, negative_group_tracking_ids, positive_group_ids, positive_group_tracking_ids, slim_chunks].hash
203
214
  end
204
215
 
205
216
  # Builds the object from hash
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
5
 
6
- The version of the OpenAPI document: 0.5.0
6
+ The version of the OpenAPI document: 0.5.7
7
7
  Contact: developers@trieve.ai
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.4.0
@@ -32,6 +32,9 @@ module TrieveRubyClient
32
32
  # The tracking_ids of the chunks to be used as positive examples for the recommendation. The chunks in this array will be used to find similar chunks.
33
33
  attr_accessor :positive_tracking_ids
34
34
 
35
+ # Set slim_chunks to true to avoid returning the content and chunk_html of the chunks. This is useful for when you want to reduce amount of data over the wire for latency improvement. Default is false.
36
+ attr_accessor :slim_chunks
37
+
35
38
  # Attribute mapping from ruby-style variable name to JSON key.
36
39
  def self.attribute_map
37
40
  {
@@ -40,7 +43,8 @@ module TrieveRubyClient
40
43
  :'negative_chunk_ids' => :'negative_chunk_ids',
41
44
  :'negative_tracking_ids' => :'negative_tracking_ids',
42
45
  :'positive_chunk_ids' => :'positive_chunk_ids',
43
- :'positive_tracking_ids' => :'positive_tracking_ids'
46
+ :'positive_tracking_ids' => :'positive_tracking_ids',
47
+ :'slim_chunks' => :'slim_chunks'
44
48
  }
45
49
  end
46
50
 
@@ -57,7 +61,8 @@ module TrieveRubyClient
57
61
  :'negative_chunk_ids' => :'Array<String>',
58
62
  :'negative_tracking_ids' => :'Array<String>',
59
63
  :'positive_chunk_ids' => :'Array<String>',
60
- :'positive_tracking_ids' => :'Array<String>'
64
+ :'positive_tracking_ids' => :'Array<String>',
65
+ :'slim_chunks' => :'Boolean'
61
66
  }
62
67
  end
63
68
 
@@ -69,7 +74,8 @@ module TrieveRubyClient
69
74
  :'negative_chunk_ids',
70
75
  :'negative_tracking_ids',
71
76
  :'positive_chunk_ids',
72
- :'positive_tracking_ids'
77
+ :'positive_tracking_ids',
78
+ :'slim_chunks'
73
79
  ])
74
80
  end
75
81
 
@@ -119,6 +125,10 @@ module TrieveRubyClient
119
125
  self.positive_tracking_ids = value
120
126
  end
121
127
  end
128
+
129
+ if attributes.key?(:'slim_chunks')
130
+ self.slim_chunks = attributes[:'slim_chunks']
131
+ end
122
132
  end
123
133
 
124
134
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -161,7 +171,8 @@ module TrieveRubyClient
161
171
  negative_chunk_ids == o.negative_chunk_ids &&
162
172
  negative_tracking_ids == o.negative_tracking_ids &&
163
173
  positive_chunk_ids == o.positive_chunk_ids &&
164
- positive_tracking_ids == o.positive_tracking_ids
174
+ positive_tracking_ids == o.positive_tracking_ids &&
175
+ slim_chunks == o.slim_chunks
165
176
  end
166
177
 
167
178
  # @see the `==` method
@@ -173,7 +184,7 @@ module TrieveRubyClient
173
184
  # Calculates hash code according to all attributes.
174
185
  # @return [Integer] Hash code
175
186
  def hash
176
- [filters, limit, negative_chunk_ids, negative_tracking_ids, positive_chunk_ids, positive_tracking_ids].hash
187
+ [filters, limit, negative_chunk_ids, negative_tracking_ids, positive_chunk_ids, positive_tracking_ids, slim_chunks].hash
177
188
  end
178
189
 
179
190
  # Builds the object from hash
@@ -0,0 +1,105 @@
1
+ =begin
2
+ #Trieve API
3
+
4
+ #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
+
6
+ The version of the OpenAPI document: 0.5.7
7
+ Contact: developers@trieve.ai
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TrieveRubyClient
17
+ module RecommendChunksResponseTypes
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'Array<ChunkMetadata>',
23
+ :'Array<SlimChunkMetadata>'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = TrieveRubyClient.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end
@@ -0,0 +1,105 @@
1
+ =begin
2
+ #Trieve API
3
+
4
+ #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
+
6
+ The version of the OpenAPI document: 0.5.7
7
+ Contact: developers@trieve.ai
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TrieveRubyClient
17
+ module RecommendGroupChunkResponseTypes
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'Array<GroupScoreChunkDTO>',
23
+ :'Array<GroupSlimChunksDTO>'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = TrieveRubyClient.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
5
 
6
- The version of the OpenAPI document: 0.5.0
6
+ The version of the OpenAPI document: 0.5.7
7
7
  Contact: developers@trieve.ai
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.4.0
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
5
 
6
- The version of the OpenAPI document: 0.5.0
6
+ The version of the OpenAPI document: 0.5.7
7
7
  Contact: developers@trieve.ai
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.4.0
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5
5
 
6
- The version of the OpenAPI document: 0.5.0
6
+ The version of the OpenAPI document: 0.5.7
7
7
  Contact: developers@trieve.ai
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.4.0