-
Notifications
You must be signed in to change notification settings - Fork 936
/
Copy pathtest_chat_group.py
50 lines (43 loc) · 1.62 KB
/
test_chat_group.py
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
import pytest
from _constants import PROMPTFLOW_ROOT
from promptflow._sdk.entities._chat_group._chat_group import ChatGroup
from promptflow._sdk.entities._chat_group._chat_role import ChatRole
FLOWS_DIR = PROMPTFLOW_ROOT / "tests/test_configs/flows"
@pytest.mark.sdk_test
@pytest.mark.e2etest
@pytest.mark.usefixtures("use_secrets_config_file", "recording_injection", "setup_local_connection")
class TestChatGroup:
def test_chat_group_basic_invoke(self):
question = "What's the most beautiful thing in the world?"
ground_truth = "The world itself."
copilot = ChatRole(
flow=FLOWS_DIR / "chat_group_copilot",
role="assistant",
inputs=dict(
question=question,
model="gpt-3.5-turbo",
conversation_history="${parent.conversation_history}",
),
)
simulation = ChatRole(
flow=FLOWS_DIR / "chat_group_simulation",
role="user",
inputs=dict(
question=question,
ground_truth=ground_truth,
conversation_history="${parent.conversation_history}",
),
)
chat_group = ChatGroup(
roles=[copilot, simulation],
max_turns=4,
max_tokens=1000,
max_time=1000,
stop_signal="[STOP]",
)
chat_group.invoke()
# history has 4 records
history = chat_group.conversation_history
assert len(history) == 4
assert history[0][0] == history[2][0] == copilot.role
assert history[1][0] == history[3][0] == simulation.role