Repository navigation
Expand file tree
/
Copy pathSystemMessageSectionsE2ETests.cs
More file actions
73 lines (65 loc) · 3.11 KB
/
Copy pathSystemMessageSectionsE2ETests.cs
File metadata and controls
73 lines (65 loc) · 3.11 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
66
67
68
69
70
71
72
73
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
using GitHub.Copilot.Rpc;
using GitHub.Copilot.Test.Harness;
using Xunit;
using Xunit.Abstractions;
namespace GitHub.Copilot.Test.E2E;
public class SystemMessageSectionsE2ETests(E2ETestFixture fixture, ITestOutputHelper output) : E2ETestBase(fixture, "system_message_sections", output)
{
[Fact]
public async Task Should_Use_Replaced_Identity_Section_In_Response()
{
var session = await CreateSessionAsync(new SessionConfig
{
OnPermissionRequest = PermissionHandler.ApproveAll,
SystemMessage = new SystemMessageConfig
{
Mode = SystemMessageMode.Customize,
Sections = new Dictionary<SystemMessageSection, SectionOverride>
{
[SystemMessageSection.Identity] = new SectionOverride
{
Action = SectionOverrideAction.Replace,
Content = "You are a helpful gardening assistant called Botanica. You only answer questions about plants and gardening."
}
}
}
});
await session.SendAsync(new MessageOptions { Prompt = "Who are you?" });
var response = await TestHelper.GetFinalAssistantMessageAsync(session);
Assert.NotNull(response);
var content = response.Data.Content.ToLowerInvariant();
Assert.True(
content.Contains("botanica") || content.Contains("garden") || content.Contains("plant"),
$"Expected response to reflect the replaced identity section, but got: {response.Data.Content}");
}
[Fact]
public async Task Should_Use_Replaced_Preamble_Section_In_Response()
{
var session = await CreateSessionAsync(new SessionConfig
{
OnPermissionRequest = PermissionHandler.ApproveAll,
SystemMessage = new SystemMessageConfig
{
Mode = SystemMessageMode.Customize,
Sections = new Dictionary<SystemMessageSection, SectionOverride>
{
[SystemMessageSection.Preamble] = new SectionOverride
{
Action = SectionOverrideAction.Replace,
Content = "You are a helpful gardening assistant called Botanica. You only answer questions about plants and gardening."
}
}
}
});
await session.SendAsync(new MessageOptions { Prompt = "Who are you?" });
var response = await TestHelper.GetFinalAssistantMessageAsync(session);
Assert.NotNull(response);
var content = response.Data.Content.ToLowerInvariant();
Assert.True(
content.Contains("botanica") || content.Contains("garden") || content.Contains("plant"),
$"Expected response to reflect the replaced preamble section, but got: {response.Data.Content}");
}
}