chat-ui
chat-ui copied to clipboard
Preprompt Missing in Rendered Chat Prompt
Bug description
The preprompt is missing in the rendered chat prompt when a user inputs a message. The expected behavior is for the preprompt to appear before the user's message, but it does not.
Steps to reproduce
-
Set the
chatPromptTemplate
as follows:<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{@root.preprompt}}\n{{/if}}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}
-
Set the
preprompt
to "You are an AI assistant". -
User inputs "Hello, world!".
-
Render the prompt using the following code (src/lib/buildPrompt.ts):
let prompt = model.chatPromptRender({ messages: filteredMessages, preprompt, tools, toolResults, });
-
Redered prompt is
<s>[INST] Hello, world![/INST]
. -
Observe the output. The preprompt "You are an AI assistant" is missing.
Specs
- chat-ui commit: 6cfc3a749a7de7e1c8bea26797760abdeac36c17 (latest)
Config
"preprompt": "You are an AI assistant",
"chatPromptTemplate": "<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{@root.preprompt}}\n{{/if}}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}",
Notes
The preprompt should be included in the rendered chat prompt, but it is not appearing. This issue needs to be addressed to ensure the correct behavior of the chat application.