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,272 @@
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 ToolCallPartAGUI
11
+ attr_accessor :id
12
+
13
+ attr_accessor :type
14
+
15
+ attr_accessor :name
16
+
17
+ attr_accessor :arguments
18
+
19
+ attr_accessor :state
20
+
21
+ attr_accessor :output
22
+
23
+ attr_accessor :approval
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :id => :id,
29
+ :type => :type,
30
+ :name => :name,
31
+ :arguments => :arguments,
32
+ :state => :state,
33
+ :output => :output,
34
+ :approval => :approval
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.types_mapping
40
+ {
41
+ :id => :"String",
42
+ :type => :"String",
43
+ :name => :"String",
44
+ :arguments => :"String",
45
+ :state => :"String",
46
+ :output => :"Hash<String, Object>",
47
+ :approval => :"ToolApprovalAGUI"
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new(
54
+ []
55
+ )
56
+ end
57
+
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
60
+ def initialize(attributes = {})
61
+ if (!attributes.is_a?(Hash))
62
+ raise(
63
+ ArgumentError,
64
+ "The input argument (attributes) must be a hash in `Algolia::ToolCallPartAGUI` initialize method"
65
+ )
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ raise(
72
+ ArgumentError,
73
+ "`#{k}` is not a valid attribute in `Algolia::ToolCallPartAGUI`. Please check the name to make sure it's valid. List of attributes: " +
74
+ self.class.attribute_map.keys.inspect
75
+ )
76
+ end
77
+
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:id)
82
+ self.id = attributes[:id]
83
+ else
84
+ self.id = nil
85
+ end
86
+
87
+ if attributes.key?(:type)
88
+ self.type = attributes[:type]
89
+ else
90
+ self.type = nil
91
+ end
92
+
93
+ if attributes.key?(:name)
94
+ self.name = attributes[:name]
95
+ else
96
+ self.name = nil
97
+ end
98
+
99
+ if attributes.key?(:arguments)
100
+ self.arguments = attributes[:arguments]
101
+ else
102
+ self.arguments = nil
103
+ end
104
+
105
+ if attributes.key?(:state)
106
+ self.state = attributes[:state]
107
+ else
108
+ self.state = nil
109
+ end
110
+
111
+ if attributes.key?(:output)
112
+ if (value = attributes[:output]).is_a?(Hash)
113
+ self.output = value
114
+ end
115
+ end
116
+
117
+ if attributes.key?(:approval)
118
+ self.approval = attributes[:approval]
119
+ end
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(other)
125
+ return true if self.equal?(other)
126
+ self.class == other.class &&
127
+ id == other.id &&
128
+ type == other.type &&
129
+ name == other.name &&
130
+ arguments == other.arguments &&
131
+ state == other.state &&
132
+ output == other.output &&
133
+ approval == other.approval
134
+ end
135
+
136
+ # @see the `==` method
137
+ # @param [Object] Object to be compared
138
+ def eql?(other)
139
+ self == other
140
+ end
141
+
142
+ # Calculates hash code according to all attributes.
143
+ # @return [Integer] Hash code
144
+ def hash
145
+ [id, type, name, arguments, state, output, approval].hash
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def self.build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+ attributes = attributes.transform_keys(&:to_sym)
154
+ transformed_hash = {}
155
+ types_mapping.each_pair do |key, type|
156
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
157
+ transformed_hash[key.to_sym] = nil
158
+ elsif type =~ /\AArray<(.*)>/i
159
+ # check to ensure the input is an array given that the attribute
160
+ # is documented as an array but the input is not
161
+ if attributes[attribute_map[key]].is_a?(Array)
162
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
163
+ _deserialize(::Regexp.last_match(1), v)
164
+ }
165
+ end
166
+ elsif !attributes[attribute_map[key]].nil?
167
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
168
+ end
169
+ end
170
+
171
+ new(transformed_hash)
172
+ end
173
+
174
+ # Deserializes the data based on type
175
+ # @param string type Data type
176
+ # @param string value Value to be deserialized
177
+ # @return [Object] Deserialized data
178
+ def self._deserialize(type, value)
179
+ case type.to_sym
180
+ when :Time
181
+ Time.parse(value)
182
+ when :Date
183
+ Date.parse(value)
184
+ when :String
185
+ value.to_s
186
+ when :Integer
187
+ value.to_i
188
+ when :Float
189
+ value.to_f
190
+ when :Boolean
191
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
192
+ true
193
+ else
194
+ false
195
+ end
196
+
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ # model
212
+ else
213
+ # models (e.g. Pet) or oneOf
214
+ klass = Algolia::AgentStudio.const_get(type)
215
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
216
+ .build_from_hash(value)
217
+ end
218
+ end
219
+
220
+ # Returns the string representation of the object
221
+ # @return [String] String presentation of the object
222
+ def to_s
223
+ to_hash.to_s
224
+ end
225
+
226
+ # to_body is an alias to to_hash (backward compatibility)
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_body
229
+ to_hash
230
+ end
231
+
232
+ def to_json(*_args)
233
+ to_hash.to_json
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to?(:to_hash)
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
@@ -0,0 +1,250 @@
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 ToolCallResultPartAGUI
11
+ attr_accessor :tool_call_id
12
+
13
+ attr_accessor :state
14
+
15
+ attr_accessor :type
16
+
17
+ attr_accessor :content
18
+
19
+ attr_accessor :error
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :tool_call_id => :toolCallId,
25
+ :state => :state,
26
+ :type => :type,
27
+ :content => :content,
28
+ :error => :error
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.types_mapping
34
+ {
35
+ :tool_call_id => :"String",
36
+ :state => :"String",
37
+ :type => :"String",
38
+ :content => :"String",
39
+ :error => :"String"
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new(
46
+ []
47
+ )
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ raise(
55
+ ArgumentError,
56
+ "The input argument (attributes) must be a hash in `Algolia::ToolCallResultPartAGUI` initialize method"
57
+ )
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ raise(
64
+ ArgumentError,
65
+ "`#{k}` is not a valid attribute in `Algolia::ToolCallResultPartAGUI`. Please check the name to make sure it's valid. List of attributes: " +
66
+ self.class.attribute_map.keys.inspect
67
+ )
68
+ end
69
+
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:tool_call_id)
74
+ self.tool_call_id = attributes[:tool_call_id]
75
+ else
76
+ self.tool_call_id = nil
77
+ end
78
+
79
+ if attributes.key?(:state)
80
+ self.state = attributes[:state]
81
+ else
82
+ self.state = nil
83
+ end
84
+
85
+ if attributes.key?(:type)
86
+ self.type = attributes[:type]
87
+ else
88
+ self.type = nil
89
+ end
90
+
91
+ if attributes.key?(:content)
92
+ self.content = attributes[:content]
93
+ else
94
+ self.content = nil
95
+ end
96
+
97
+ if attributes.key?(:error)
98
+ self.error = attributes[:error]
99
+ end
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(other)
105
+ return true if self.equal?(other)
106
+ self.class == other.class &&
107
+ tool_call_id == other.tool_call_id &&
108
+ state == other.state &&
109
+ type == other.type &&
110
+ content == other.content &&
111
+ error == other.error
112
+ end
113
+
114
+ # @see the `==` method
115
+ # @param [Object] Object to be compared
116
+ def eql?(other)
117
+ self == other
118
+ end
119
+
120
+ # Calculates hash code according to all attributes.
121
+ # @return [Integer] Hash code
122
+ def hash
123
+ [tool_call_id, state, type, content, error].hash
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ transformed_hash = {}
133
+ types_mapping.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash[key.to_sym] = nil
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
141
+ _deserialize(::Regexp.last_match(1), v)
142
+ }
143
+ end
144
+ elsif !attributes[attribute_map[key]].nil?
145
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
146
+ end
147
+ end
148
+
149
+ new(transformed_hash)
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def self._deserialize(type, value)
157
+ case type.to_sym
158
+ when :Time
159
+ Time.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ # model
190
+ else
191
+ # models (e.g. Pet) or oneOf
192
+ klass = Algolia::AgentStudio.const_get(type)
193
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
194
+ .build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ def to_json(*_args)
211
+ to_hash.to_json
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+
228
+ hash
229
+ end
230
+
231
+ # Outputs non-array value in the form of hash
232
+ # For object, use to_hash. Otherwise, just return the value
233
+ # @param [Object] value Any valid value
234
+ # @return [Hash] Returns the value in the form of hash
235
+ def _to_hash(value)
236
+ if value.is_a?(Array)
237
+ value.map { |v| _to_hash(v) }
238
+ elsif value.is_a?(Hash)
239
+ {}.tap do |hash|
240
+ value.each { |k, v| hash[k] = _to_hash(v) }
241
+ end
242
+ elsif value.respond_to?(:to_hash)
243
+ value.to_hash
244
+ else
245
+ value
246
+ end
247
+ end
248
+ end
249
+ end
250
+ end
@@ -12,8 +12,7 @@ module Algolia
12
12
  # List of class defined in oneOf (OpenAPI v3)
