Skip to main content

System Prompt Template

The system prompt template is a key feature in TaskingAI's assistant system, enabling assistants to generate consistent and contextually relevant responses. It incorporates variables, allowing for personalized and dynamic message generation based on different conversation contexts.

Code Example

You can create an assistant with a system prompt template using the following code:

import taskingai

assistant = taskingai.assistant.create_assistant(
model_id="YOUR_MODEL_ID",
name="My Assistant",
description="A assistant who knows the meaning of various numbers.",
system_prompt_template=[
"You know the meaning of various numbers.",
"No matter what the user's language is, you will use {{langugae}} to explain."
]
)

After creating the assistant, you can generate a response message with system_prompt_variables using the following code:

taskingai.assistant.create_message(
assistant_id=assistant.assistant_id,
chat_id=chat.chat_id,
text=user_input,
)

# generate assistant response
assistant_message = taskingai.assistant.generate_message(
assistant_id=assistant.assistant_id,
chat_id=chat.chat_id,
system_prompt_variables={
"language": "English"
}
)

Overall, the system prompt template functions as a dynamic script for the Assistant. It changes based on the variables provided. Each line in the template is conditional. If a line contains a variable that is not filled, that line is excluded from the final system prompt.

This feature ensures that the Assistant’s responses are always tailored to the specific context of the conversation. It prevents irrelevant or incomplete information from being included in the Assistant’s dialogue.