-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_system_message_sections_e2e.py
More file actions
73 lines (59 loc) · 2.68 KB
/
Copy pathtest_system_message_sections_e2e.py
File metadata and controls
73 lines (59 loc) · 2.68 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.
Tests for system message sections functionality
"""
import pytest
from copilot.session import PermissionHandler
from .testharness import E2ETestContext
pytestmark = pytest.mark.asyncio(loop_scope="module")
class TestSystemMessageSections:
async def test_should_use_replaced_identity_section_in_response(self, ctx: E2ETestContext):
"""Test that replacing the identity section causes the assistant to adopt a new persona"""
session = await ctx.client.create_session(
system_message={
"mode": "customize",
"sections": {
"identity": {
"action": "replace",
"content": (
"You are a helpful gardening assistant called Botanica."
" You only answer questions about plants and gardening."
),
},
},
},
on_permission_request=PermissionHandler.approve_all,
)
response = await session.send_and_wait("Who are you?")
assert response is not None, "Expected a response from the assistant"
content = response.data.content.lower()
assert "botanica" in content or "garden" in content or "plant" in content, (
f"Expected response to reflect the replaced identity section,"
f" but got: {response.data.content}"
)
await session.disconnect()
async def test_should_use_replaced_preamble_section_in_response(self, ctx: E2ETestContext):
"""Test that replacing only the preamble section changes the assistant persona"""
session = await ctx.client.create_session(
system_message={
"mode": "customize",
"sections": {
"preamble": {
"action": "replace",
"content": (
"You are a helpful gardening assistant called Botanica."
" You only answer questions about plants and gardening."
),
},
},
},
on_permission_request=PermissionHandler.approve_all,
)
response = await session.send_and_wait("Who are you?")
assert response is not None, "Expected a response from the assistant"
content = response.data.content.lower()
assert "botanica" in content or "garden" in content or "plant" in content, (
f"Expected response to reflect the replaced preamble section,"
f" but got: {response.data.content}"
)
await session.disconnect()