nsarrazin HF staff commited on
Commit
1305730
1 Parent(s): 8074ead

filter system messages when building prompt

Browse files
Files changed (1) hide show
  1. src/lib/buildPrompt.ts +3 -1
src/lib/buildPrompt.ts CHANGED
@@ -11,8 +11,10 @@ export async function buildPrompt({
11
  preprompt,
12
  continueMessage,
13
  }: buildPromptOptions): Promise<string> {
 
 
14
  let prompt = model
15
- .chatPromptRender({ messages, preprompt })
16
  // Not super precise, but it's truncated in the model's backend anyway
17
  .split(" ")
18
  .slice(-(model.parameters?.truncate ?? 0))
 
11
  preprompt,
12
  continueMessage,
13
  }: buildPromptOptions): Promise<string> {
14
+ const filteredMessages = messages.filter((m) => m.from !== "system");
15
+
16
  let prompt = model
17
+ .chatPromptRender({ messages: filteredMessages, preprompt })
18
  // Not super precise, but it's truncated in the model's backend anyway
19
  .split(" ")
20
  .slice(-(model.parameters?.truncate ?? 0))