Skip to main content

Retrieve Chats

TaskingAI provides two main methods to retrieve an assistant's chats with get_chat and list_chats.


Get Chat

To retrieve information about a specific chat, the get_chat method is used.

import taskingai

chat = taskingai.assistant.get_chat(
assistant_id="YOUR_ASSISTANT_ID",
chat_id="YOUR_CHAT_ID",
)

List Chats

The list_chats function retrieves a list of chats of a specific assistant.

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

Parameters and Usage:

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

The method will return a list of Chat objects, each representing a chat session with the assistant.