Skip to content

Commit dd43681

Browse files
committed
Made prompt parsing better
1 parent 301cd8f commit dd43681

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

ai-assistant/src/core/prompt/prompt.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,31 @@ export class Prompt {
1111
this._messages = messages;
1212
}
1313

14+
private parsePromptContent(content: string): string {
15+
return content
16+
.split("\n")
17+
.map((x) => x.trim())
18+
.join("\n");
19+
}
20+
1421
pushSystem(content: string) {
15-
this._messages.push({ role: "system", content });
22+
this._messages.push({
23+
role: "system",
24+
content: this.parsePromptContent(content),
25+
});
1626
}
1727

1828
pushAssistant(content: string) {
19-
this._messages.push({ role: "assistant", content });
29+
this._messages.push({
30+
role: "assistant",
31+
content: this.parsePromptContent(content),
32+
});
2033
}
2134

2235
pushUser(content: string) {
23-
this._messages.push({ role: "user", content });
36+
this._messages.push({
37+
role: "user",
38+
content: this.parsePromptContent(content),
39+
});
2440
}
2541
}

0 commit comments

Comments
 (0)