All URIs are relative to https://api.trieve.ai
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 |
str 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.
- Api Key Authentication (ApiKey):
import trieve_py_client
from trieve_py_client.models.create_message_data import CreateMessageData
from trieve_py_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.trieve.ai
# See configuration.py for a list of all supported configuration parameters.
configuration = trieve_py_client.Configuration(
host = "https://api.trieve.ai"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'
# Enter a context with an instance of the API client
with trieve_py_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = trieve_py_client.MessageApi(api_client)
tr_dataset = 'tr_dataset_example' # str | The dataset id to use for the request
create_message_data = trieve_py_client.CreateMessageData() # CreateMessageData | JSON request payload to create a message completion
try:
# Create a message
api_response = api_instance.create_message_completion_handler(tr_dataset, create_message_data)
print("The response of MessageApi->create_message_completion_handler:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MessageApi->create_message_completion_handler: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
tr_dataset | str | The dataset id to use for the request | |
create_message_data | CreateMessageData | JSON request payload to create a message completion |
str
- Content-Type: application/json
- Accept: text/plain, application/json
Status code | Description | Response headers |
---|---|---|
200 | This will be a JSON response of a string containing the LLM's generated inference. Response if not streaming. | - |
400 | Service error relating to getting a chat completion | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
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.
- Api Key Authentication (ApiKey):
import trieve_py_client
from trieve_py_client.models.edit_message_data import EditMessageData
from trieve_py_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.trieve.ai
# See configuration.py for a list of all supported configuration parameters.
configuration = trieve_py_client.Configuration(
host = "https://api.trieve.ai"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'
# Enter a context with an instance of the API client
with trieve_py_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = trieve_py_client.MessageApi(api_client)
tr_dataset = 'tr_dataset_example' # str | The dataset id to use for the request
edit_message_data = trieve_py_client.EditMessageData() # EditMessageData | JSON request payload to edit a message and get a new stream
try:
# Edit a message
api_instance.edit_message_handler(tr_dataset, edit_message_data)
except Exception as e:
print("Exception when calling MessageApi->edit_message_handler: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
tr_dataset | str | The dataset id to use for the request | |
edit_message_data | EditMessageData | JSON request payload to edit a message and get a new stream |
void (empty response body)
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | This will be a HTTP stream, check the chat or search UI for an example how to process this | - |
400 | Service error relating to getting a chat completion | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
List[Message] 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.
- Api Key Authentication (ApiKey):
import trieve_py_client
from trieve_py_client.models.message import Message
from trieve_py_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.trieve.ai
# See configuration.py for a list of all supported configuration parameters.
configuration = trieve_py_client.Configuration(
host = "https://api.trieve.ai"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'
# Enter a context with an instance of the API client
with trieve_py_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = trieve_py_client.MessageApi(api_client)
tr_dataset = 'tr_dataset_example' # str | The dataset id to use for the request
messages_topic_id = 'messages_topic_id_example' # str | The ID of the topic to get messages for.
try:
# Get all messages for a given topic
api_response = api_instance.get_all_topic_messages(tr_dataset, messages_topic_id)
print("The response of MessageApi->get_all_topic_messages:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MessageApi->get_all_topic_messages: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
tr_dataset | str | The dataset id to use for the request | |
messages_topic_id | str | The ID of the topic to get messages for. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | All messages relating to the topic with the given ID | - |
400 | Service error relating to getting the messages | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
str 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.
- Api Key Authentication (ApiKey):
import trieve_py_client
from trieve_py_client.models.regenerate_message_data import RegenerateMessageData
from trieve_py_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.trieve.ai
# See configuration.py for a list of all supported configuration parameters.
configuration = trieve_py_client.Configuration(
host = "https://api.trieve.ai"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'
# Enter a context with an instance of the API client
with trieve_py_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = trieve_py_client.MessageApi(api_client)
tr_dataset = 'tr_dataset_example' # str | The dataset id to use for the request
regenerate_message_data = trieve_py_client.RegenerateMessageData() # RegenerateMessageData | JSON request payload to delete an agent message then regenerate it in a strem
try:
# Regenerate message
api_response = api_instance.regenerate_message_handler(tr_dataset, regenerate_message_data)
print("The response of MessageApi->regenerate_message_handler:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MessageApi->regenerate_message_handler: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
tr_dataset | str | 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 |
str
- Content-Type: application/json
- Accept: text/plain, application/json
Status code | Description | Response headers |
---|---|---|
200 | This will be a JSON response of a string containing the LLM's generated inference. Response if not streaming. | - |
400 | Service error relating to getting a chat completion | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]