chat-ui icon indicating copy to clipboard operation
chat-ui copied to clipboard

Preprompt Missing in Rendered Chat Prompt

Open calycekr opened this issue 5 months ago • 1 comments

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

  1. Set the chatPromptTemplate as follows: <s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{@root.preprompt}}\n{{/if}}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}

  2. Set the preprompt to "You are an AI assistant".

  3. User inputs "Hello, world!".

  4. Render the prompt using the following code (src/lib/buildPrompt.ts):

    let prompt = model.chatPromptRender({
        messages: filteredMessages,
        preprompt,
        tools,
        toolResults,
    });
    
  5. Redered prompt is <s>[INST] Hello, world![/INST].

  6. 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.

calycekr avatar Sep 03 '24 00:09 calycekr