Class: TrieveRubyClient::ChunkApi

Inherits:
Object
  • Object
show all
Defined in:
lib/trieve_ruby_client/api/chunk_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ChunkApi

Returns a new instance of ChunkApi.



19
20
21
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#autocomplete(tr_dataset, autocomplete_req_payload, opts = {}) ⇒ SearchResponseTypes

Autocomplete This route provides the primary autocomplete functionality for the API. This prioritize prefix matching with semantic or full-text search.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • autocomplete_req_payload (AutocompleteReqPayload)

    JSON request payload to semantically search for chunks (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



29
30
31
32
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 29

def autocomplete(tr_dataset, autocomplete_req_payload, opts = {})
  data, _status_code, _headers = autocomplete_with_http_info(tr_dataset, autocomplete_req_payload, opts)
  data
end

#autocomplete_with_http_info(tr_dataset, autocomplete_req_payload, opts = {}) ⇒ Array<(SearchResponseTypes, Integer, Hash)>

Autocomplete This route provides the primary autocomplete functionality for the API. This prioritize prefix matching with semantic or full-text search.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • autocomplete_req_payload (AutocompleteReqPayload)

    JSON request payload to semantically search for chunks (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(SearchResponseTypes, Integer, Hash)>)

    SearchResponseTypes data, response status code and response headers



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 41

def autocomplete_with_http_info(tr_dataset, autocomplete_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.autocomplete ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.autocomplete"
  end
  # verify the required parameter 'autocomplete_req_payload' is set
  if @api_client.config.client_side_validation && autocomplete_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'autocomplete_req_payload' when calling ChunkApi.autocomplete"
  end
  # resource path
  local_var_path = '/api/chunk/autocomplete'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(autocomplete_req_payload)

  # return_type
  return_type = opts[:debug_return_type] || 'SearchResponseTypes'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.autocomplete",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#autocomplete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#count_chunks(tr_dataset, count_chunks_req_payload, opts = {}) ⇒ CountChunkQueryResponseBody

Count chunks above threshold This route can be used to determine the number of chunks that match a given search criteria including filters and score threshold. It may be high latency for large datasets. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization. There is a dataset configuration imposed restriction on the maximum limit value (default 10,000) which is used to prevent DDOS attacks.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • count_chunks_req_payload (CountChunksReqPayload)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



106
107
108
109
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 106

def count_chunks(tr_dataset, count_chunks_req_payload, opts = {})
  data, _status_code, _headers = count_chunks_with_http_info(tr_dataset, count_chunks_req_payload, opts)
  data
end

#count_chunks_with_http_info(tr_dataset, count_chunks_req_payload, opts = {}) ⇒ Array<(CountChunkQueryResponseBody, Integer, Hash)>

Count chunks above threshold This route can be used to determine the number of chunks that match a given search criteria including filters and score threshold. It may be high latency for large datasets. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization. There is a dataset configuration imposed restriction on the maximum limit value (default 10,000) which is used to prevent DDOS attacks.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • count_chunks_req_payload (CountChunksReqPayload)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CountChunkQueryResponseBody, Integer, Hash)>)

    CountChunkQueryResponseBody data, response status code and response headers



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 117

def count_chunks_with_http_info(tr_dataset, count_chunks_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.count_chunks ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.count_chunks"
  end
  # verify the required parameter 'count_chunks_req_payload' is set
  if @api_client.config.client_side_validation && count_chunks_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'count_chunks_req_payload' when calling ChunkApi.count_chunks"
  end
  # resource path
  local_var_path = '/api/chunk/count'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(count_chunks_req_payload)

  # return_type
  return_type = opts[:debug_return_type] || 'CountChunkQueryResponseBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.count_chunks",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#count_chunks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_chunk(tr_dataset, create_chunk_req_payload_enum, opts = {}) ⇒ ReturnQueuedChunk

Create or Upsert Chunk or Chunks Create a new chunk. If the chunk has the same tracking_id as an existing chunk, the request will fail. Once a chunk is created, it can be searched for using the search endpoint. If uploading in bulk, the maximum amount of chunks that can be uploaded at once is 120 chunks. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • create_chunk_req_payload_enum (CreateChunkReqPayloadEnum)

    JSON request payload to create a new chunk (chunk)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



181
182
183
184
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 181

def create_chunk(tr_dataset, create_chunk_req_payload_enum, opts = {})
  data, _status_code, _headers = create_chunk_with_http_info(tr_dataset, create_chunk_req_payload_enum, opts)
  data
end

#create_chunk_with_http_info(tr_dataset, create_chunk_req_payload_enum, opts = {}) ⇒ Array<(ReturnQueuedChunk, Integer, Hash)>

Create or Upsert Chunk or Chunks Create a new chunk. If the chunk has the same tracking_id as an existing chunk, the request will fail. Once a chunk is created, it can be searched for using the search endpoint. If uploading in bulk, the maximum amount of chunks that can be uploaded at once is 120 chunks. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • create_chunk_req_payload_enum (CreateChunkReqPayloadEnum)

    JSON request payload to create a new chunk (chunk)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ReturnQueuedChunk, Integer, Hash)>)

    ReturnQueuedChunk data, response status code and response headers



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 192

