-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add unit test for Message schema serialization and promp…
…t loading
- Loading branch information
1 parent
61194e5
commit 85c9703
Showing
1 changed file
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from langchain_core.prompts.chat import ChatPromptTemplate | ||
|
||
from langflow.schema.message import Message | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
pass | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_message_async_prompt_serialization(): | ||
template = "Hello, {name}!" | ||
message = await Message.async_from_template_and_variables(template, name="Langflow") | ||
assert message.text == "Hello, Langflow!" | ||
|
||
prompt = message.load_lc_prompt() | ||
assert isinstance(prompt, ChatPromptTemplate) | ||
assert prompt.messages[0].content == "Hello, Langflow!" | ||
|
||
|
||
def test_message_prompt_serialization(): | ||
template = "Hello, {name}!" | ||
message = Message.from_template_and_variables(template, name="Langflow") | ||
assert message.text == "Hello, Langflow!" | ||
|
||
prompt = message.load_lc_prompt() | ||
assert isinstance(prompt, ChatPromptTemplate) | ||
assert prompt.messages[0].content == "Hello, Langflow!" |