Langflow is a powerful tool for building and deploying AI-powered agents and workflows. http://www.langflow.org
Find a file
Gabriel Luiz Freitas Almeida 4221fa40e6
refactor: deactivate caching if a component is part of a cycle (#3694)
* Set `_has_cycle_edges` to `True` for source and target vertices in cycle edges

* feat: Add `has_cycle_edges` method to Vertex class

The `has_cycle_edges` method is added to the `Vertex` class to check if the vertex has any cycle edges. Additionally, the `instantiate_component` method is updated to use the `initialize.loading.instantiate_class` function for custom component instantiation.

* Add `apply_on_outputs` method to Vertex for applying functions to outputs

* Add utility to find vertices in cycles within a directed graph

- Implement `find_cycle_vertices` function to identify all vertices that are part of cycles in a directed graph.
- Utilize depth-first search (DFS) to detect cycles and collect vertices involved in those cycles.

* Add unit tests for `find_cycle_vertices` utility function in graph module

* Add method to set cache for vertices in cycle

- Introduced `_set_cache_to_vertices_in_cycle` method to enable caching for vertices involved in cycles.
- Added `find_cycle_vertices` import to support the new method.
- Refactored vertex instantiation into `_instantiate_components_in_vertices` method for better code organization.

* refactor: Update caching logic for vertices in cycles

Refactor the `_set_cache_to_vertices_in_cycle` method to improve caching logic for vertices involved in cycles. Instead of setting the `cache` attribute to `True`, it is now set to `False` for better clarity and consistency. This change ensures that the cache is properly handled for vertices in cycles.

* Refactor `find_cycle_vertices` to use NetworkX for cycle detection

* Refactor `find_cycle_vertices` tests to remove entry point parameter and add new test case

- Removed the `entry_point` parameter from all test cases for `find_cycle_vertices`.
- Added a new parameterized test case `test_handle_two_inputs_in_cycle` to verify handling of cycles with two inputs.

* Disable cache in cycle: Update `apply_on_outputs` to handle empty outputs in `base.py`

* Add unit test to ensure output cache is disabled in graph cycles

* Add unit test for graph cyclicity with prompt components and OpenAI integration

- Introduce `test_updated_graph_with_prompts` to validate graph cyclicity and execution.
- Integrate `PromptComponent`, `OpenAIModelComponent`, and `ConditionalRouterComponent` in the test.
- Ensure graph execution with a maximum of 20 iterations and cache disabled.
- Validate the presence of expected output vertices in the results.

* Convert `_instantiate_components_in_vertices` to async and disable cache in cycle vertices

* Add default value handling for cycle edges in vertex component

- Introduced `default_value` to handle cases where edges are cycles and target parameters are present.
- Ensured that `default_value` is returned if defined, preventing errors when the component is not built.

* Switch from os.environ to os.getenv for API key retrieval in test_cycles.py

* Add __repr__ method to Edge class to indicate cycle edges with a symbol

* Refactor test_cycles.py to streamline component initialization and update assertions

- Simplified component initialization using method chaining.
- Corrected router input and message parameters to use openai_component_1.
- Updated assertions to check for correct output IDs.

* Refactor test_cycles.py to streamline component initialization and update assertions

* Refactor test to use custom serialization method instead of pickle

* Add cycle_vertices property to optimize cycle detection in graph

- Introduced `_cycle_vertices` attribute to store vertices involved in cycles.
- Added `cycle_vertices` property to compute and cache cycle vertices.
- Updated edge creation logic to use `cycle_vertices` for cycle detection.

* Enhance error message in `types.py` to include component ID for better debugging

* Refactor test_cycles.py to update graph configuration and assertions

- Changed router operator from "equals" to "contains".
- Consolidated chat output to a single component.
- Updated graph construction to use a single chat output.
- Replaced `_snapshot` with `get_snapshot` for graph state capture.
- Adjusted assertions to reflect the updated graph structure and outputs.

* Add api_key_required marker to test_updated_graph_with_prompts test

* Add validation to require max_iterations for cyclic graphs

* run ruff

- Refactored error message handling in `base.py` for cyclic graphs.
- Optimized cycle vertex extraction in `utils.py` by using set comprehension.

* Comment out tests for loading flow from JSON in test_loading.py

* Refactor test fixture for webhook flow creation in conftest.py

* Update unit tests to reflect new webhook flow structure in vertices endpoints

* Temporarily disable tests for loading Langchain objects with and without cached sessions

* Disable caching in vector store and OpenAI model components
2024-10-02 18:05:20 +00:00
.devcontainer Update Python base image to version 3.10 in devcontainer.json 2024-04-17 11:21:05 -03:00
.github ci: small nightly fixes (#3993) 2024-10-02 16:36:55 +00:00
.vscode feat: import Graph without position information (#3203) 2024-08-07 07:04:48 -07:00
deploy fix: fix docker compose and add instructions (#2654) 2024-07-12 09:27:13 -07:00
docker ci: fix releases with uv (#3971) 2024-10-02 05:37:04 -07:00
docker_example feat: add pull_policy to Docker compose example (#3693) 2024-09-06 10:41:47 -07:00
docs fix: enhancements for the AssemblyAI component (#3934) 2024-10-01 14:28:18 +00:00
scripts ci: fix releases with uv (#3971) 2024-10-02 05:37:04 -07:00
src refactor: deactivate caching if a component is part of a cycle (#3694) 2024-10-02 18:05:20 +00:00
.env.example fixing ThreadingInMemoryCache usage (#2604) 2024-07-10 04:52:37 -07:00
.eslintrc.json 🔧 (.pre-commit-config.yaml): Add eslint@9.1.1 as a dependency and enable autofix for pretty-format-json hook 2024-05-02 19:27:40 -03:00
.gitattributes Merge cz/mergeAll to two_edges 2024-06-10 11:31:02 -03:00
.gitignore fix: security file upload (#3923) 2024-09-30 19:14:03 +00:00
.pre-commit-config.yaml feat: Add pre-commit hook for ruff (#3960) 2024-10-01 12:50:19 +02:00
CODE_OF_CONDUCT.md run codespell 2024-06-04 09:26:13 -03:00
CONTRIBUTING.md docs: Update CONTRIBUTING.md to mention uv (#3965) 2024-09-30 12:23:35 -07:00
eslint.config.js 🔧 (.pre-commit-config.yaml): Add eslint@9.1.1 as a dependency and enable autofix for pretty-format-json hook 2024-05-02 19:27:40 -03:00
LICENSE Update organization name and URLs in configuration files 2024-04-18 11:58:19 -03:00
Makefile ci: fix releases with uv (#3971) 2024-10-02 05:37:04 -07:00
poetry.lock feat: Add OpenSearch VectorStore Component with Ingest and Search Capabilities (#3799) 2024-10-01 21:42:55 +00:00
pyproject.toml tests: update tests to use httpx.AsyncClient (#3984) 2024-10-02 10:21:52 -07:00
README.ES.md docs: Added Spanish README (#3451) 2024-08-20 11:41:13 -07:00
README.ja.md docs: Added Spanish README (#3451) 2024-08-20 11:41:13 -07:00
README.KR.md docs: Added Spanish README (#3451) 2024-08-20 11:41:13 -07:00
README.md docs: update integrations image (#3508) 2024-08-22 16:57:34 +00:00
README.PT.md docs: Added Spanish README (#3451) 2024-08-20 11:41:13 -07:00
README.zh_CN.md docs: Added Spanish README (#3451) 2024-08-20 11:41:13 -07:00
render.yaml docs: fix render deployment and docs (#3309) 2024-08-14 03:45:56 -07:00
uv.lock tests: update tests to use httpx.AsyncClient (#3984) 2024-10-02 10:21:52 -07:00

Langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. Its Python-based and agnostic to any model, API, or database.

Docs - Free Cloud Service - Self Managed

README in English README in Portuguese README in Spanish README in Simplified Chinese README in Japanese README in KOREAN

Core features

  1. Python-based and agnostic to models, APIs, data sources, or databases.
  2. Visual IDE for drag-and-drop building and testing of workflows.
  3. Playground to immediately test and iterate workflows with step-by-step control.
  4. Multi-agent orchestration and conversation management and retrieval.
  5. Free cloud service to get started in minutes with no setup.
  6. Publish as an API or export as a Python application.
  7. Observability with LangSmith, LangFuse, or LangWatch integration.
  8. Enterprise-grade security and scalability with free DataStax Langflow cloud service.
  9. Customize workflows or create flows entirely just using Python.
  10. Ecosystem integrations as reusable components for any model, API or database.

Integrations

📦 Quickstart

  • Install with pip (Python 3.10 or greater):
pip install langflow

Getting Started

Stay up-to-date

Star Langflow on GitHub to be instantly notified of new releases.

Star Langflow

👋 Contribute

We welcome contributions from developers of all levels. If you'd like to contribute, please check our contributing guidelines and help make Langflow more accessible.


Star History Chart

❤️ Contributors

langflow contributors