def create_chunk_with_http_info(tr_dataset, create_chunk_req_payload_enum, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.create_chunk ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.create_chunk"
  end
  # verify the required parameter 'create_chunk_req_payload_enum' is set
  if @api_client.config.client_side_validation && create_chunk_req_payload_enum.nil?
    fail ArgumentError, "Missing the required parameter 'create_chunk_req_payload_enum' when calling ChunkApi.create_chunk"
  end
  # resource path
  local_var_path = '/api/chunk'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_chunk_req_payload_enum)

  # return_type
  return_type = opts[:debug_return_type] || 'ReturnQueuedChunk'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.create_chunk",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#create_chunk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_chunk(tr_dataset, chunk_id, opts = {}) ⇒ nil

Delete Chunk Delete a chunk by its id. If deleting a root chunk which has a collision, the most recently created collision will become a new root chunk. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • chunk_id (String)

    Id of the chunk you want to fetch.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


256
257
258
259
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 256

def delete_chunk(tr_dataset, chunk_id, opts = {})
  delete_chunk_with_http_info(tr_dataset, chunk_id, opts)
  nil
end

#delete_chunk_by_tracking_id(tr_dataset, tracking_id, opts = {}) ⇒ nil

Delete Chunk By Tracking Id Delete a chunk by tracking_id. This is useful for when you are coordinating with an external system and want to use the tracking_id to identify the chunk. If deleting a root chunk which has a collision, the most recently created collision will become a new root chunk. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • tracking_id (String)

    tracking_id of the chunk you want to delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


326
327
328
329
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 326

def delete_chunk_by_tracking_id(tr_dataset, tracking_id, opts = {})
  delete_chunk_by_tracking_id_with_http_info(tr_dataset, tracking_id, opts)
  nil
end

#delete_chunk_by_tracking_id_with_http_info(tr_dataset, tracking_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Chunk By Tracking Id Delete a chunk by tracking_id. This is useful for when you are coordinating with an external system and want to use the tracking_id to identify the chunk. If deleting a root chunk which has a collision, the most recently created collision will become a new root chunk. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • tracking_id (String)

    tracking_id of the chunk you want to delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 337

