MoRaj
02/24/2025, 5:39 AMKyle
02/25/2025, 6:11 AM// Send a system message with updated product info
const message = {
type: 'add-message',
message: {
role: 'system',
content: Updated product catalog: ${JSON.stringify(products)},
},
// Set to false to silently update without triggering a response
triggerResponseEnabled: false
};
2\. Using Variable Substitution
You can use variable substitution in your system prompts and update them dynamically:
const assistant = {
model: {
messages: [
{
role: 'system',
content: 'Current products: {{products}}'
}
]
}
};
// Update variables
const variables = {
products: JSON.stringify(updatedProducts)
};
Both methods allow for dynamic updates during an active conversation. You can choose between triggering a new response or silently updating the context.
FYI: Changes are properly tracked in the conversation history and updates are handled efficiently without requiring full context reloads