Skip to content

Commit

Permalink
Don't include system prompt in summary text
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Sep 19, 2023
1 parent a7fcec8 commit 5fae20a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/ChatCraftChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export type SerializedChatCraftChat = {
};

function createSummary(chat: ChatCraftChat, maxLength = 200) {
const markdown = chat.toMarkdown();
// We only want to consider human prompts and ai responses for our summary
const markdown = chat
.messages({ includeAppMessages: false, includeSystemMessages: false })
.map((message) => message.text)
.join("\n\n");

const summary = summarize(markdown);
return summary.length > maxLength ? summary.slice(0, maxLength) + "..." : summary;
}
Expand Down Expand Up @@ -224,7 +229,7 @@ export class ChatCraftChat {
toMarkdown() {
// Turn the messages into Markdown, with each message separated with an <hr />
// Strip out the app messages.
return this.messages({ includeAppMessages: false, includeSystemMessages: true })
return this.messages({ includeAppMessages: false })
.map((message) => message.text)
.join("\n\n---\n\n");
}
Expand Down

0 comments on commit 5fae20a

Please sign in to comment.