def delete_chunk_by_tracking_id_with_http_info(tr_dataset, tracking_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.delete_chunk_by_tracking_id ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.delete_chunk_by_tracking_id"
  end
  # verify the required parameter 'tracking_id' is set
  if @api_client.config.client_side_validation && tracking_id.nil?
    fail ArgumentError, "Missing the required parameter 'tracking_id' when calling ChunkApi.delete_chunk_by_tracking_id"
  end
  # resource path
  local_var_path = '/api/chunk/tracking_id/{tracking_id}'.sub('{' + 'tracking_id' + '}', CGI.escape(tracking_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.delete_chunk_by_tracking_id",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#delete_chunk_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_chunk_with_http_info(tr_dataset, chunk_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Chunk Delete a chunk by its id. If deleting a root chunk which has a collision, the most recently created collision will become a new root chunk. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • chunk_id (String)

    Id of the chunk you want to fetch.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 267

def delete_chunk_with_http_info(tr_dataset, chunk_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.delete_chunk ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.delete_chunk"
  end
  # verify the required parameter 'chunk_id' is set
  if @api_client.config.client_side_validation && chunk_id.nil?
    fail ArgumentError, "Missing the required parameter 'chunk_id' when calling ChunkApi.delete_chunk"
  end
  # resource path
  local_var_path = '/api/chunk/{chunk_id}'.sub('{' + 'chunk_id' + '}', CGI.escape(chunk_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.delete_chunk",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#delete_chunk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#generate_off_chunks(tr_dataset, generate_chunks_request, opts = {}) ⇒ String

RAG on Specified Chunks This endpoint exists as an alternative to the topic+message concept where our API handles chat memory. With this endpoint, the user is responsible for providing the context window and the prompt. See more in the "search before generate" page at docs.trieve.ai.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • generate_chunks_request (GenerateChunksRequest)

    JSON request payload to perform RAG on some chunks (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


396
397
398
399
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 396

def generate_off_chunks(tr_dataset, generate_chunks_request, opts = {})
  data, _status_code, _headers = generate_off_chunks_with_http_info(tr_dataset, generate_chunks_request, opts)
  data
end

#generate_off_chunks_with_http_info(tr_dataset, generate_chunks_request, opts = {}) ⇒ Array<(String, Integer, Hash)>

RAG on Specified Chunks This endpoint exists as an alternative to the topic+message concept where our API handles chat memory. With this endpoint, the user is responsible for providing the context window and the prompt. See more in the &quot;search before generate&quot; page at docs.trieve.ai.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • generate_chunks_request (GenerateChunksRequest)

    JSON request payload to perform RAG on some chunks (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 407

def generate_off_chunks_with_http_info(tr_dataset, generate_chunks_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.generate_off_chunks ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.generate_off_chunks"
  end
  # verify the required parameter 'generate_chunks_request' is set
  if @api_client.config.client_side_validation && generate_chunks_request.nil?
    fail ArgumentError, "Missing the required parameter 'generate_chunks_request' when calling ChunkApi.generate_off_chunks"
  end
  # resource path
  local_var_path = '/api/chunk/generate'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(generate_chunks_request)

  # return_type
  return_type = opts[:debug_return_type] || 'String'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.generate_off_chunks",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#generate_off_chunks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_chunk_by_id(tr_dataset, chunk_id, opts = {}) ⇒ ChunkReturnTypes

Get Chunk By Id Get a singular chunk by id.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • chunk_id (String)

    Id of the chunk you want to fetch.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



472
473
474
475
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 472

def get_chunk_by_id(tr_dataset, chunk_id, opts = {})
  data, _status_code, _headers = get_chunk_by_id_with_http_info(tr_dataset, chunk_id, opts)
  data
end

#get_chunk_by_id_with_http_info(tr_dataset, chunk_id, opts = {}) ⇒ Array<(ChunkReturnTypes, Integer, Hash)>

Get Chunk By Id Get a singular chunk by id.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • chunk_id (String)

    Id of the chunk you want to fetch.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(ChunkReturnTypes, Integer, Hash)>)

    ChunkReturnTypes data, response status code and response headers



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 484

def get_chunk_by_id_with_http_info(tr_dataset, chunk_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.get_chunk_by_id ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.get_chunk_by_id"
  end
  # verify the required parameter 'chunk_id' is set
  if @api_client.config.client_side_validation && chunk_id.nil?
    fail ArgumentError, "Missing the required parameter 'chunk_id' when calling ChunkApi.get_chunk_by_id"
  end
  # resource path
  local_var_path = '/api/chunk/{chunk_id}'.sub('{' + 'chunk_id' + '}', CGI.escape(chunk_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ChunkReturnTypes'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.get_chunk_by_id",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#get_chunk_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_chunk_by_tracking_id(tr_dataset, tracking_id, opts = {}) ⇒ ChunkReturnTypes

Get Chunk By Tracking Id Get a singular chunk by tracking_id. This is useful for when you are coordinating with an external system and want to use your own id as the primary reference for a chunk.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • tracking_id (String)

    tracking_id of the chunk you want to fetch

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



545
546
547
548
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 545

def get_chunk_by_tracking_id(tr_dataset, tracking_id, opts = {})
  data, _status_code, _headers = get_chunk_by_tracking_id_with_http_info(tr_dataset, tracking_id, opts)
  data
end

#get_chunk_by_tracking_id_with_http_info(tr_dataset, tracking_id, opts = {}) ⇒ Array<(ChunkReturnTypes, Integer, Hash)>

Get Chunk By Tracking Id Get a singular chunk by tracking_id. This is useful for when you are coordinating with an external system and want to use your own id as the primary reference for a chunk.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • tracking_id (String)

    tracking_id of the chunk you want to fetch

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(ChunkReturnTypes, Integer, Hash)>)

    ChunkReturnTypes data, response status code and response headers



557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 557

def get_chunk_by_tracking_id_with_http_info(tr_dataset, tracking_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.get_chunk_by_tracking_id ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.get_chunk_by_tracking_id"
  end
  # verify the required parameter 'tracking_id' is set
  if @api_client.config.client_side_validation && tracking_id.nil?
    fail ArgumentError, "Missing the required parameter 'tracking_id' when calling ChunkApi.get_chunk_by_tracking_id"
  end
  # resource path
  local_var_path = '/api/chunk/tracking_id/{tracking_id}'.sub('{' + 'tracking_id' + '}', CGI.escape(tracking_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ChunkReturnTypes'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.get_chunk_by_tracking_id",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#get_chunk_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_chunks_by_ids(tr_dataset, get_chunks_data, opts = {}) ⇒ Array<ChunkReturnTypes>

Get Chunks By Ids Get multiple chunks by multiple ids.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • get_chunks_data (GetChunksData)

    JSON request payload to get the chunks in the request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



618
619
620
621
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 618

def get_chunks_by_ids(tr_dataset, get_chunks_data, opts = {})
  data, _status_code, _headers = get_chunks_by_ids_with_http_info(tr_dataset, get_chunks_data, opts)
  data
end

#get_chunks_by_ids_with_http_info(tr_dataset, get_chunks_data, opts = {}) ⇒ Array<(Array<ChunkReturnTypes>, Integer, Hash)>

Get Chunks By Ids Get multiple chunks by multiple ids.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • get_chunks_data (GetChunksData)

    JSON request payload to get the chunks in the request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(Array<ChunkReturnTypes>, Integer, Hash)>)

    Array<ChunkReturnTypes> data, response status code and response headers



630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 630

def get_chunks_by_ids_with_http_info(tr_dataset, get_chunks_data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.get_chunks_by_ids ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.get_chunks_by_ids"
  end
  # verify the required parameter 'get_chunks_data' is set
  if @api_client.config.client_side_validation && get_chunks_data.nil?
    fail ArgumentError, "Missing the required parameter 'get_chunks_data' when calling ChunkApi.get_chunks_by_ids"
  end
  # resource path
  local_var_path = '/api/chunks'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(get_chunks_data)

  # return_type
  return_type = opts[:debug_return_type] || 'Array<ChunkReturnTypes>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.get_chunks_by_ids",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#get_chunks_by_ids\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_chunks_by_tracking_ids(tr_dataset, get_tracking_chunks_data, opts = {}) ⇒ Array<ChunkReturnTypes>

Get Chunks By Tracking Ids Get multiple chunks by ids.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • get_tracking_chunks_data (GetTrackingChunksData)

    JSON request payload to get the chunks in the request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



696
697
698
699
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 696

def get_chunks_by_tracking_ids(tr_dataset, get_tracking_chunks_data, opts = {})
  data, _status_code, _headers = get_chunks_by_tracking_ids_with_http_info(tr_dataset, get_tracking_chunks_data, opts)
  data
end

#get_chunks_by_tracking_ids_with_http_info(tr_dataset, get_tracking_chunks_data, opts = {}) ⇒ Array<(Array<ChunkReturnTypes>, Integer, Hash)>

Get Chunks By Tracking Ids Get multiple chunks by ids.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • get_tracking_chunks_data (GetTrackingChunksData)

    JSON request payload to get the chunks in the request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(Array<ChunkReturnTypes>, Integer, Hash)>)

    Array<ChunkReturnTypes> data, response status code and response headers



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 708

def get_chunks_by_tracking_ids_with_http_info(tr_dataset, get_tracking_chunks_data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.get_chunks_by_tracking_ids ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.get_chunks_by_tracking_ids"
  end
  # verify the required parameter 'get_tracking_chunks_data' is set
  if @api_client.config.client_side_validation && get_tracking_chunks_data.nil?
    fail ArgumentError, "Missing the required parameter 'get_tracking_chunks_data' when calling ChunkApi.get_chunks_by_tracking_ids"
  end
  # resource path
  local_var_path = '/api/chunks/tracking'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(get_tracking_chunks_data)

  # return_type
  return_type = opts[:debug_return_type] || 'Array<ChunkReturnTypes>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.get_chunks_by_tracking_ids",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#get_chunks_by_tracking_ids\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

Get Recommended Chunks Get recommendations of chunks similar to the positive samples in the request and dissimilar to the negative. You must provide at least one of either positive_chunk_ids or positive_tracking_ids.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • recommend_chunks_request (RecommendChunksRequest)

    JSON request payload to get recommendations of chunks similar to the chunks in the request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



774
775
776
777
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 774

def get_recommended_chunks(tr_dataset, recommend_chunks_request, opts = {})
  data, _status_code, _headers = get_recommended_chunks_with_http_info(tr_dataset, recommend_chunks_request, opts)
  data
end

Get Recommended Chunks Get recommendations of chunks similar to the positive samples in the request and dissimilar to the negative. You must provide at least one of either positive_chunk_ids or positive_tracking_ids.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • recommend_chunks_request (RecommendChunksRequest)

    JSON request payload to get recommendations of chunks similar to the chunks in the request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(RecommendResponseTypes, Integer, Hash)>)

    RecommendResponseTypes data, response status code and response headers



786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 786

def get_recommended_chunks_with_http_info(tr_dataset, recommend_chunks_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.get_recommended_chunks ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.get_recommended_chunks"
  end
  # verify the required parameter 'recommend_chunks_request' is set
  if @api_client.config.client_side_validation && recommend_chunks_request.nil?
    fail ArgumentError, "Missing the required parameter 'recommend_chunks_request' when calling ChunkApi.get_recommended_chunks"
  end
  # resource path
  local_var_path = '/api/chunk/recommend'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(recommend_chunks_request)

  # return_type
  return_type = opts[:debug_return_type] || 'RecommendResponseTypes'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.get_recommended_chunks",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#get_recommended_chunks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_suggested_queries(tr_dataset, suggested_queries_req_payload, opts = {}) ⇒ SuggestedQueriesResponse

Generate suggested queries This endpoint will generate 3 suggested queries based off a hybrid search using RAG with the query provided in the request body and return them as a JSON object.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • suggested_queries_req_payload (SuggestedQueriesReqPayload)

    JSON request payload to get alternative suggested queries

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



851
852
853
854
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 851

def get_suggested_queries(tr_dataset, suggested_queries_req_payload, opts = {})
  data, _status_code, _headers = get_suggested_queries_with_http_info(tr_dataset, suggested_queries_req_payload, opts)
  data
end

#get_suggested_queries_with_http_info(tr_dataset, suggested_queries_req_payload, opts = {}) ⇒ Array<(SuggestedQueriesResponse, Integer, Hash)>

Generate suggested queries This endpoint will generate 3 suggested queries based off a hybrid search using RAG with the query provided in the request body and return them as a JSON object.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • suggested_queries_req_payload (SuggestedQueriesReqPayload)

    JSON request payload to get alternative suggested queries

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(SuggestedQueriesResponse, Integer, Hash)>)

    SuggestedQueriesResponse data, response status code and response headers



862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 862

def get_suggested_queries_with_http_info(tr_dataset, suggested_queries_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.get_suggested_queries ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.get_suggested_queries"
  end
  # verify the required parameter 'suggested_queries_req_payload' is set
  if @api_client.config.client_side_validation && suggested_queries_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'suggested_queries_req_payload' when calling ChunkApi.get_suggested_queries"
  end
  # resource path
  local_var_path = '/api/chunk/gen_suggestions'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(suggested_queries_req_payload)

  # return_type
  return_type = opts[:debug_return_type] || 'SuggestedQueriesResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.get_suggested_queries",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#get_suggested_queries\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_chunks(tr_dataset, search_chunks_req_payload, opts = {}) ⇒ SearchResponseTypes

Search This route provides the primary search functionality for the API. It can be used to search for chunks by semantic similarity, full-text similarity, or a combination of both. Results’ ‘chunk_html` values will be modified with `<b><mark>` tags for sub-sentence highlighting.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • search_chunks_req_payload (SearchChunksReqPayload)

    JSON request payload to semantically search for chunks (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:



927
928
929
930
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 927

def search_chunks(tr_dataset, search_chunks_req_payload, opts = {})
  data, _status_code, _headers = search_chunks_with_http_info(tr_dataset, search_chunks_req_payload, opts)
  data
end

#search_chunks_with_http_info(tr_dataset, search_chunks_req_payload, opts = {}) ⇒ Array<(SearchResponseTypes, Integer, Hash)>

Search This route provides the primary search functionality for the API. It can be used to search for chunks by semantic similarity, full-text similarity, or a combination of both. Results&#39; &#x60;chunk_html&#x60; values will be modified with &#x60;&lt;b&gt;&lt;mark&gt;&#x60; tags for sub-sentence highlighting.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • search_chunks_req_payload (SearchChunksReqPayload)

    JSON request payload to semantically search for chunks (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_api_version (APIVersion)

    The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise.

Returns:

  • (Array<(SearchResponseTypes, Integer, Hash)>)

    SearchResponseTypes data, response status code and response headers



939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 939

def search_chunks_with_http_info(tr_dataset, search_chunks_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.search_chunks ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.search_chunks"
  end
  # verify the required parameter 'search_chunks_req_payload' is set
  if @api_client.config.client_side_validation && search_chunks_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'search_chunks_req_payload' when calling ChunkApi.search_chunks"
  end
  # resource path
  local_var_path = '/api/chunk/search'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset
  header_params[:'X-API-Version'] = opts[:'x_api_version'] if !opts[:'x_api_version'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(search_chunks_req_payload)

  # return_type
  return_type = opts[:debug_return_type] || 'SearchResponseTypes'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.search_chunks",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#search_chunks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_chunk(tr_dataset, update_chunk_req_payload, opts = {}) ⇒ nil

Update Chunk Update a chunk. If you try to change the tracking_id of the chunk to have the same tracking_id as an existing chunk, the request will fail. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • update_chunk_req_payload (UpdateChunkReqPayload)

    JSON request payload to update a chunk (chunk)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


1004
1005
1006
1007
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 1004

def update_chunk(tr_dataset, update_chunk_req_payload, opts = {})
  update_chunk_with_http_info(tr_dataset, update_chunk_req_payload, opts)
  nil
end

#update_chunk_by_tracking_id(tr_dataset, update_chunk_by_tracking_id_data, opts = {}) ⇒ nil

Update Chunk By Tracking Id Update a chunk by tracking_id. This is useful for when you are coordinating with an external system and want to use the tracking_id to identify the chunk. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • update_chunk_by_tracking_id_data (UpdateChunkByTrackingIdData)

    JSON request payload to update a chunk by tracking_id (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


1079
1080
1081
1082
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 1079

def update_chunk_by_tracking_id(tr_dataset, update_chunk_by_tracking_id_data, opts = {})
  update_chunk_by_tracking_id_with_http_info(tr_dataset, update_chunk_by_tracking_id_data, opts)
  nil
end

#update_chunk_by_tracking_id_with_http_info(tr_dataset, update_chunk_by_tracking_id_data, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update Chunk By Tracking Id Update a chunk by tracking_id. This is useful for when you are coordinating with an external system and want to use the tracking_id to identify the chunk. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • update_chunk_by_tracking_id_data (UpdateChunkByTrackingIdData)

    JSON request payload to update a chunk by tracking_id (chunks)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 1090

def update_chunk_by_tracking_id_with_http_info(tr_dataset, update_chunk_by_tracking_id_data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.update_chunk_by_tracking_id ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.update_chunk_by_tracking_id"
  end
  # verify the required parameter 'update_chunk_by_tracking_id_data' is set
  if @api_client.config.client_side_validation && update_chunk_by_tracking_id_data.nil?
    fail ArgumentError, "Missing the required parameter 'update_chunk_by_tracking_id_data' when calling ChunkApi.update_chunk_by_tracking_id"
  end
  # resource path
  local_var_path = '/api/chunk/tracking_id/update'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_chunk_by_tracking_id_data)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.update_chunk_by_tracking_id",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#update_chunk_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_chunk_with_http_info(tr_dataset, update_chunk_req_payload, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update Chunk Update a chunk. If you try to change the tracking_id of the chunk to have the same tracking_id as an existing chunk, the request will fail. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization.

Parameters:

  • tr_dataset (String)

    The dataset id to use for the request

  • update_chunk_req_payload (UpdateChunkReqPayload)

    JSON request payload to update a chunk (chunk)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
# File 'lib/trieve_ruby_client/api/chunk_api.rb', line 1015

def update_chunk_with_http_info(tr_dataset, update_chunk_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChunkApi.update_chunk ...'
  end
  # verify the required parameter 'tr_dataset' is set
  if @api_client.config.client_side_validation && tr_dataset.nil?
    fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling ChunkApi.update_chunk"
  end
  # verify the required parameter 'update_chunk_req_payload' is set
  if @api_client.config.client_side_validation && update_chunk_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'update_chunk_req_payload' when calling ChunkApi.update_chunk"
  end
  # resource path
  local_var_path = '/api/chunk'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'TR-Dataset'] = tr_dataset

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_chunk_req_payload)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"ChunkApi.update_chunk",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChunkApi#update_chunk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end