algolia 3.45.0 → 3.46.1

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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +2 -2
  3. data/AGENTS.md +0 -24
  4. data/CHANGELOG.md +30 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/abtesting_v3_client.rb +196 -7
  7. data/lib/algolia/api/agent_studio_client.rb +244 -6
  8. data/lib/algolia/api/recommend_client.rb +2 -2
  9. data/lib/algolia/api/search_client.rb +17 -3
  10. data/lib/algolia/configuration.rb +8 -0
  11. data/lib/algolia/defaults.rb +8 -0
  12. data/lib/algolia/models/abtesting-v3/ab_test.rb +25 -1
  13. data/lib/algolia/models/abtesting-v3/ab_test_configuration.rb +22 -4
  14. data/lib/algolia/models/abtesting-v3/ab_test_settings_response.rb +224 -0
  15. data/lib/algolia/models/abtesting-v3/add_ab_tests_request.rb +11 -1
  16. data/lib/algolia/models/abtesting-v3/analysis_method.rb +34 -0
  17. data/lib/algolia/models/abtesting-v3/bayesian_metric_result.rb +237 -0
  18. data/lib/algolia/models/abtesting-v3/evidence_status.rb +37 -0
  19. data/lib/algolia/models/abtesting-v3/feature_settings.rb +224 -0
  20. data/lib/algolia/models/abtesting-v3/metric_evidence.rb +209 -0
  21. data/lib/algolia/models/abtesting-v3/metric_metadata.rb +1 -1
  22. data/lib/algolia/models/abtesting-v3/metric_name.rb +7 -1
  23. data/lib/algolia/models/abtesting-v3/metric_result.rb +18 -8
  24. data/lib/algolia/models/abtesting-v3/minimum_detectable_effect.rb +1 -1
  25. data/lib/algolia/models/abtesting-v3/primary_metric.rb +37 -0
  26. data/lib/algolia/models/abtesting-v3/save_settings_request.rb +208 -0
  27. data/lib/algolia/models/abtesting-v3/variant_settings.rb +293 -0
  28. data/lib/algolia/models/agent-studio/agent_completion_algolia_params.rb +16 -4
  29. data/lib/algolia/models/agent-studio/agent_completion_request.rb +1 -3
  30. data/lib/algolia/models/agent-studio/agent_completion_request_union.rb +108 -0
  31. data/lib/algolia/models/agent-studio/agent_test_configuration.rb +1 -1
  32. data/lib/algolia/models/agent-studio/agent_with_version_response.rb +1 -1
  33. data/lib/algolia/models/agent-studio/agui_completion_request.rb +265 -0
  34. data/lib/algolia/models/agent-studio/agui_resume.rb +231 -0
  35. data/lib/algolia/models/agent-studio/algolia_grouped_results_compat_tool_config.rb +268 -0
  36. data/lib/algolia/models/agent-studio/{algolia_display_results_tool_config.rb → algolia_grouped_results_tool_config.rb} +30 -16
  37. data/lib/algolia/models/agent-studio/{algolia_recommend_tool_config_input.rb → algolia_recommend_tool_config.rb} +3 -3
  38. data/lib/algolia/models/agent-studio/algolia_search_tool_config.rb +22 -4
  39. data/lib/algolia/models/agent-studio/assistant_message_agui.rb +280 -0
  40. data/lib/algolia/models/agent-studio/assistant_message_v4.rb +1 -0
  41. data/lib/algolia/models/agent-studio/assistant_message_v5.rb +3 -1
  42. data/lib/algolia/models/agent-studio/assistant_part_v5.rb +2 -0
  43. data/lib/algolia/models/agent-studio/azure_open_ai_provider_input.rb +1 -1
  44. data/lib/algolia/models/agent-studio/boolean_param.rb +220 -0
  45. data/lib/algolia/models/agent-studio/client_side_tool_config.rb +14 -4
  46. data/lib/algolia/models/agent-studio/compaction_stats.rb +271 -0
  47. data/lib/algolia/models/agent-studio/compatibility_mode.rb +2 -1
  48. data/lib/algolia/models/agent-studio/context_compact_request.rb +263 -0
  49. data/lib/algolia/models/agent-studio/context_response.rb +231 -0
  50. data/lib/algolia/models/agent-studio/context_stats.rb +258 -0
  51. data/lib/algolia/models/agent-studio/context_trim_request.rb +239 -0
  52. data/lib/algolia/models/agent-studio/conversation_base_response.rb +16 -5
  53. data/lib/algolia/models/agent-studio/conversation_full_response.rb +26 -5
  54. data/lib/algolia/models/agent-studio/data_guardrail_violation_part_v5.rb +218 -0
  55. data/lib/algolia/models/agent-studio/data_part_v5.rb +220 -0
  56. data/lib/algolia/models/agent-studio/facet_filters_union_search_parameters_overrides.rb +108 -0
  57. data/lib/algolia/models/agent-studio/feedback_update_request.rb +253 -0
  58. data/lib/algolia/models/agent-studio/forwarded_props.rb +226 -0
  59. data/lib/algolia/models/agent-studio/function_call_agui.rb +219 -0
  60. data/lib/algolia/models/agent-studio/guardrail_outcome.rb +231 -0
  61. data/lib/algolia/models/agent-studio/guardrail_violation_data_v5.rb +230 -0
  62. data/lib/algolia/models/agent-studio/impact_analytics.rb +242 -0
  63. data/lib/algolia/models/agent-studio/index_search_parameters.rb +11 -1
  64. data/lib/algolia/models/agent-studio/input_union.rb +113 -0
  65. data/lib/algolia/models/agent-studio/items_union.rb +132 -0
  66. data/lib/algolia/models/agent-studio/items_union_agui_completion_request.rb +123 -0
  67. data/lib/algolia/models/agent-studio/managed_provider_response_input.rb +209 -0
  68. data/lib/algolia/models/agent-studio/mcp_server_tool_config.rb +1 -1
  69. data/lib/algolia/models/agent-studio/memory_record.rb +4 -4
  70. data/lib/algolia/models/agent-studio/message_event.rb +231 -0
  71. data/lib/algolia/models/agent-studio/message_part_assistant_message_agui.rb +123 -0
  72. data/lib/algolia/models/agent-studio/message_response.rb +87 -5
  73. data/lib/algolia/models/agent-studio/mode_enum.rb +34 -0
  74. data/lib/algolia/models/agent-studio/one_of_enum.rb +34 -0
  75. data/lib/algolia/models/agent-studio/open_ai_compatible_provider_input.rb +1 -1
  76. data/lib/algolia/models/agent-studio/paginated_conversations_response.rb +13 -4
  77. data/lib/algolia/models/agent-studio/provider_authentication_response.rb +14 -5
  78. data/lib/algolia/models/agent-studio/provider_input.rb +2 -1
  79. data/lib/algolia/models/agent-studio/provider_input_nullable.rb +2 -1
  80. data/lib/algolia/models/agent-studio/provider_name.rb +2 -1
  81. data/lib/algolia/models/agent-studio/reasoning_message_agui.rb +239 -0
  82. data/lib/algolia/models/agent-studio/reasoning_part_agui.rb +228 -0
  83. data/lib/algolia/models/agent-studio/search_parameters.rb +1 -1
  84. data/lib/algolia/models/agent-studio/search_parameters_overrides.rb +80 -5
  85. data/lib/algolia/models/agent-studio/status_enum.rb +34 -0
  86. data/lib/algolia/models/agent-studio/task_kind.rb +33 -0
  87. data/lib/algolia/models/agent-studio/task_request.rb +240 -0
  88. data/lib/algolia/models/agent-studio/task_response.rb +211 -0
  89. data/lib/algolia/models/agent-studio/text_part_agui.rb +219 -0
  90. data/lib/algolia/models/agent-studio/tool_approval_agui.rb +228 -0
  91. data/lib/algolia/models/agent-studio/tool_approval_request_part.rb +15 -5
  92. data/lib/algolia/models/agent-studio/tool_call_agui.rb +237 -0
  93. data/lib/algolia/models/agent-studio/tool_call_part.rb +13 -1
  94. data/lib/algolia/models/agent-studio/tool_call_part_agui.rb +272 -0
  95. data/lib/algolia/models/agent-studio/tool_call_result_part_agui.rb +250 -0
  96. data/lib/algolia/models/agent-studio/tool_config_input.rb +2 -5
  97. data/lib/algolia/models/agent-studio/{tool_config.rb → tool_config_or_boolean_union.rb} +1 -1
  98. data/lib/algolia/models/agent-studio/tool_config_output.rb +126 -0
  99. data/lib/algolia/models/agent-studio/tool_invocation_v4.rb +10 -2
  100. data/lib/algolia/models/agent-studio/tool_message_agui.rb +259 -0
  101. data/lib/algolia/models/agent-studio/tool_part_v5.rb +47 -2
  102. data/lib/algolia/models/agent-studio/tool_result_part.rb +57 -5
  103. data/lib/algolia/models/agent-studio/unknown_tool_config.rb +1 -1
  104. data/lib/algolia/models/agent-studio/user_message_agui.rb +261 -0
  105. data/lib/algolia/models/agent-studio/user_message_metadata_agui.rb +208 -0
  106. data/lib/algolia/models/agent-studio/user_message_metadata_v5.rb +4 -2
  107. data/lib/algolia/models/agent-studio/user_message_v4.rb +4 -1
  108. data/lib/algolia/models/agent-studio/user_message_v5.rb +4 -1
  109. data/lib/algolia/models/agent-studio/validation_error.rb +5 -25
  110. data/lib/algolia/models/agent-studio/xai_provider_input.rb +220 -0
  111. data/lib/algolia/models/analytics/catalog_entry.rb +1 -1
  112. data/lib/algolia/models/composition/base_injection_query_parameters.rb +18 -18
  113. data/lib/algolia/models/composition/distinct.rb +1 -1
  114. data/lib/algolia/models/composition/external_provider.rb +209 -0
  115. data/lib/algolia/models/composition/external_provider_ordering.rb +34 -0
  116. data/lib/algolia/models/composition/hit_metadata.rb +2 -2
  117. data/lib/algolia/models/composition/injected_item_external.rb +21 -14
  118. data/lib/algolia/models/composition/injected_item_external_provider.rb +258 -0
  119. data/lib/algolia/models/composition/injected_item_external_provider_source.rb +216 -0
  120. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +1 -1
  121. data/lib/algolia/models/composition/{recommend.rb → injected_item_recommend.rb} +10 -3
  122. data/lib/algolia/models/composition/injected_item_recommend_source.rb +1 -1
  123. data/lib/algolia/models/composition/injected_item_search.rb +8 -1
  124. data/lib/algolia/models/composition/injected_item_source.rb +1 -0
  125. data/lib/algolia/models/composition/injection_main_external_provider.rb +258 -0
  126. data/lib/algolia/models/composition/injection_main_external_provider_source.rb +216 -0
  127. data/lib/algolia/models/composition/{main_recommend.rb → injection_main_recommend.rb} +10 -3
  128. data/lib/algolia/models/composition/injection_main_recommend_source.rb +1 -1
  129. data/lib/algolia/models/composition/{main_search.rb → injection_main_search.rb} +11 -4
  130. data/lib/algolia/models/composition/injection_main_search_source.rb +1 -1
  131. data/lib/algolia/models/composition/injection_main_source.rb +1 -0
  132. data/lib/algolia/models/composition/main_injection_query_parameters.rb +22 -22
  133. data/lib/algolia/models/composition/optional_words.rb +1 -1
  134. data/lib/algolia/models/composition/params.rb +6 -6
  135. data/lib/algolia/models/composition/processing_error.rb +209 -0
  136. data/lib/algolia/models/composition/request_body.rb +13 -4
  137. data/lib/algolia/models/composition/result_card.rb +208 -0
  138. data/lib/algolia/models/composition/search_response.rb +16 -4
  139. data/lib/algolia/models/composition/widgets.rb +13 -4
  140. data/lib/algolia/models/ingestion/source_update_commercetools.rb +11 -0
  141. data/lib/algolia/models/recommend/distinct.rb +1 -1
  142. data/lib/algolia/models/recommend/fallback_params.rb +26 -26
  143. data/lib/algolia/models/recommend/optional_words.rb +1 -1
  144. data/lib/algolia/models/recommend/recommend_search_params.rb +26 -26
  145. data/lib/algolia/models/recommend/result_card.rb +208 -0
  146. data/lib/algolia/models/recommend/widgets.rb +13 -4
  147. data/lib/algolia/models/search/api_key.rb +2 -2
  148. data/lib/algolia/models/search/attribute_criteria_computed_by.rb +35 -0
  149. data/lib/algolia/models/search/browse_params_object.rb +35 -25
  150. data/lib/algolia/models/search/consequence_params.rb +35 -25
  151. data/lib/algolia/models/search/distinct.rb +1 -1
  152. data/lib/algolia/models/search/get_api_key_response.rb +2 -2
  153. data/lib/algolia/models/search/index_settings.rb +28 -18
  154. data/lib/algolia/models/search/optional_words.rb +1 -1
  155. data/lib/algolia/models/search/result_card.rb +208 -0
  156. data/lib/algolia/models/search/search_for_facets.rb +35 -25
  157. data/lib/algolia/models/search/search_for_hits.rb +35 -25
  158. data/lib/algolia/models/search/search_params_object.rb +35 -25
  159. data/lib/algolia/models/search/secured_api_key_restrictions.rb +1 -1
  160. data/lib/algolia/models/search/settings_response.rb +28 -18
  161. data/lib/algolia/models/search/widgets.rb +13 -4
  162. data/lib/algolia/transport/transport.rb +82 -10
  163. data/lib/algolia/version.rb +1 -1
  164. metadata +72 -8
