-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathsystem_message_sections.e2e.test.ts
More file actions
65 lines (55 loc) · 2.6 KB
/
Copy pathsystem_message_sections.e2e.test.ts
File metadata and controls
65 lines (55 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
import { describe, expect, it } from "vitest";
import { approveAll } from "../../src/index.js";
import { createSdkTestContext } from "./harness/sdkTestContext.js";
describe("System message sections", async () => {
const { copilotClient: client } = await createSdkTestContext();
it("should_use_replaced_identity_section_in_response", async () => {
const session = await client.createSession({
onPermissionRequest: approveAll,
systemMessage: {
mode: "customize",
sections: {
identity: {
action: "replace",
content:
"You are a helpful gardening assistant called Botanica. You only answer questions about plants and gardening.",
},
},
},
});
const response = await session.sendAndWait({ prompt: "Who are you?" });
expect(response).not.toBeNull();
const content = response!.data.content.toLowerCase();
expect(
content.includes("botanica") || content.includes("garden") || content.includes("plant"),
`Expected response to reflect the replaced identity section, but got: ${response!.data.content}`
).toBe(true);
await session.disconnect();
});
it("should_use_replaced_preamble_section_in_response", async () => {
const session = await client.createSession({
onPermissionRequest: approveAll,
systemMessage: {
mode: "customize",
sections: {
preamble: {
action: "replace",
content:
"You are a helpful gardening assistant called Botanica. You only answer questions about plants and gardening.",
},
},
},
});
const response = await session.sendAndWait({ prompt: "Who are you?" });
expect(response).not.toBeNull();
const content = response!.data.content.toLowerCase();
expect(
content.includes("botanica") || content.includes("garden") || content.includes("plant"),
`Expected response to reflect the replaced preamble section, but got: ${response!.data.content}`
).toBe(true);
await session.disconnect();
});
});