🔀 refactor(process.py): change load_flow_from_json function signature to accept either a JSON file path or a JSON object

🔀 refactor(base.py): import Chain from langchain.chains.base instead of importing it from langflow.graph.vertex.types
🔀 refactor(process.py): remove print statement from process_tweaks function
🔀 refactor(process.py): change load_flow_from_json function signature to accept optional tweaks parameter
🔀 refactor(process.py): change return type of build method in Graph class from List[Vertex] to Chain
🧪 test(loading.py): add test case for loading a flow from a JSON file and applying tweaks
🧪 test(loading.py): remove unused import statement
The import statement for Chain in base.py is now more explicit and imports it from langchain.chains.base instead of importing it from langflow.graph.vertex.types. The load_flow_from_json function in process.py now accepts either a JSON file path or a JSON object. The print statement in process_tweaks function has been removed. The load_flow_from_json function in process.py now accepts an optional tweaks parameter. The return type of the build method in the Graph class has been changed from List[Vertex] to Chain. A new test case has been added to loading.py to test loading a flow from a JSON file and applying tweaks. An unused import statement has been removed from loading.py.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-19 11:36:43 -03:00
commit 6886828ddd
3 changed files with 43 additions and 19 deletions

View file

@ -14,6 +14,15 @@ def test_load_flow_from_json():
assert isinstance(loaded, Chain)
def test_load_flow_from_json_with_tweaks():
"""Test loading a flow from a json file and applying tweaks"""
tweaks = {"dndnode_82": {"model_name": "test model"}}
loaded = load_flow_from_json(pytest.BASIC_EXAMPLE_PATH, tweaks=tweaks)
assert loaded is not None
assert isinstance(loaded, Chain)
assert loaded.llm.model_name == "test model"
def test_get_root_node():
with open(pytest.BASIC_EXAMPLE_PATH, "r") as f:
flow_graph = json.load(f)