13
13
  def openapi_one_of
14
14
  [
15
- :"AlgoliaDisplayResultsToolConfig",
16
- :"AlgoliaRecommendToolConfigInput",
15
+ :"AlgoliaRecommendToolConfig",
17
16
  :"AlgoliaSearchToolConfig",
18
17
  :"ClientSideToolConfig",
19
18
  :"McpServerToolConfig",
@@ -34,10 +33,8 @@ module Algolia
34
33
  # - TODO: logging when debugging is set.
35
34
  if data.is_a?(Hash) && data.key?("type")
36
35
  case data["type"]
37
- when "algolia_display_results"
38
- return find_and_cast_into_type(:"AlgoliaDisplayResultsToolConfig", data)
39
36
  when "algolia_recommend"
40
- return find_and_cast_into_type(:"AlgoliaRecommendToolConfigInput", data)
37
+ return find_and_cast_into_type(:"AlgoliaRecommendToolConfig", data)
41
38
  when "algolia_search_index"
42
39
  return find_and_cast_into_type(:"AlgoliaSearchToolConfig", data)
43
40
  when "client_side"
@@ -7,7 +7,7 @@ require "time"
7
7
 
8
8
  module Algolia
9
9
  module AgentStudio
10
- module ToolConfig
10
+ module ToolConfigOrBooleanUnion
11
11
  class << self
12
12
  # List of class defined in oneOf (OpenAPI v3)
13
13
  def openapi_one_of
@@ -0,0 +1,126 @@
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
+ module ToolConfigOutput
11
+ class << self
12
+ # List of class defined in oneOf (OpenAPI v3)
13
+ def openapi_one_of
14
+ [
15
+ :"AlgoliaRecommendToolConfig",
16
+ :"AlgoliaSearchToolConfig",
17
+ :"ClientSideToolConfig",
18
+ :"McpServerToolConfig",
19
+ :"UnknownToolConfig"
20
+ ]
21
+ end
22
+
23
+ # Builds the object
24
+ # @param [Mixed] Data to be matched against the list of oneOf items
25
+ # @return [Object] Returns the model or the data itself
26
+ def build(data)
27
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
28
+ # Note:
29
+ # - We do not attempt to check whether exactly one item matches.
30
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
31
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
32
+ # - TODO: scalar values are de facto behaving as if they were nullable.
33
+ # - TODO: logging when debugging is set.
34
+ if data.is_a?(Hash) && data.key?("type")
35
+ case data["type"]
36
+ when "algolia_recommend"
37
+ return find_and_cast_into_type(:"AlgoliaRecommendToolConfig", data)
38
+ when "algolia_search_index"
39
+ return find_and_cast_into_type(:"AlgoliaSearchToolConfig", data)
40
+ when "client_side"
41
+ return find_and_cast_into_type(:"ClientSideToolConfig", data)
42
+ when "mcp_tools"
43
+ return find_and_cast_into_type(:"McpServerToolConfig", data)
44
+ when "unknown"
45
+ return find_and_cast_into_type(:"UnknownToolConfig", data)
46
+ end
47
+ end
48
+
49
+ openapi_one_of.each do |klass|
50
+ begin
51
+ # "nullable: true"
52
+ next if klass == :AnyType
53
+ typed_data = find_and_cast_into_type(klass, data)
54
+ return typed_data if typed_data
55
+ # rescue all errors so we keep iterating even if the current item lookup raises
56
+ rescue
57
+ end
58
+ end
59
+
60
+ openapi_one_of.include?(:AnyType) ? data : nil
61
+ end
62
+
63
+ private
64
+
65
+ SchemaMismatchError = Class.new(StandardError)
66
+
67
+ def find_and_cast_into_type(klass, data)
68
+ return if data.nil?
69
+
70
+ case klass.to_s
71
+ when "Boolean"
72
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
73
+ when "Float"
74
+ return data if data.instance_of?(Float)
75
+ when "Integer"
76
+ return data if data.instance_of?(Integer)
77
+ when "Time"
78
+ return Time.parse(data)
79
+ when "Date"
80
+ return Date.parse(data)
81
+ when "String"
82
+ return data if data.instance_of?(String)
83
+ # "type: object"
84
+ when "Object"
85
+ return data if data.instance_of?(Hash)
86
+ # "type: array"
87
+ when /\AArray<(?<sub_type>.+)>\z/
88
+ if data.instance_of?(Array)
89
+ sub_type = Regexp.last_match[:sub_type]
90
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
91
+ end
92
+ # "type: object" with "additionalProperties: { ... }"
93
+ when /\AHash<String, (?<sub_type>.+)>\z/
94
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
95
+ sub_type = Regexp.last_match[:sub_type]
96
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
97
+ end
98
+ # model
99
+ else
100
+ const = Algolia::AgentStudio.const_get(klass)
101
+ if const
102
+ if const.respond_to?(:openapi_one_of)
103
+ # nested oneOf model
104
+ model = const.build(data)
105
+ elsif const.respond_to?(:discriminator_attributes)
106
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
107
+ model = const.build_from_hash(data)
108
+ end
109
+ else
110
+ # maybe it's an enum, or doens't have discriminators
111
+ model = const.build_from_hash(data)
112
+ end
113
+
114
+ return model if model
115
+ end
116
+ end
117
+
118
+ # if no match by now, raise
119
+ raise
120
+ rescue
121
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -7,7 +7,7 @@ require "time"
7
7
 
8
8
  module Algolia
9
9
  module AgentStudio
10
- # Model for tool invocation in a Message.
10
+ # A tool invocation in a message.
11
11
  class ToolInvocationV4
12
12
  attr_accessor :tool_call_id
13
13
 
@@ -64,7 +64,15 @@ module Algolia
64
64
  # List of attributes with nullable: true
65
65
  def self.openapi_nullable
66
66
  Set.new(
67
- []
67
+ [
68
+ :result,
69
+ :step,
70
+ :state,
71
+ :provider_options,
72
+ :requires_approval,
73
+ :description,
74
+ :args_hash
75
+ ]
68
76
  )
69
77
  end
70
78