@@ -0,0 +1,261 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module AgentStudio
10
+ class UserMessageAGUI
11
+ attr_accessor :id
12
+
13
+ attr_accessor :role
14
+
15
+ attr_accessor :parts
16
+
17
+ attr_accessor :created_at
18
+
19
+ attr_accessor :content
20
+
21
+ attr_accessor :metadata
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :id => :id,
27
+ :role => :role,
28
+ :parts => :parts,
29
+ :created_at => :createdAt,
30
+ :content => :content,
31
+ :metadata => :metadata
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.types_mapping
37
+ {
38
+ :id => :"String",
39
+ :role => :"String",
40
+ :parts => :"Array<TextPartAGUI>",
41
+ :created_at => :"String",
42
+ :content => :"String",
43
+ :metadata => :"UserMessageMetadataAGUI"
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new(
50
+ [
51
+ :parts
52
+ ]
53
+ )
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ raise(
61
+ ArgumentError,
62
+ "The input argument (attributes) must be a hash in `Algolia::UserMessageAGUI` initialize method"
63
+ )
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ raise(
70
+ ArgumentError,
71
+ "`#{k}` is not a valid attribute in `Algolia::UserMessageAGUI`. Please check the name to make sure it's valid. List of attributes: " +
72
+ self.class.attribute_map.keys.inspect
73
+ )
74
+ end
75
+
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:id)
80
+ self.id = attributes[:id]
81
+ else
82
+ self.id = nil
83
+ end
84
+
85
+ if attributes.key?(:role)
86
+ self.role = attributes[:role]
87
+ else
88
+ self.role = nil
89
+ end
90
+
91
+ if attributes.key?(:parts)
92
+ if (value = attributes[:parts]).is_a?(Array)
93
+ self.parts = value
94
+ end
95
+ end
96
+
97
+ if attributes.key?(:created_at)
98
+ self.created_at = attributes[:created_at]
99
+ end
100
+
101
+ if attributes.key?(:content)
102
+ self.content = attributes[:content]
103
+ else
104
+ self.content = nil
105
+ end
106
+
107
+ if attributes.key?(:metadata)
108
+ self.metadata = attributes[:metadata]
109
+ end
110
+ end
111
+
112
+ # Checks equality by comparing each attribute.
113
+ # @param [Object] Object to be compared
114
+ def ==(other)
115
+ return true if self.equal?(other)
116
+ self.class == other.class &&
117
+ id == other.id &&
118
+ role == other.role &&
119
+ parts == other.parts &&
120
+ created_at == other.created_at &&
121
+ content == other.content &&
122
+ metadata == other.metadata
123
+ end
124
+
125
+ # @see the `==` method
126
+ # @param [Object] Object to be compared
127
+ def eql?(other)
128
+ self == other
129
+ end
130
+
131
+ # Calculates hash code according to all attributes.
132
+ # @return [Integer] Hash code
133
+ def hash
134
+ [id, role, parts, created_at, content, metadata].hash
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def self.build_from_hash(attributes)
141
+ return nil unless attributes.is_a?(Hash)
142
+ attributes = attributes.transform_keys(&:to_sym)
143
+ transformed_hash = {}
144
+ types_mapping.each_pair do |key, type|
145
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
146
+ transformed_hash[key.to_sym] = nil
147
+ elsif type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[attribute_map[key]].is_a?(Array)
151
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
152
+ _deserialize(::Regexp.last_match(1), v)
153
+ }
154
+ end
155
+ elsif !attributes[attribute_map[key]].nil?
156
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
157
+ end
158
+ end
159
+
160
+ new(transformed_hash)
161
+ end
162
+
163
+ # Deserializes the data based on type
164
+ # @param string type Data type
165
+ # @param string value Value to be deserialized
166
+ # @return [Object] Deserialized data
167
+ def self._deserialize(type, value)
168
+ case type.to_sym
169
+ when :Time
170
+ Time.parse(value)
171
+ when :Date
172
+ Date.parse(value)
173
+ when :String
174
+ value.to_s
175
+ when :Integer
176
+ value.to_i
177
+ when :Float
178
+ value.to_f
179
+ when :Boolean
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
+ true
182
+ else
183
+ false
184
+ end
185
+
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ # model
201
+ else
202
+ # models (e.g. Pet) or oneOf
203
+ klass = Algolia::AgentStudio.const_get(type)
204
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
205
+ .build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ def to_json(*_args)
222
+ to_hash.to_json
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+
239
+ hash
240
+ end
241
+
242
+ # Outputs non-array value in the form of hash
243
+ # For object, use to_hash. Otherwise, just return the value
244
+ # @param [Object] value Any valid value
245
+ # @return [Hash] Returns the value in the form of hash
246
+ def _to_hash(value)
247
+ if value.is_a?(Array)
248
+ value.map { |v| _to_hash(v) }
249
+ elsif value.is_a?(Hash)
250
+ {}.tap do |hash|
251
+ value.each { |k, v| hash[k] = _to_hash(v) }
252
+ end
253
+ elsif value.respond_to?(:to_hash)
254
+ value.to_hash
255
+ else
256
+ value
257
+ end
258
+ end
259
+ end
260
+ end
261
+ end
@@ -0,0 +1,208 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module AgentStudio
10
+ class UserMessageMetadataAGUI
11
+ attr_accessor :turn_context
12
+
13
+ # Attribute mapping from ruby-style variable name to JSON key.
14
+ def self.attribute_map
15
+ {
16
+ :turn_context => :turnContext
17
+ }
18
+ end
19
+
20
+ # Attribute type mapping.
21
+ def self.types_mapping
22
+ {
23
+ :turn_context => :"Hash<String, Object>"
24
+ }
25
+ end
26
+
27
+ # List of attributes with nullable: true
28
+ def self.openapi_nullable
29
+ Set.new(
30
+ []
31
+ )
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ raise(
39
+ ArgumentError,
40
+ "The input argument (attributes) must be a hash in `Algolia::UserMessageMetadataAGUI` initialize method"
41
+ )
42
+ end
43
+
44
+ # check to see if the attribute exists and convert string to symbol for hash key
45
+ attributes = attributes.each_with_object({}) { |(k, v), h|
46
+ if (!self.class.attribute_map.key?(k.to_sym))
47
+ raise(
48
+ ArgumentError,
49
+ "`#{k}` is not a valid attribute in `Algolia::UserMessageMetadataAGUI`. Please check the name to make sure it's valid. List of attributes: " +
50
+ self.class.attribute_map.keys.inspect
51
+ )
52
+ end
53
+
54
+ h[k.to_sym] = v
55
+ }
56
+
57
+ if attributes.key?(:turn_context)
58
+ if (value = attributes[:turn_context]).is_a?(Hash)
59
+ self.turn_context = value
60
+ end
61
+ end
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(other)
67
+ return true if self.equal?(other)
68
+ self.class == other.class &&
69
+ turn_context == other.turn_context
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(other)
75
+ self == other
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Integer] Hash code
80
+ def hash
81
+ [turn_context].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def self.build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ attributes = attributes.transform_keys(&:to_sym)
90
+ transformed_hash = {}
91
+ types_mapping.each_pair do |key, type|
92
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
93
+ transformed_hash[key.to_sym] = nil
94
+ elsif type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[attribute_map[key]].is_a?(Array)
98
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
99
+ _deserialize(::Regexp.last_match(1), v)
100
+ }
101
+ end
102
+ elsif !attributes[attribute_map[key]].nil?
103
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
104
+ end
105
+ end
106
+
107
+ new(transformed_hash)
108
+ end
109
+
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
114
+ def self._deserialize(type, value)
115
+ case type.to_sym
116
+ when :Time
117
+ Time.parse(value)
118
+ when :Date
119
+ Date.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :Boolean
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+
133
+ when :Object
134
+ # generic object (usually a Hash), return directly
135
+ value
136
+ when /\AArray<(?<inner_type>.+)>\z/
137
+ inner_type = Regexp.last_match[:inner_type]
138
+ value.map { |v| _deserialize(inner_type, v) }
139
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
+ k_type = Regexp.last_match[:k_type]
141
+ v_type = Regexp.last_match[:v_type]
142
+ {}.tap do |hash|
143
+ value.each do |k, v|
144
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
+ end
146
+ end
147
+ # model
148
+ else
149
+ # models (e.g. Pet) or oneOf
150
+ klass = Algolia::AgentStudio.const_get(type)
151
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
152
+ .build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ def to_json(*_args)
169
+ to_hash.to_json
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.map { |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to?(:to_hash)
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
@@ -7,7 +7,7 @@ require "time"
7
7
 
8
8
  module Algolia
9
9
  module AgentStudio
10
- # Client-supplied metadata on a v5 user message. `turn_context` is namespaced so other callers can use `metadata` for unrelated purposes without collision. Unknown keys are preserved and ignored by this pipeline. Note: `turn_context` is deliberately typed `dict[str, Any]` (not `TurnContext`). The metadata is parsed eagerly with the request body, but cap/charset validation must be deferred to `extract_turn_context_v5` so the kill-switch (`TURN_CONTEXT_ENABLED=false`) can silently drop payloads instead of 422-ing. See `test_invalid_metadata_does_not_raise_at_model_construction`.
10
+ # Client-supplied metadata on a v5 user message. `turn_context` is namespaced so other callers can use `metadata` for unrelated purposes without collision. Unknown keys are preserved and ignored by this pipeline. `turn_context` accepts any JSON object (arbitrarily nested values, no size caps). A value that cannot be serialized as JSON is rejected with a 422.
11
11
  class UserMessageMetadataV5
12
12
  attr_accessor :turn_context
13
13
 
@@ -30,7 +30,9 @@ module Algolia
30
30
  # List of attributes with nullable: true
31
31
  def self.openapi_nullable
32
32
  Set.new(
33
- []
33
+ [
34
+ :turn_context
35
+ ]
34
36
  )
35
37
  end
36
38
 
@@ -43,7 +43,10 @@ module Algolia
43
43
  # List of attributes with nullable: true
44
44
  def self.openapi_nullable
45
45
  Set.new(
46
- []
46
+ [
47
+ :id,
48
+ :annotations
49
+ ]
47
50
  )
48
51
  end
49
52
 
@@ -39,7 +39,10 @@ module Algolia
39
39
  # List of attributes with nullable: true
40
40
  def self.openapi_nullable
41
41
  Set.new(
42
- []
42
+ [
43
+ :id,
44
+ :metadata
45
+ ]
43
46
  )
44
47
  end
45
48
 
@@ -14,18 +14,12 @@ module Algolia
14
14
 
15
15
  attr_accessor :type
16
16
 
17
- attr_accessor :input
18
-
19
- attr_accessor :ctx
20
-
21
17
  # Attribute mapping from ruby-style variable name to JSON key.
22
18
  def self.attribute_map
23
19
  {
24
20
  :loc => :loc,
25
21
  :msg => :msg,
26
- :type => :type,
27
- :input => :input,
28
- :ctx => :ctx
22
+ :type => :type
29
23
  }
30
24
  end
31
25
 
@@ -34,18 +28,14 @@ module Algolia
34
28
  {
35
29
  :loc => :"Array<LocationItemUnion>",
36
30
  :msg => :"String",
37
- :type => :"String",
38
- :input => :"Object",
39
- :ctx => :"Object"
31
+ :type => :"String"
40
32
  }
41
33
  end
42
34
 
43
35
  # List of attributes with nullable: true
44
36
  def self.openapi_nullable
45
37
  Set.new(
46
- [
47
- :input
48
- ]
38
+ []
49
39
  )
50
40
  end
51
41
 
@@ -91,14 +81,6 @@ module Algolia
91
81
  else
92
82
  self.type = nil
93
83
  end
94
-
95
- if attributes.key?(:input)
96
- self.input = attributes[:input]
97
- end
98
-
99
- if attributes.key?(:ctx)
100
- self.ctx = attributes[:ctx]
101
- end
102
84
  end
103
85
 
104
86
  # Checks equality by comparing each attribute.
@@ -108,9 +90,7 @@ module Algolia
108
90
  self.class == other.class &&
109
91
  loc == other.loc &&
110
92
  msg == other.msg &&
111
- type == other.type &&
112
- input == other.input &&
113
- ctx == other.ctx
93
+ type == other.type
114
94
  end
115
95
 
116
96
  # @see the `==` method
@@ -122,7 +102,7 @@ module Algolia
122
102
  # Calculates hash code according to all attributes.
123
103
  # @return [Integer] Hash code
124
104
  def hash
125
- [loc, msg, type, input, ctx].hash
105
+ [loc, msg, type].hash
126
106
  end
127
107
 
128
108
  # Builds the object from hash