* chore(pyproject.toml): update vulture dependency to version 2.11 * chore: Remove unused files and imports * Refactor legacy_custom/customs.py by removing unused nodes and chains * Refactor langflow.interface.custom.base.py by removing unused code * Refactor test_custom_component.py to import CustomComponent from langflow.custom * refactor(agents): remove AgentInitializer and OpenAIConversationalAgent components as they are no longer needed refactor(embeddings): remove client parameter from OpenAIEmbeddingsComponent as it is not used refactor(memories): change search_scope and search_type parameters in ZepMessageReaderComponent to be of type str refactor(model_specs): remove examples parameter from ChatVertexAIComponent as it is not used refactor(models): change metadata parameter type in OllamaModel to Dict for consistency refactor(VertexAiModel.py): remove examples parameter from ChatVertexAIComponent constructor to simplify the class structure refactor(MultiQueryRetriever.py): change prompt parameter type to Text for better consistency and readability refactor(JsonToolkit.py): update build method to handle both json and yaml file types for JsonToolkit creation refactor(OpenAPIToolkit.py): update build method to handle both json and yaml file types for JsonSpec creation and improve parameter naming for clarity * Format json * refactor(langflow.custom): update imports in code files to use the new langflow.custom module * chore(settings.py): remove unused settings file and related imports and classes from the project. * refactor(langflow): optimize imports in graph/__init__.py and graph/graph/base.py refactor(langflow): remove unused code and simplify logic in vertex/base.py refactor(types.py): remove unused imports and classes, clean up commented out code, and improve code readability by removing unnecessary methods and attributes refactor(utils.py): remove unused functions is_basic_type, invoke_lc_runnable, generate_result feat(load): add new functionality to load flow from JSON file or object and run flow from JSON file or object feat(load): add new modules load.py and __init__.py for loading and running flow from JSON feat(processing): remove unused functions get_result_and_steps, flush_langfuse_callback_if_present refactor(process.py): remove unused functions and imports to clean up the codebase feat(utils.py): remove unused file utils.py to declutter the project and improve maintainability test(test_loading.py): update import paths after restructuring the project folders
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
import pytest
|
|
from langflow.graph import Graph
|
|
from langflow.graph.schema import RunOutputs
|
|
from langflow.initial_setup.setup import load_starter_projects
|
|
from langflow.load import load_flow_from_json, run_flow_from_json
|
|
|
|
|
|
@pytest.mark.noclient
|
|
def test_load_flow_from_json():
|
|
"""Test loading a flow from a json file"""
|
|
loaded = load_flow_from_json(pytest.BASIC_EXAMPLE_PATH)
|
|
assert loaded is not None
|
|
assert isinstance(loaded, Graph)
|
|
|
|
|
|
@pytest.mark.noclient
|
|
def test_load_flow_from_json_with_tweaks():
|
|
"""Test loading a flow from a json file and applying tweaks"""
|
|
tweaks = {"dndnode_82": {"model_name": "gpt-3.5-turbo-16k-0613"}}
|
|
loaded = load_flow_from_json(pytest.BASIC_EXAMPLE_PATH, tweaks=tweaks)
|
|
assert loaded is not None
|
|
assert isinstance(loaded, Graph)
|
|
|
|
|
|
@pytest.mark.noclient
|
|
def test_load_flow_from_json_object():
|
|
"""Test loading a flow from a json file and applying tweaks"""
|
|
_, projects = zip(*load_starter_projects())
|
|
project = projects[0]
|
|
loaded = load_flow_from_json(project)
|
|
assert loaded is not None
|
|
assert isinstance(loaded, Graph)
|
|
|
|
|
|
@pytest.mark.noclient
|
|
def test_run_flow_from_json_object():
|
|
"""Test loading a flow from a json file and applying tweaks"""
|
|
_, projects = zip(*load_starter_projects())
|
|
project = [project for project in projects if "Basic Prompting" in project["name"]][0]
|
|
results = run_flow_from_json(project, input_value="test", fallback_to_env_vars=True)
|
|
assert results is not None
|
|
assert all(isinstance(result, RunOutputs) for result in results)
|