Prepend text to a system message.
Creates a new SystemMessage with the text prepended to the existing content. If the original message has content, the new text is separated by two newlines.
prependToSystemMessage(
systemMessage: SystemMessage<MessageStructure<MessageToolSet>> | null | undefined,
text: string
): SystemMessage| Name | Type | Description |
|---|---|---|
systemMessage* | SystemMessage<MessageStructure<MessageToolSet>> | null | undefined | Existing system message or null/undefined. |
text* | string | Text to prepend to the system message. |
const original = new SystemMessage({ content: "Always be concise." });
const updated = prependToSystemMessage(original, "You are a helpful assistant.");
// Result: SystemMessage with content "You are a helpful assistant.\n\nAlways be concise."