Skip to content

Commit

Permalink
Use XML tags to more clearly structure prompt sections and comment data
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 6d75c2644a0e38b2add4a198fa430a366d31107f
Jigsaw authored and copybara-github committed Jan 24, 2025
1 parent 7d55d3d commit dee9d96
Showing 2 changed files with 27 additions and 19 deletions.
33 changes: 19 additions & 14 deletions src/sensemaker_utils.test.ts
Original file line number Diff line number Diff line change
@@ -62,12 +62,15 @@ const TEST_COMMENTS = [
describe("SensemakerUtilsTest", () => {
it("should create a prompt", () => {
expect(getPrompt("Summarize this.", ["comment1", "comment2"])).toEqual(
`Instructions:
Summarize this.
`
<instructions>
Summarize this.
</instructions>
Comments:
comment1
comment2`
<data>
<comment>comment1</comment>
<comment>comment2</comment>
</data>`
);
});

@@ -78,17 +81,19 @@ comment2`
["comment1", "comment2"],
"This is for a town hall style conversation"
)
).toEqual(
`Instructions:
Summarize this.
).toEqual(`
<instructions>
Summarize this.
</instructions>
Additional context:
This is for a town hall style conversation
<additionalContext>
This is for a town hall style conversation
</additionalContext>
Comments:
comment1
comment2`
);
<data>
<comment>comment1</comment>
<comment>comment2</comment>
</data>`);
});
describe("groupCommentsByTopic", () => {
it("should group comments by topic and subtopic", () => {
13 changes: 8 additions & 5 deletions src/sensemaker_utils.ts
Original file line number Diff line number Diff line change
@@ -64,11 +64,14 @@ export async function retryCall<T>(
* @returns the instructions and the data as a text
*/
export function getPrompt(instructions: string, data: string[], additionalInstructions?: string) {
return `Instructions:
${instructions}
${additionalInstructions ? "\nAdditional context:\n" + additionalInstructions + "\n" : ""}
Comments:
${data.join("\n")}`; // separate comments with newlines
return `
<instructions>
${instructions}
</instructions>
${additionalInstructions ? "\n<additionalContext>\n " + additionalInstructions + "\n</additionalContext>\n" : ""}
<data>
<comment>${data.join("</comment>\n <comment>")}</comment>
</data>`;
}

/**

0 comments on commit dee9d96

Please sign in to comment.