Skip to content

Latest commit

 

History

History
302 lines (215 loc) · 10.5 KB

MessageApi.md

File metadata and controls

302 lines (215 loc) · 10.5 KB

TrieveRubyClient::MessageApi

All URIs are relative to http://localhost:8090

Method HTTP request Description
create_message_completion_handler POST /api/message Create a message
edit_message_handler PUT /api/message Edit a message
get_all_topic_messages GET /api/messages/{messages_topic_id} Get all messages for a given topic
regenerate_message_handler DELETE /api/message Regenerate message

create_message_completion_handler

String create_message_completion_handler(tr_dataset, create_message_data)

Create a message

Create a message Create a message. Messages are attached to topics in order to coordinate memory of gen-AI chat sessions. We are considering refactoring this resource of the API soon. Currently, you can only send user messages. If the topic is a RAG topic then the response will include Chunks first on the stream. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information.

Examples

require 'time'
require 'trieve_ruby_client'
# setup authorization
TrieveRubyClient.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = TrieveRubyClient::MessageApi.new
tr_dataset = 'tr_dataset_example' # String | The dataset id to use for the request
create_message_data = TrieveRubyClient::CreateMessageData.new({new_message_content: 'new_message_content_example', topic_id: 'topic_id_example'}) # CreateMessageData | JSON request payload to create a message completion

begin
  # Create a message
  result = api_instance.create_message_completion_handler(tr_dataset, create_message_data)
  p result
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->create_message_completion_handler: #{e}"
end

Using the create_message_completion_handler_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(String, Integer, Hash)> create_message_completion_handler_with_http_info(tr_dataset, create_message_data)

begin
  # Create a message
  data, status_code, headers = api_instance.create_message_completion_handler_with_http_info(tr_dataset, create_message_data)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => String
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->create_message_completion_handler_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
tr_dataset String The dataset id to use for the request
create_message_data CreateMessageData JSON request payload to create a message completion

Return type

String

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: text/plain, application/json

edit_message_handler

edit_message_handler(tr_dataset, edit_message_data)

Edit a message

Edit a message Edit a message which exists within the topic's chat history. This will delete the message and replace it with a new message. The new message will be generated by the AI based on the new content provided in the request body. The response will include Chunks first on the stream if the topic is using RAG. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information.

Examples

require 'time'
require 'trieve_ruby_client'
# setup authorization
TrieveRubyClient.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = TrieveRubyClient::MessageApi.new
tr_dataset = 'tr_dataset_example' # String | The dataset id to use for the request
edit_message_data = TrieveRubyClient::EditMessageData.new({message_sort_order: 37, new_message_content: 'new_message_content_example', topic_id: 'topic_id_example'}) # EditMessageData | JSON request payload to edit a message and get a new stream

begin
  # Edit a message
  api_instance.edit_message_handler(tr_dataset, edit_message_data)
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->edit_message_handler: #{e}"
end

Using the edit_message_handler_with_http_info variant

This returns an Array which contains the response data (nil in this case), status code and headers.

<Array(nil, Integer, Hash)> edit_message_handler_with_http_info(tr_dataset, edit_message_data)

begin
  # Edit a message
  data, status_code, headers = api_instance.edit_message_handler_with_http_info(tr_dataset, edit_message_data)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => nil
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->edit_message_handler_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
tr_dataset String The dataset id to use for the request
edit_message_data EditMessageData JSON request payload to edit a message and get a new stream

Return type

nil (empty response body)

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

get_all_topic_messages

<Array> get_all_topic_messages(tr_dataset, messages_topic_id)

Get all messages for a given topic

Get all messages for a given topic Get all messages for a given topic. If the topic is a RAG topic then the response will include Chunks first on each message. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information.

Examples

require 'time'
require 'trieve_ruby_client'
# setup authorization
TrieveRubyClient.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = TrieveRubyClient::MessageApi.new
tr_dataset = 'tr_dataset_example' # String | The dataset id to use for the request
messages_topic_id = '38400000-8cf0-11bd-b23e-10b96e4ef00d' # String | The ID of the topic to get messages for.

begin
  # Get all messages for a given topic
  result = api_instance.get_all_topic_messages(tr_dataset, messages_topic_id)
  p result
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->get_all_topic_messages: #{e}"
end

Using the get_all_topic_messages_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(<Array>, Integer, Hash)> get_all_topic_messages_with_http_info(tr_dataset, messages_topic_id)

begin
  # Get all messages for a given topic
  data, status_code, headers = api_instance.get_all_topic_messages_with_http_info(tr_dataset, messages_topic_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Array<Message>>
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->get_all_topic_messages_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
tr_dataset String The dataset id to use for the request
messages_topic_id String The ID of the topic to get messages for.

Return type

Array<Message>

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

regenerate_message_handler

String regenerate_message_handler(tr_dataset, regenerate_message_data)

Regenerate message

Regenerate message Regenerate the assistant response to the last user message of a topic. This will delete the last message and replace it with a new message. The response will include Chunks first on the stream if the topic is using RAG. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information.

Examples

require 'time'
require 'trieve_ruby_client'
# setup authorization
TrieveRubyClient.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = TrieveRubyClient::MessageApi.new
tr_dataset = 'tr_dataset_example' # String | The dataset id to use for the request
regenerate_message_data = TrieveRubyClient::RegenerateMessageData.new({topic_id: 'topic_id_example'}) # RegenerateMessageData | JSON request payload to delete an agent message then regenerate it in a strem

begin
  # Regenerate message
  result = api_instance.regenerate_message_handler(tr_dataset, regenerate_message_data)
  p result
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->regenerate_message_handler: #{e}"
end

Using the regenerate_message_handler_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(String, Integer, Hash)> regenerate_message_handler_with_http_info(tr_dataset, regenerate_message_data)

begin
  # Regenerate message
  data, status_code, headers = api_instance.regenerate_message_handler_with_http_info(tr_dataset, regenerate_message_data)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => String
rescue TrieveRubyClient::ApiError => e
  puts "Error when calling MessageApi->regenerate_message_handler_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
tr_dataset String The dataset id to use for the request
regenerate_message_data RegenerateMessageData JSON request payload to delete an agent message then regenerate it in a strem

Return type

String

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: text/plain, application/json