Stateless Invocations
Stateless vs Stateful
Normally, when you interact with a TaskingAI assistant, whether through UI or SDK, the conversation is stateful under a chat session. Even if the assistant is configured with zero memory, the chat history are still traceable inside the chat session.
However, in some cases, you may want to perform stateless tasks, where the assistant should take each task independently without any context from any previous tasks. And in those cases, the concept of chat is no longer wanted.
How to Perform Stateless Invocations with TaskingAI
To perform stateless tasks with TaskingAI, you can use the chat completion API with the following method. It is similar to the basic usage of chat completion, but using assistant_id instead of model_id.
import taskingai
# create a chat_completion task
chat_completion_result = taskingai.inference.chat_completion(
model_id="YOUR_ASSISTANT_ID",
messages=[
{"role": "user", "message": "What does TaskingAI provide?"},
],
)