Henhouse/workflow-comics
0
1 2 interface Message {3 role: "system" | "user" | "assistant";4 content: string;5 }6 7 /**8 * Formats the messages for the chat with the LLM model in the style of a pirate.9 * @param messages - Array of message objects with role and content.10 * @returns The formatted chat prompt.11 */12 export function createZephyrPrompt(messages: Message[]): string {13 let prompt = ``;14 15 // Iterate over messages and generate corresponding chat entries.16 messages.forEach(message => {17 prompt += `<|${message.role}|>\n${message.content.trim()}</s>`;18 });19 20 if (messages.at(-1)?.role === "user") {21 // Append the assistant's tag for the next response but without a closing tag.22 prompt += `<|assistant|>`;23 }24 25 return prompt;26 }