-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c71b3d4
commit faea324
Showing
4 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from jinja2 import Template | ||
|
||
from aidial_assistant.chain.history import History, MessageScope, ScopedMessage | ||
from aidial_assistant.chain.model_client import Message | ||
|
||
SYSTEM_MESSAGE = "<system message>" | ||
USER_MESSAGE = "<user message>" | ||
ASSISTANT_MESSAGE = "<assistant message>" | ||
|
||
|
||
def test_protocol_messages(): | ||
history = History( | ||
assistant_system_message_template=Template( | ||
"system message={{system_prefix}}" | ||
), | ||
best_effort_template=Template(""), | ||
scoped_messages=[ | ||
ScopedMessage( | ||
scope=MessageScope.USER, message=Message.system(SYSTEM_MESSAGE) | ||
), | ||
ScopedMessage( | ||
scope=MessageScope.USER, message=Message.user(USER_MESSAGE) | ||
), | ||
ScopedMessage( | ||
scope=MessageScope.USER, | ||
message=Message.assistant(ASSISTANT_MESSAGE), | ||
), | ||
], | ||
) | ||
|
||
assert history.to_protocol_messages() == [ | ||
Message.system(f"system message={SYSTEM_MESSAGE}"), | ||
Message.user(USER_MESSAGE), | ||
Message.assistant( | ||
f'{{"commands": [{{"command": "reply", "args": ["{ASSISTANT_MESSAGE}"]}}]}}' | ||
), | ||
] |