Class: TrieveRubyClient::TopicApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TopicApi

Returns a new instance of TopicApi.



19
20
21
# File 'lib/trieve_ruby_client/api/topic_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/topic_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_topic(tr_dataset, create_topic_req_payload, opts = {}) ⇒ Topic

Create Topic Create a new chat topic. Topics are attached to a owner_id’s and act as a coordinator for conversation message history of gen-AI chat sessions. 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_topic_req_payload (CreateTopicReqPayload)

    JSON request payload to create chat topic

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

    the optional parameters

Returns:



28
29
30
31
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 28

def create_topic(tr_dataset, create_topic_req_payload, opts = {})
  data, _status_code, _headers = create_topic_with_http_info(tr_dataset, create_topic_req_payload, opts)
  data
end

#create_topic_with_http_info(tr_dataset, create_topic_req_payload, opts = {}) ⇒ Array<(Topic, Integer, Hash)>

Create Topic Create a new chat topic. Topics are attached to a owner_id&#39;s and act as a coordinator for conversation message history of gen-AI chat sessions. 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_topic_req_payload (CreateTopicReqPayload)

    JSON request payload to create chat topic

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

    the optional parameters

Returns:

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

    Topic data, response status code and response headers



39
40
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
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 39

def create_topic_with_http_info(tr_dataset, create_topic_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TopicApi.create_topic ...'
  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 TopicApi.create_topic"
  end
  # verify the required parameter 'create_topic_req_payload' is set
  if @api_client.config.client_side_validation && create_topic_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'create_topic_req_payload' when calling TopicApi.create_topic"
  end
  # resource path
  local_var_path = '/api/topic'

  # 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_topic_req_payload)

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

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

  new_options = opts.merge(
    :operation => :"TopicApi.create_topic",
    :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: TopicApi#create_topic\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_topic(tr_dataset, topic_id, opts = {}) ⇒ nil

Delete Topic Delete an existing chat topic. When a topic is deleted, all associated chat messages are also deleted. 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

  • topic_id (String)

    The id of the topic you want to delete.

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

    the optional parameters

Returns:

  • (nil)


103
104
105
106
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 103

def delete_topic(tr_dataset, topic_id, opts = {})
  delete_topic_with_http_info(tr_dataset, topic_id, opts)
  nil
end

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

Delete Topic Delete an existing chat topic. When a topic is deleted, all associated chat messages are also deleted. 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

  • topic_id (String)

    The id of the topic you want to delete.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



114
115
116
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
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 114

def delete_topic_with_http_info(tr_dataset, topic_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TopicApi.delete_topic ...'
  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 TopicApi.delete_topic"
  end
  # verify the required parameter 'topic_id' is set
  if @api_client.config.client_side_validation && topic_id.nil?
    fail ArgumentError, "Missing the required parameter 'topic_id' when calling TopicApi.delete_topic"
  end
  # resource path
  local_var_path = '/api/topic/{topic_id}'.sub('{' + 'topic_id' + '}', CGI.escape(topic_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 => :"TopicApi.delete_topic",
    :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: TopicApi#delete_topic\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_all_topics_for_owner_id(owner_id, tr_dataset, opts = {}) ⇒ Array<Topic>

Get All Topics for Owner ID Get all topics belonging to an arbitary owner_id. This is useful for managing message history and chat sessions. It is common to use a browser fingerprint or your user’s id as the owner_id. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization.

Parameters:

  • owner_id (String)

    The owner_id to get topics of; A common approach is to use a browser fingerprint or your user&#39;s id

  • tr_dataset (String)

    The dataset id to use for the request

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

    the optional parameters

Returns:



173
174
175
176
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 173

def get_all_topics_for_owner_id(owner_id, tr_dataset, opts = {})
  data, _status_code, _headers = get_all_topics_for_owner_id_with_http_info(owner_id, tr_dataset, opts)
  data
end

#get_all_topics_for_owner_id_with_http_info(owner_id, tr_dataset, opts = {}) ⇒ Array<(Array<Topic>, Integer, Hash)>

Get All Topics for Owner ID Get all topics belonging to an arbitary owner_id. This is useful for managing message history and chat sessions. It is common to use a browser fingerprint or your user&#39;s id as the owner_id. Auth&#39;ed user or api key must have an admin or owner role for the specified dataset&#39;s organization.

Parameters:

  • owner_id (String)

    The owner_id to get topics of; A common approach is to use a browser fingerprint or your user&#39;s id

  • tr_dataset (String)

    The dataset id to use for the request

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

    the optional parameters

Returns:

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

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



184
185
186
187
188
189
190
191
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
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 184

def get_all_topics_for_owner_id_with_http_info(owner_id, tr_dataset, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TopicApi.get_all_topics_for_owner_id ...'
  end
  # verify the required parameter 'owner_id' is set
  if @api_client.config.client_side_validation && owner_id.nil?
    fail ArgumentError, "Missing the required parameter 'owner_id' when calling TopicApi.get_all_topics_for_owner_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 TopicApi.get_all_topics_for_owner_id"
  end
  # resource path
  local_var_path = '/api/topic/owner/{owner_id}'.sub('{' + 'owner_id' + '}', CGI.escape(owner_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] || 'Array<Topic>'

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

  new_options = opts.merge(
    :operation => :"TopicApi.get_all_topics_for_owner_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: TopicApi#get_all_topics_for_owner_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_topic(tr_dataset, update_topic_req_payload, opts = {}) ⇒ nil

Update Topic Update an existing chat topic. Currently, only the name of the topic can be updated. 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_topic_req_payload (UpdateTopicReqPayload)

    JSON request payload to update a chat topic

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

    the optional parameters

Returns:

  • (nil)


243
244
245
246
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 243

def update_topic(tr_dataset, update_topic_req_payload, opts = {})
  update_topic_with_http_info(tr_dataset, update_topic_req_payload, opts)
  nil
end

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

Update Topic Update an existing chat topic. Currently, only the name of the topic can be updated. 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_topic_req_payload (UpdateTopicReqPayload)

    JSON request payload to update a chat topic

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



254
255
256
257
258
259
260
261
262
263
264
265
266
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
# File 'lib/trieve_ruby_client/api/topic_api.rb', line 254

def update_topic_with_http_info(tr_dataset, update_topic_req_payload, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TopicApi.update_topic ...'
  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 TopicApi.update_topic"
  end
  # verify the required parameter 'update_topic_req_payload' is set
  if @api_client.config.client_side_validation && update_topic_req_payload.nil?
    fail ArgumentError, "Missing the required parameter 'update_topic_req_payload' when calling TopicApi.update_topic"
  end
  # resource path
  local_var_path = '/api/topic'

  # 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_topic_req_payload)

  # return_type
  return_type = opts[:debug_return_type]

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

  new_options = opts.merge(
    :operation => :"TopicApi.update_topic",
    :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: TopicApi#update_topic\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end