Skip to main content

Retrieve Messages

Retrieving a Specific Message

You can use get_message to retrieve a specific message, where all assistant_id, chat_id, and message_id are required for locating the message.

import taskingai

message = taskingai.assistant.get_message(
assistant_id="YOUR_ASSISTANT_ID",
chat_id="YOUR_CHAT_ID",
message_id="YOUR_MESSAGE_ID"
)

It returns a Message object containing details of the specified message.

Listing Messages

The list_messages function lists multiple messages within a specific chat.

chats = taskingai.assistant.list_messages(
assistant_id="YOUR_ASSISTANT_ID",
chat_id="YOUR_CHAT_ID",
order="desc",
limit=20,
after="YOUR_MESSAGE_ID"
)

Parameters and Usage:

  • limit: Sets the maximum number of chats to return in the list. It should be in the range of 1 to 100.
  • order: desc or asc. Determines the order in which the assistants are listed. The sort key is the created_timestamp field of the message.
  • before/after: It specifies the point before/after which the next set of messages should be fetched.

The method will return a list of Message objects representing the messages in the chat session.