-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhaiku_stream_test.py
More file actions
38 lines (28 loc) · 1.25 KB
/
haiku_stream_test.py
File metadata and controls
38 lines (28 loc) · 1.25 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
"""
An example of how to test skill code.
"""
from pharia_skill import FinishReason
from pharia_skill.testing import MessageRecorder, StubCsi
from .haiku_stream import Input, SkillOutput, haiku_stream
def test_haiku_stream():
# Given a haiku skill and a request about oat milk
input = Input(topic="oat milk")
# When executing the skill against a message recorder and a stub csi
writer = MessageRecorder[SkillOutput]()
haiku_stream(StubCsi(), writer, input)
# Then the message recorded will be about oat milk
first_message = writer.messages()[0]
assert first_message.role == "assistant"
assert "oat milk" in first_message.content
assert first_message.payload is not None
assert first_message.payload.finish_reason == FinishReason.STOP
def test_haiku_stream_reasoning():
# Given a haiku skill and a request about oat milk
input = Input(topic="oat milk")
# When executing the skill against a message recorder and a stub csi
writer = MessageRecorder[SkillOutput]()
haiku_stream(StubCsi(), writer, input)
# Then the message recorded will be about oat milk
first_message = writer.messages()[0]
assert first_message.role == "assistant"
assert first_message.reasoning_content == "I am thinking..."