-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update message reload and update langchain-core (#3054)
* refactor: update langchain-core to version 0.2.24 * refactor: convert inner messages to BaseMessage in load_lc_prompt method * refactor: update ChatPromptTemplate instantiation in message.py * refactor: update langflow-base dependency to use local path for development * [autofix.ci] apply automated fixes * refactor: update ChatPromptTemplate instantiation in message.py * refactor: add async_from_template_and_variables and sync from_template_and_variables * feat(tests): add unit test for Message schema serialization and prompt loading * refactor: update langchain-core dependency to version 0.2.24 * chore: new lock * mypy * chore: format pyproject * refactor: rename async_from_template_and_variables to from_template_and_variables in Message class * refactor: Rename async_from_template_and_variables to from_template_and_variables in Message class --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Nicolò Boschi <[email protected]>
- Loading branch information
1 parent
3e6d3dc
commit 4382e42
Showing
7 changed files
with
565 additions
and
590 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,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.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.sync_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!" |