-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat: make it possible to load graphs using get_graph function in scripts
#9913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Updated `load_graph_from_script` to be an async function, allowing for the retrieval of the graph via an async `get_graph` function if available. - Implemented fallback to the existing `graph` variable for backward compatibility. - Enhanced `find_graph_variable` to identify both `get_graph` function definitions and `graph` variable assignments, improving flexibility in script handling.
- Refactored `load_graph_from_script` to be an async function, enabling the use of an async `get_graph` function for graph retrieval. - Implemented a fallback mechanism to access the `graph` variable for backward compatibility. - Enhanced error handling to provide clearer messages when neither `graph` nor `get_graph()` is found in the script.
- Introduced an async `get_graph` function to handle the initialization of components and graph creation without blocking. - Updated the logging configuration and component setup to be part of the async function, improving the overall flow and responsiveness. - Enhanced documentation for the `get_graph` function to clarify its purpose and return type.
…oading - Refactored `serve_command` to be an async function using `syncify`, allowing for non-blocking execution. - Updated calls to `load_graph_from_path` and `load_graph_from_script` within `serve_command` and `run` to await their results, enhancing performance and responsiveness. - Improved overall async handling in the CLI commands for better integration with async workflows.
- Changed `load_graph_from_path` to an async function, enabling non-blocking graph loading. - Updated the call to `load_graph_from_script` to use await, improving performance during graph retrieval. - Enhanced the overall async handling in the CLI for better integration with async workflows.
- Updated `get_graph` function in `simple_agent.py` to utilize async component initialization for improved responsiveness. - Modified test cases in `test_simple_agent_in_lfx_run.py` to validate the async behavior of `get_graph`. - Refactored various test functions across multiple files to support async execution, ensuring compatibility with the new async workflows. - Improved documentation for async functions to clarify their purpose and usage.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe codebase shifts graph construction and loading to an asynchronous model. Scripts now expose an async get_graph() factory (fallback to module-level graph remains). CLI loaders and serve command were updated to await async paths. Unit tests were converted to async accordingly, with imports and calls adjusted. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as CLI (serve_command)
participant Common as common.load_graph_from_path
participant Loader as script_loader.load_graph_from_script
participant Mod as Target Script Module
participant Graph as Graph Instance
User->>CLI: Invoke serve (path or script)
note over CLI: serve_command is async (syncified)
alt JSON file
CLI->>Common: await load_graph_from_path(path)
Common-->>CLI: Graph
else Python script
CLI->>Loader: await load_graph_from_script(script_path)
alt get_graph exists
Loader->>Mod: get_graph()
opt async get_graph
Loader->>Mod: await get_graph()
end
Mod-->>Loader: Graph
else legacy graph variable
Loader->>Mod: access module.graph
Mod-->>Loader: Graph
else none
Loader-->>CLI: Error (no graph or get_graph)
end
Loader-->>CLI: Graph
end
CLI->>Graph: use returned Graph
CLI-->>User: Server started with Graph
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@Cristhianzl this will fix some of the changes you made in #9901 |
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (38.94%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #9913 +/- ##
=======================================
Coverage 31.61% 31.61%
=======================================
Files 1348 1348
Lines 61117 61117
Branches 9134 9134
=======================================
+ Hits 19324 19325 +1
Misses 40878 40878
+ Partials 915 914 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/backend/tests/unit/test_simple_agent_in_lfx_run.py (1)
328-359: Async mismatch: to_toolkit must be awaited; make test async.Also mark with pytest.mark.asyncio.
- @pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="OPENAI_API_KEY required for integration test") - def test_complete_workflow_integration(self): + @pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="OPENAI_API_KEY required for integration test") + @pytest.mark.asyncio + async def test_complete_workflow_integration(self): @@ - tools = url_component.to_toolkit() + tools = await url_component.to_toolkit()src/lfx/src/lfx/cli/common.py (1)
246-263: Don’t hard‑fail when no 'graph' variable; allow get_graph‑only scripts.Current precheck raises if the script lacks a module‑level
graph, which blocks the PR goal (support get_graph()). We should proceed to runtime loading and letload_graph_from_scripthandleget_graph()orgraph. Also, tweak the log to reflect this behavior.Apply this diff:
if file_extension == ".py": verbose_print("Analyzing Python script...") graph_var = find_graph_variable(script_path) if graph_var: source_info = graph_var.get("source", "Unknown") type_info = graph_var.get("type", "Unknown") line_no = graph_var.get("line", "Unknown") verbose_print(f"✓ Found 'graph' variable at line {line_no}") verbose_print(f" Type: {type_info}") verbose_print(f" Source: {source_info}") else: - error_msg = "No 'graph' variable found in script" - verbose_print(f"✗ {error_msg}") - raise ValueError(error_msg) + # Don't fail fast: allow get_graph() at runtime + verbose_print("No static 'graph' variable detected; will attempt to resolve via get_graph() at runtime.") verbose_print("Loading graph...") - graph = await load_graph_from_script(script_path) + graph = await load_graph_from_script(script_path)
🧹 Nitpick comments (22)
src/backend/tests/data/simple_agent.py (3)
29-32: Docstring: avoid “run_until_complete” (loader now awaits).Simplify wording to reflect that the CLI loader awaits get_graph().
- blocking the module loading process. The script loader will detect this - async function and handle it appropriately using run_until_complete. + blocking the module loading process. The script loader detects this + async function and awaits it in the CLI loader.
45-48: Guard URLComponent config before awaiting to_toolkit().If no URLs are set, tool creation may be empty or error depending on defaults. Read from env for flexibility.
- url_component = cp.URLComponent() - tools = await url_component.to_toolkit() + url_component = cp.URLComponent() + urls_env = os.getenv("AGENT_URLS") + if urls_env: + url_component.set(urls=[u.strip() for u in urls_env.split(",") if u.strip()]) + tools = await url_component.to_toolkit()
49-55: Explicit API key handling.Consider validating OPENAI_API_KEY early to fail-fast with a clear message.
- agent.set( + api_key = os.getenv("OPENAI_API_KEY") + # Optional: raise if missing to avoid late failures + # if not api_key: + # raise RuntimeError("OPENAI_API_KEY not set") + agent.set( model_name="gpt-4o-mini", agent_llm="OpenAI", - api_key=os.getenv("OPENAI_API_KEY"), + api_key=api_key,src/backend/tests/unit/test_simple_agent_in_lfx_run.py (3)
160-160: Mark async test with pytest.mark.asyncio.Required by backend test guidelines for async tests.
- async def test_agent_workflow_direct_execution(self): + @pytest.mark.asyncio + async def test_agent_workflow_direct_execution(self):
229-229: Mark async test with pytest.mark.asyncio.- async def test_url_component_to_toolkit_functionality(self): + @pytest.mark.asyncio + async def test_url_component_to_toolkit_functionality(self):
193-196: Missing link: ChatOutput should receive agent.message_response.Without this, the graph lacks the final edge.
- chat_output = cp.ChatOutput() + chat_output = cp.ChatOutput().set(input_value=agent.message_response)src/lfx/src/lfx/cli/script_loader.py (3)
3-5: Module docstring: include get_graph entrypoint.-This module provides functionality to load and validate Python scripts -containing LFX graph variables. +This module provides functionality to load and validate Python scripts +containing an LFX graph variable or a get_graph() entrypoint.
95-104: Handle functions that return awaitables (decorated async).If get_graph() returns an awaitable but isn’t defined as a coroutinefunction, await the result.
- if inspect.iscoroutinefunction(get_graph_func): - graph_obj = await get_graph_func() - else: - graph_obj = get_graph_func() + if inspect.iscoroutinefunction(get_graph_func): + graph_obj = await get_graph_func() + else: + graph_obj = get_graph_func() + if inspect.isawaitable(graph_obj): + graph_obj = await graph_obj
210-238: Simplify AST detection for get_graph (sync/async) in one branch.- for node in ast.walk(tree): - # Check for get_graph function definition - if isinstance(node, ast.FunctionDef) and node.name == "get_graph": - line_number = node.lineno - is_async = isinstance(node, ast.AsyncFunctionDef) - - return { - "line_number": line_number, - "type": "function_definition", - "function": "get_graph", - "is_async": is_async, - "arg_count": len(node.args.args), - "source_line": content.split("\n")[line_number - 1].strip(), - } - - # Check for async get_graph function definition - if isinstance(node, ast.AsyncFunctionDef) and node.name == "get_graph": - line_number = node.lineno - - return { - "line_number": line_number, - "type": "function_definition", - "function": "get_graph", - "is_async": True, - "arg_count": len(node.args.args), - "source_line": content.split("\n")[line_number - 1].strip(), - } + for node in ast.walk(tree): + # get_graph function definition (sync or async) + if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name == "get_graph": + line_number = node.lineno + is_async = isinstance(node, ast.AsyncFunctionDef) + return { + "line_number": line_number, + "type": "function_definition", + "function": "get_graph", + "is_async": is_async, + "arg_count": len(node.args.args), + "source_line": content.split("\n")[line_number - 1].strip(), + }src/lfx/src/lfx/cli/run.py (2)
180-189: Error/verbose text should include get_graph as entrypoint.- if not graph_info: - error_msg = ( - "No 'graph' variable found in the script. Expected to find an assignment like: graph = Graph(...)" - ) + if not graph_info: + error_msg = ( + "No 'graph' entry point found. Expected get_graph() or a 'graph = Graph(...)' assignment." + ) raise ValueError(error_msg) - verbose_print(f"Found 'graph' variable at line {graph_info['line_number']}") + entry = "get_graph()" if graph_info.get("type") == "function_definition" else "graph variable" + verbose_print(f"Found {entry} at line {graph_info['line_number']}") verbose_print(f"Type: {graph_info['type']}") verbose_print(f"Source: {graph_info['source_line']}")
243-249: Component types debug should use vertex.custom_component.display_name.- component_types = set() - for vertex in graph.vertices: - if hasattr(vertex, "display_name"): - component_types.add(vertex.display_name) + component_types = set() + for vertex in graph.vertices: + name = getattr(getattr(vertex, "custom_component", None), "display_name", None) + if name: + component_types.add(name)src/lfx/tests/unit/cli/test_script_loader.py (7)
173-177: Mark async test with pytest.mark.asyncio.- async def test_load_graph_from_script_success(self, simple_chat_py): + @pytest.mark.asyncio + async def test_load_graph_from_script_success(self, simple_chat_py):
188-197: Mark async test with pytest.mark.asyncio.- async def test_load_graph_from_script_no_graph_variable(self): + @pytest.mark.asyncio + async def test_load_graph_from_script_no_graph_variable(self):
200-206: Mark async test with pytest.mark.asyncio.- async def test_load_graph_from_script_import_error(self): + @pytest.mark.asyncio + async def test_load_graph_from_script_import_error(self):
207-233: Mark async test with pytest.mark.asyncio.- async def test_load_graph_from_script_with_async_get_graph(self): + @pytest.mark.asyncio + async def test_load_graph_from_script_with_async_get_graph(self):
234-260: Mark async test with pytest.mark.asyncio.- async def test_load_graph_from_script_with_sync_get_graph(self): + @pytest.mark.asyncio + async def test_load_graph_from_script_with_sync_get_graph(self):
562-566: Mark async test with pytest.mark.asyncio.- async def test_load_and_validate_real_script(self, simple_chat_py): + @pytest.mark.asyncio + async def test_load_and_validate_real_script(self, simple_chat_py):
577-581: Mark async test with pytest.mark.asyncio.- async def test_execute_real_flow_with_results(self, simple_chat_py): + @pytest.mark.asyncio + async def test_execute_real_flow_with_results(self, simple_chat_py):src/lfx/src/lfx/cli/common.py (1)
267-273: Optional: surface ValueError messages even when not in verbose mode.Right now ValueErrors are wrapped into
typer.Exit(1)without echoing. Consider echoing the message whenverboseis False to avoid silent exits.Example:
except ValueError as e: - # Re-raise ValueError as typer.Exit to preserve the error message - raise typer.Exit(1) from e + if not verbose: + typer.echo(f"✗ {e}", err=True) + raise typer.Exit(1) from esrc/lfx/src/lfx/cli/commands.py (2)
9-9: Prefer explicit decorator call over functools.partial for syncify.
@syncify(raise_sync_error=False)is clearer than@partial(syncify, ...)and avoids confusion about decorator semantics.Apply this diff:
-from functools import partial ... -from asyncer import syncify +from asyncer import syncify ... -@partial(syncify, raise_sync_error=False) +@syncify(raise_sync_error=False) async def serve_command(Also applies to: 14-15, 37-38
300-313: Nested event loop risk: uvicorn.run inside a syncified async function.Because
serve_commandruns undersyncify(which drives an event loop), callinguvicorn.runinside it can conflict with an already running loop in some environments. In practice this often works, but it’s brittle.
- Option A (verify): Manually run
lfx servein a context where an event loop is active (e.g., inside IPython/Jupyter) and confirm no “asyncio.run() cannot be called from a running event loop” or loop reuse errors appear.- Option B (refactor): Keep
serve_commandas a plain sync function and syncify only the loader calls:-@syncify(raise_sync_error=False) -async def serve_command(...): +def serve_command(...): ... - if resolved_path.suffix == ".json": - graph = await load_graph_from_path(...) + from asyncer import syncify as _syncify + _load_from_path_sync = _syncify(load_graph_from_path, raise_sync_error=False) + _load_from_script_sync = _syncify(load_graph_from_script, raise_sync_error=False) + if resolved_path.suffix == ".json": + graph = _load_from_path_sync(resolved_path, resolved_path.suffix, verbose_print, verbose=verbose) elif resolved_path.suffix == ".py": - graph = await load_graph_from_script(resolved_path) + graph = _load_from_script_sync(resolved_path) ... uvicorn.run(serve_app, ...)This limits event‑loop usage to short-lived sections before starting Uvicorn.
src/lfx/tests/unit/cli/test_serve_components.py (1)
202-205: Add a unit test covering Python scripts that only expose get_graph().Given the feature goal, add a test that patches a temp .py script with only
async def get_graph(): ...and assertsload_graph_from_path(..., ".py", ...)succeeds.I can draft a focused test that writes a temp script exposing only
get_graph()(async and sync variants) and validates both paths. Want me to add it?
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/backend/tests/data/simple_agent.py(1 hunks)src/backend/tests/unit/test_simple_agent_in_lfx_run.py(4 hunks)src/lfx/src/lfx/cli/commands.py(3 hunks)src/lfx/src/lfx/cli/common.py(2 hunks)src/lfx/src/lfx/cli/run.py(1 hunks)src/lfx/src/lfx/cli/script_loader.py(4 hunks)src/lfx/tests/unit/cli/test_common.py(2 hunks)src/lfx/tests/unit/cli/test_script_loader.py(4 hunks)src/lfx/tests/unit/cli/test_serve_components.py(5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/tests/unit/test_simple_agent_in_lfx_run.pysrc/backend/tests/data/simple_agent.py
src/backend/tests/unit/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Files:
src/backend/tests/unit/test_simple_agent_in_lfx_run.py
src/backend/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...
Files:
src/backend/tests/unit/test_simple_agent_in_lfx_run.pysrc/backend/tests/data/simple_agent.py
🧠 Learnings (6)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test both sync and async code paths in backend Python tests, using 'pytest.mark.asyncio' for async tests.
Applied to files:
src/lfx/tests/unit/cli/test_common.pysrc/lfx/tests/unit/cli/test_script_loader.pysrc/lfx/tests/unit/cli/test_serve_components.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Use 'anyio' and 'aiofiles' for async file operations in backend Python tests that involve file handling.
Applied to files:
src/lfx/tests/unit/cli/test_common.pysrc/lfx/tests/unit/cli/test_serve_components.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Applied to files:
src/lfx/tests/unit/cli/test_serve_components.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's REST API endpoints in backend Python tests using the async client fixture and asserting response codes and payloads.
Applied to files:
src/lfx/tests/unit/cli/test_serve_components.py
📚 Learning: 2025-07-18T18:25:54.487Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.487Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Applied to files:
src/lfx/tests/unit/cli/test_serve_components.py
📚 Learning: 2025-08-05T22:51:27.961Z
Learnt from: edwinjosechittilappilly
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-08-05T22:51:27.961Z
Learning: The TestComposioComponentAuth test in src/backend/tests/unit/components/bundles/composio/test_base_composio.py demonstrates proper integration testing patterns for external API components, including real API calls with mocking for OAuth completion, comprehensive resource cleanup, and proper environment variable handling with pytest.skip() fallbacks.
Applied to files:
src/lfx/tests/unit/cli/test_serve_components.py
🧬 Code graph analysis (7)
src/lfx/src/lfx/cli/run.py (1)
src/lfx/src/lfx/cli/script_loader.py (1)
load_graph_from_script(75-120)
src/lfx/tests/unit/cli/test_common.py (2)
src/lfx/tests/unit/cli/test_serve_components.py (9)
test_load_graph_from_path_success(204-218)verbose_print(186-187)verbose_print(196-197)verbose_print(213-214)verbose_print(230-231)verbose_print(265-266)verbose_print(280-281)verbose_print(301-302)verbose_print(449-450)src/lfx/src/lfx/cli/common.py (1)
load_graph_from_path(227-274)
src/backend/tests/data/simple_agent.py (2)
src/lfx/src/lfx/custom/custom_component/component.py (1)
to_toolkit(1314-1335)src/backend/base/langflow/__main__.py (1)
api_key(847-895)
src/lfx/src/lfx/cli/common.py (1)
src/lfx/src/lfx/cli/script_loader.py (1)
load_graph_from_script(75-120)
src/lfx/tests/unit/cli/test_script_loader.py (1)
src/lfx/src/lfx/cli/script_loader.py (1)
load_graph_from_script(75-120)
src/lfx/tests/unit/cli/test_serve_components.py (2)
src/lfx/tests/unit/cli/test_common.py (1)
test_load_graph_from_path_success(172-186)src/lfx/src/lfx/cli/common.py (1)
load_graph_from_path(227-274)
src/lfx/src/lfx/cli/commands.py (2)
src/lfx/src/lfx/cli/common.py (1)
load_graph_from_path(227-274)src/lfx/src/lfx/cli/script_loader.py (1)
load_graph_from_script(75-120)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Test Starter Templates
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
🔇 Additional comments (9)
src/backend/tests/data/simple_agent.py (1)
56-58: LGTM: graph construction and wiring look correct.src/backend/tests/unit/test_simple_agent_in_lfx_run.py (2)
115-120: Script content assertions: good coverage of async get_graph path.
1-1: Backend test hygiene — run format + lint.Verification failed here:
/bin/bash: line 3: make: command not found. Runmake format_backendandmake lintlocally or in CI and commit any resulting fixes (target: src/backend/tests/unit/test_simple_agent_in_lfx_run.py).src/lfx/tests/unit/cli/test_common.py (2)
171-173: Async test conversion looks correct.Awaiting
load_graph_from_pathand marking the test withpytest.mark.asynciomatches the new async API. Assertions for verbose behavior and disable_logs are solid.Also applies to: 181-181
188-190: Failure-path assertions are accurate.Mocking the loader to raise and asserting Typer exit + error log ensures the async error path is covered.
Also applies to: 196-201
src/lfx/src/lfx/cli/commands.py (1)
201-209: LGTM: async awaits for loaders in serve path.Awaiting both JSON and Python script loaders matches the new async interfaces and keeps logs consistent.
src/lfx/tests/unit/cli/test_serve_components.py (3)
203-205: Async migration of success test is correct.Awaiting
load_graph_from_pathand assertingdisable_logs=Falsewhenverbose=Trueis spot on.Also applies to: 216-216
221-223: Error-path test updated correctly.Awaiting the async loader and asserting
disable_logs=Trueverifies the quiet mode path.Also applies to: 233-235
435-436: Integration test aligns with async API.End‑to‑end uses of
load_graph_from_pathare consistent and validate flow ID + app wiring.Also applies to: 453-454
…alization - Introduced an async `get_graph` function in `README.md` to facilitate non-blocking component initialization. - Enhanced the logging configuration and component setup within the async function, ensuring a smoother flow. - Updated documentation to clarify the purpose and return type of the `get_graph` function, aligning with the async handling improvements.
|
| ) | ||
| chat_output = cp.ChatOutput().set(input_value=agent.message_response) | ||
|
|
||
| return Graph(chat_input, chat_output, log_config=log_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Tested this locally, works great.
…cripts (langflow-ai#9913) * feat: Enhance graph loading functionality to support async retrieval - Updated `load_graph_from_script` to be an async function, allowing for the retrieval of the graph via an async `get_graph` function if available. - Implemented fallback to the existing `graph` variable for backward compatibility. - Enhanced `find_graph_variable` to identify both `get_graph` function definitions and `graph` variable assignments, improving flexibility in script handling. * feat: Update load_graph_from_script to support async graph retrieval - Refactored `load_graph_from_script` to be an async function, enabling the use of an async `get_graph` function for graph retrieval. - Implemented a fallback mechanism to access the `graph` variable for backward compatibility. - Enhanced error handling to provide clearer messages when neither `graph` nor `get_graph()` is found in the script. * feat: Refactor simple_agent.py to support async graph creation - Introduced an async `get_graph` function to handle the initialization of components and graph creation without blocking. - Updated the logging configuration and component setup to be part of the async function, improving the overall flow and responsiveness. - Enhanced documentation for the `get_graph` function to clarify its purpose and return type. * feat: Update serve_command and run functions to support async graph loading - Refactored `serve_command` to be an async function using `syncify`, allowing for non-blocking execution. - Updated calls to `load_graph_from_path` and `load_graph_from_script` within `serve_command` and `run` to await their results, enhancing performance and responsiveness. - Improved overall async handling in the CLI commands for better integration with async workflows. * feat: Refactor load_graph_from_path to support async execution - Changed `load_graph_from_path` to an async function, enabling non-blocking graph loading. - Updated the call to `load_graph_from_script` to use await, improving performance during graph retrieval. - Enhanced the overall async handling in the CLI for better integration with async workflows. * feat: Enhance async handling in simple_agent and related tests - Updated `get_graph` function in `simple_agent.py` to utilize async component initialization for improved responsiveness. - Modified test cases in `test_simple_agent_in_lfx_run.py` to validate the async behavior of `get_graph`. - Refactored various test functions across multiple files to support async execution, ensuring compatibility with the new async workflows. - Improved documentation for async functions to clarify their purpose and usage. * docs: Implement async get_graph function for improved component initialization - Introduced an async `get_graph` function in `README.md` to facilitate non-blocking component initialization. - Enhanced the logging configuration and component setup within the async function, ensuring a smoother flow. - Updated documentation to clarify the purpose and return type of the `get_graph` function, aligning with the async handling improvements. * refactor: reorder imports in simple_agent test file * style: reorder imports in simple_agent test file * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…cripts (langflow-ai#9913) * feat: Enhance graph loading functionality to support async retrieval - Updated `load_graph_from_script` to be an async function, allowing for the retrieval of the graph via an async `get_graph` function if available. - Implemented fallback to the existing `graph` variable for backward compatibility. - Enhanced `find_graph_variable` to identify both `get_graph` function definitions and `graph` variable assignments, improving flexibility in script handling. * feat: Update load_graph_from_script to support async graph retrieval - Refactored `load_graph_from_script` to be an async function, enabling the use of an async `get_graph` function for graph retrieval. - Implemented a fallback mechanism to access the `graph` variable for backward compatibility. - Enhanced error handling to provide clearer messages when neither `graph` nor `get_graph()` is found in the script. * feat: Refactor simple_agent.py to support async graph creation - Introduced an async `get_graph` function to handle the initialization of components and graph creation without blocking. - Updated the logging configuration and component setup to be part of the async function, improving the overall flow and responsiveness. - Enhanced documentation for the `get_graph` function to clarify its purpose and return type. * feat: Update serve_command and run functions to support async graph loading - Refactored `serve_command` to be an async function using `syncify`, allowing for non-blocking execution. - Updated calls to `load_graph_from_path` and `load_graph_from_script` within `serve_command` and `run` to await their results, enhancing performance and responsiveness. - Improved overall async handling in the CLI commands for better integration with async workflows. * feat: Refactor load_graph_from_path to support async execution - Changed `load_graph_from_path` to an async function, enabling non-blocking graph loading. - Updated the call to `load_graph_from_script` to use await, improving performance during graph retrieval. - Enhanced the overall async handling in the CLI for better integration with async workflows. * feat: Enhance async handling in simple_agent and related tests - Updated `get_graph` function in `simple_agent.py` to utilize async component initialization for improved responsiveness. - Modified test cases in `test_simple_agent_in_lfx_run.py` to validate the async behavior of `get_graph`. - Refactored various test functions across multiple files to support async execution, ensuring compatibility with the new async workflows. - Improved documentation for async functions to clarify their purpose and usage. * docs: Implement async get_graph function for improved component initialization - Introduced an async `get_graph` function in `README.md` to facilitate non-blocking component initialization. - Enhanced the logging configuration and component setup within the async function, ensuring a smoother flow. - Updated documentation to clarify the purpose and return type of the `get_graph` function, aligning with the async handling improvements. * refactor: reorder imports in simple_agent test file * style: reorder imports in simple_agent test file * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…parse errors (#10508) * feat: Add ALTK Agent with tool validation and comprehensive tests (#10587) * Add ALTK Agent with tool validation and comprehensive tests - Added agent-lifecycle-toolkit~=0.4.1 dependency to pyproject.toml - Implemented ALTKBaseAgent with comprehensive error handling and tool validation - Added ALTKToolWrappers for SPARC integration and tool execution safety - Created ALTK Agent component with proper LangChain integration - Added comprehensive test suite covering tool validation, conversation context, and edge cases - Fixed docstring formatting to comply with ruff linting standards * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * minor fix to execute_tool that was left out. * Fixes following coderabbitai comments. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Update component_index.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Add custom message to dict conversion in ValidatedTool * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Add Notion integration components to index Updated component_index.json to include new Notion integration components: AddContentToPage, NotionDatabaseProperties, NotionListPages, NotionPageContent, NotionPageCreator, NotionPageUpdate, and NotionSearch. These components provide functionality for interacting with Notion databases and pages, including querying, creating, updating, and retrieving content. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: Koren Lazar <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Edwin Jose <[email protected]> * feat: Implement dynamic model discovery system (#10523) * add dynamic model request * add description to groq * add cache folder to store cache models json * change git ignore description * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * add comprehensive tests for Groq dynamic model discovery - Add 101 unit tests covering success, error, and edge cases - Test model discovery, caching, tool calling detection - Test fallback models and backward compatibility - Add support for real GROQ_API_KEY from environment - Fix all lint errors and improve code quality * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * fix Python 3.10 compatibility - replace UTC with timezone.utc Python 3.10 doesn't have datetime.UTC, need to use timezone.utc instead * fix pytest hook signature - use config instead of _config * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * fix conftest config.py * fix timezone UTC on tests * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: remove `code` from Transactions to reduce clutter in logs (#10400) * refactor: remove code from transaction model inputs * refactor: remove code from transaction model inputs * tests: add tests to make sure code is not added to transactions data * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * refactor: improve code removal from logs with explicit dict copying --------- Co-authored-by: Edwin Jose <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: new release for cuga component (#10591) * feat: new release of cuga * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * fix: address review * fix: fixed more bugs * fix: build component index * [autofix.ci] apply automated fixes * fix: update test * chore: update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: adds Component Inputs telemetry (#10254) * feat: Introduce telemetry tracking for sensitive field types Added a new set of field types that should not be tracked in telemetry due to their sensitive nature, including PASSWORD, AUTH, FILE, CONNECTION, and MCP. Updated relevant input classes to ensure telemetry tracking is disabled for these sensitive fields, enhancing data privacy and security. * feat: Enhance telemetry payloads with additional fields and serialization support Added new fields to the ComponentPayload and ComponentInputsPayload classes, including component_id and component_run_id, to improve telemetry data tracking. Introduced a serialize_input_values function to handle JSON serialization of component input values, ensuring robust handling of input data for telemetry purposes. * feat: Implement telemetry input tracking and caching Added functionality to track and cache telemetry input values within the Component class. Introduced a method to determine if inputs should be tracked based on sensitivity and an accessor for retrieving cached telemetry data, enhancing the robustness of telemetry handling. * feat: Add logging for component input telemetry Introduced a new method, log_package_component_inputs, to the TelemetryService for logging telemetry data related to component inputs. This enhancement improves the tracking capabilities of the telemetry system, allowing for more detailed insights into component interactions. * feat: Enhance telemetry logging for component execution Added functionality to log component input telemetry both during successful execution and error cases. Introduced a unique component_run_id for each execution to improve tracking. This update ensures comprehensive telemetry data collection, enhancing the robustness of the telemetry system. * feat: Extend telemetry payload tests and enhance serialization Added tests for the new component_id and component_run_id fields in ComponentPayload and ComponentInputsPayload classes. Introduced a new test suite for ComponentInputTelemetry, covering serialization of various data types and handling of edge cases. This update improves the robustness and coverage of telemetry data handling in the system. * fix: Update default telemetry tracking behavior in BaseInputMixin Changed the default value of track_in_telemetry from True to False in the BaseInputMixin class. Updated documentation to clarify that telemetry tracking is now opt-in and can be explicitly enabled for individual input types, enhancing data privacy and control. * fix: Update telemetry tracking defaults for input types Modified the default value of `track_in_telemetry` for various input classes to enhance data privacy. Regular inputs now default to False, while safe inputs like `IntInput` and `BoolInput` default to True, ensuring explicit opt-in for telemetry tracking. Updated related tests to reflect these changes. * feat: add chunk_index and total_chunks fields to ComponentInputsPayload This commit adds two new optional fields to ComponentInputsPayload: - chunk_index: Index of this chunk in a split payload sequence - total_chunks: Total number of chunks in the split sequence Both fields default to None and use camelCase aliases for serialization. This is Task 1 of the telemetry query parameter splitting implementation. Tests included: - Verify fields exist and can be set - Verify camelCase serialization aliases work correctly - Verify fields default to None when not provided Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: update ComponentInputsPayload to support automatic splitting of oversized inputs This commit enhances the ComponentInputsPayload class by implementing functionality to automatically split input values into multiple chunks if they exceed the maximum URL size limit. Key changes include: - Added methods for calculating URL size, truncating oversized values, and splitting payloads. - Updated component_inputs field to accept a dictionary instead of a string for better handling of input values. - Improved documentation for the ComponentInputsPayload class to reflect the new splitting behavior and usage examples. These changes aim to improve telemetry data handling and ensure compliance with URL length restrictions. * refactor: enhance log_package_component_inputs to handle oversized payloads This commit updates the log_package_component_inputs method in the TelemetryService class to split component input payloads into multiple requests if they exceed the maximum URL size limit. Key changes include: - Added logic to split the payload using the new split_if_needed method. - Each chunk is queued separately for telemetry logging. These improvements ensure better handling of telemetry data while adhering to URL length restrictions. * refactor: centralize maximum telemetry URL size constant This commit introduces a centralized constant, MAX_TELEMETRY_URL_SIZE, to define the maximum URL length for telemetry GET requests. Key changes include: - Added MAX_TELEMETRY_URL_SIZE constant to schema.py for better maintainability. - Updated split_if_needed method in ComponentInputsPayload to use the new constant instead of a hardcoded value. - Adjusted the TelemetryService to reference the centralized constant for URL size limits. These changes enhance code clarity and ensure consistent handling of URL size limits across the telemetry service. * refactor: update ComponentInputsPayload tests to use dictionary inputs This commit modifies the tests for ComponentInputsPayload to utilize a dictionary for component inputs instead of a serialized JSON string. Key changes include: - Renamed the test method to reflect the new input type. - Removed unnecessary serialization steps and assertions related to JSON strings. - Added assertions to verify the correct handling of dictionary inputs. These changes streamline the testing process and improve clarity in how component inputs are represented. * test: add integration tests for telemetry service payload splitting This commit introduces integration tests for the TelemetryService to verify its handling of large and small payloads. Key changes include: - Added tests to ensure large payloads are split into multiple chunks and queued correctly. - Implemented a test to confirm that small payloads are not split and result in a single queued event. - Created a mock settings service for testing purposes. These tests enhance the reliability of the telemetry service by ensuring proper payload management. * test: enhance ComponentInputsPayload tests with additional scenarios This commit expands the test suite for ComponentInputsPayload by adding various scenarios to ensure robust handling of input payloads. Key changes include: - Introduced tests for calculating URL size, ensuring it returns a positive integer and accounts for encoding. - Added tests to verify the splitting logic for large payloads, including checks for chunk metadata and preservation of fixed fields. - Implemented property-based tests using Hypothesis to validate that all chunks respect the maximum URL size and preserve original data. These enhancements improve the reliability and coverage of the ComponentInputsPayload tests, ensuring proper functionality under various conditions. * [autofix.ci] apply automated fixes * optimize query param encoding Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> * refactor: extract telemetry logging logic into a separate function This commit introduces a new function, _log_component_input_telemetry, to centralize the logic for logging component input telemetry. The function is called in two places within the generate_flow_events function, improving code readability and maintainability by reducing duplication. This change enhances the clarity of telemetry handling in the flow generation process. * refactor: optimize truncation logic in ComponentInputsPayload This commit refines the truncation logic for input values in the ComponentInputsPayload class. The previous binary search method for string values has been simplified, allowing for direct truncation of both string and non-string values. This change enhances code clarity and maintains functionality while ensuring optimal handling of oversized inputs. * refactor: update telemetry tracking logic to respect opt-in flag This commit modifies the telemetry tracking logic in the Component class to change the default behavior of the `track_in_telemetry` attribute from True to False. This adjustment enhances user privacy by requiring explicit consent for tracking input objects in telemetry. The change ensures that sensitive field types are still auto-excluded from tracking, maintaining the integrity of the telemetry data. * refactor: update tests to use dictionary format for component inputs This commit modifies the integration tests for telemetry payload validation and component input telemetry to utilize dictionaries for component inputs instead of serialized JSON strings. Key changes include: - Updated assertions to compare dictionary inputs directly. - Enhanced clarity and maintainability of the test cases by removing unnecessary serialization steps. These changes improve the representation of component inputs in tests, aligning with recent refactoring efforts. * [autofix.ci] apply automated fixes * refactor: specify type for current_chunk_inputs in ComponentInputsPayload This commit updates the type annotation for the current_chunk_inputs variable in the ComponentInputsPayload class to explicitly define it as a dictionary. This change enhances code clarity and maintainability by providing better type information for developers working with the code. * test: add component_id to ComponentPayload tests This commit enhances the test cases for the ComponentPayload class by adding a component_id parameter to various initialization tests. The updates ensure that the component_id is properly tested across different scenarios, including valid parameters, error messages, and edge cases. This change improves the robustness of the tests and aligns with recent updates to the ComponentPayload structure. * [autofix.ci] apply automated fixes * feat: add component_id to ComponentPayload in build_vertex function * fix: update MAX_TELEMETRY_URL_SIZE to 2048 and adjust related tests This commit increases the maximum URL size for telemetry GET requests from 2000 to 2048 bytes to align with Scarf's specifications. Corresponding test assertions have been updated to reference the new constant, ensuring consistency across the codebase. * [autofix.ci] apply automated fixes * feat(telemetry): add track_in_telemetry field to starter project configurations * refactor(telemetry): remove unused blank line in test imports * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * update starter templates * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: Claude <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> * feat: Add gpt-5.1 model to Language models (#10590) * Add gpt-5.1 model to starter projects Added 'gpt-5.1' to the list of available models in all starter project JSON files to support the new model version. This update ensures users can select gpt-5.1 in agent configurations. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Update component_index.json * [autofix.ci] apply automated fixes * Update component_index.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: Use the proper Embeddings import for Qdrant vector store (#10613) * Use the proper Embeddings import for Qdrant vector store * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: Madhavan <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: Ensure split text test is more robust (#10622) * fix: Ensure split text test is more robust * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: use issubclass in the pool creation (#10232) * use issubclass in the pool creation * [autofix.ci] apply automated fixes * add poolclass pytests * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: Hamza Rashid <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: cristhianzl <[email protected]> * feat: make it possible to load graphs using `get_graph` function in scripts (#9913) * feat: Enhance graph loading functionality to support async retrieval - Updated `load_graph_from_script` to be an async function, allowing for the retrieval of the graph via an async `get_graph` function if available. - Implemented fallback to the existing `graph` variable for backward compatibility. - Enhanced `find_graph_variable` to identify both `get_graph` function definitions and `graph` variable assignments, improving flexibility in script handling. * feat: Update load_graph_from_script to support async graph retrieval - Refactored `load_graph_from_script` to be an async function, enabling the use of an async `get_graph` function for graph retrieval. - Implemented a fallback mechanism to access the `graph` variable for backward compatibility. - Enhanced error handling to provide clearer messages when neither `graph` nor `get_graph()` is found in the script. * feat: Refactor simple_agent.py to support async graph creation - Introduced an async `get_graph` function to handle the initialization of components and graph creation without blocking. - Updated the logging configuration and component setup to be part of the async function, improving the overall flow and responsiveness. - Enhanced documentation for the `get_graph` function to clarify its purpose and return type. * feat: Update serve_command and run functions to support async graph loading - Refactored `serve_command` to be an async function using `syncify`, allowing for non-blocking execution. - Updated calls to `load_graph_from_path` and `load_graph_from_script` within `serve_command` and `run` to await their results, enhancing performance and responsiveness. - Improved overall async handling in the CLI commands for better integration with async workflows. * feat: Refactor load_graph_from_path to support async execution - Changed `load_graph_from_path` to an async function, enabling non-blocking graph loading. - Updated the call to `load_graph_from_script` to use await, improving performance during graph retrieval. - Enhanced the overall async handling in the CLI for better integration with async workflows. * feat: Enhance async handling in simple_agent and related tests - Updated `get_graph` function in `simple_agent.py` to utilize async component initialization for improved responsiveness. - Modified test cases in `test_simple_agent_in_lfx_run.py` to validate the async behavior of `get_graph`. - Refactored various test functions across multiple files to support async execution, ensuring compatibility with the new async workflows. - Improved documentation for async functions to clarify their purpose and usage. * docs: Implement async get_graph function for improved component initialization - Introduced an async `get_graph` function in `README.md` to facilitate non-blocking component initialization. - Enhanced the logging configuration and component setup within the async function, ensuring a smoother flow. - Updated documentation to clarify the purpose and return type of the `get_graph` function, aligning with the async handling improvements. * refactor: reorder imports in simple_agent test file * style: reorder imports in simple_agent test file * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: Add ALTK Agent with tool validation and comprehensive tests (#10587) * Add ALTK Agent with tool validation and comprehensive tests - Added agent-lifecycle-toolkit~=0.4.1 dependency to pyproject.toml - Implemented ALTKBaseAgent with comprehensive error handling and tool validation - Added ALTKToolWrappers for SPARC integration and tool execution safety - Created ALTK Agent component with proper LangChain integration - Added comprehensive test suite covering tool validation, conversation context, and edge cases - Fixed docstring formatting to comply with ruff linting standards * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * minor fix to execute_tool that was left out. * Fixes following coderabbitai comments. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Update component_index.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Add custom message to dict conversion in ValidatedTool * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Add Notion integration components to index Updated component_index.json to include new Notion integration components: AddContentToPage, NotionDatabaseProperties, NotionListPages, NotionPageContent, NotionPageCreator, NotionPageUpdate, and NotionSearch. These components provide functionality for interacting with Notion databases and pages, including querying, creating, updating, and retrieving content. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: Koren Lazar <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Edwin Jose <[email protected]> * feat: Implement dynamic model discovery system (#10523) * add dynamic model request * add description to groq * add cache folder to store cache models json * change git ignore description * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * add comprehensive tests for Groq dynamic model discovery - Add 101 unit tests covering success, error, and edge cases - Test model discovery, caching, tool calling detection - Test fallback models and backward compatibility - Add support for real GROQ_API_KEY from environment - Fix all lint errors and improve code quality * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * fix Python 3.10 compatibility - replace UTC with timezone.utc Python 3.10 doesn't have datetime.UTC, need to use timezone.utc instead * fix pytest hook signature - use config instead of _config * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * fix conftest config.py * fix timezone UTC on tests * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: remove `code` from Transactions to reduce clutter in logs (#10400) * refactor: remove code from transaction model inputs * refactor: remove code from transaction model inputs * tests: add tests to make sure code is not added to transactions data * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * refactor: improve code removal from logs with explicit dict copying --------- Co-authored-by: Edwin Jose <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: new release for cuga component (#10591) * feat: new release of cuga * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * fix: address review * fix: fixed more bugs * fix: build component index * [autofix.ci] apply automated fixes * fix: update test * chore: update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: adds Component Inputs telemetry (#10254) * feat: Introduce telemetry tracking for sensitive field types Added a new set of field types that should not be tracked in telemetry due to their sensitive nature, including PASSWORD, AUTH, FILE, CONNECTION, and MCP. Updated relevant input classes to ensure telemetry tracking is disabled for these sensitive fields, enhancing data privacy and security. * feat: Enhance telemetry payloads with additional fields and serialization support Added new fields to the ComponentPayload and ComponentInputsPayload classes, including component_id and component_run_id, to improve telemetry data tracking. Introduced a serialize_input_values function to handle JSON serialization of component input values, ensuring robust handling of input data for telemetry purposes. * feat: Implement telemetry input tracking and caching Added functionality to track and cache telemetry input values within the Component class. Introduced a method to determine if inputs should be tracked based on sensitivity and an accessor for retrieving cached telemetry data, enhancing the robustness of telemetry handling. * feat: Add logging for component input telemetry Introduced a new method, log_package_component_inputs, to the TelemetryService for logging telemetry data related to component inputs. This enhancement improves the tracking capabilities of the telemetry system, allowing for more detailed insights into component interactions. * feat: Enhance telemetry logging for component execution Added functionality to log component input telemetry both during successful execution and error cases. Introduced a unique component_run_id for each execution to improve tracking. This update ensures comprehensive telemetry data collection, enhancing the robustness of the telemetry system. * feat: Extend telemetry payload tests and enhance serialization Added tests for the new component_id and component_run_id fields in ComponentPayload and ComponentInputsPayload classes. Introduced a new test suite for ComponentInputTelemetry, covering serialization of various data types and handling of edge cases. This update improves the robustness and coverage of telemetry data handling in the system. * fix: Update default telemetry tracking behavior in BaseInputMixin Changed the default value of track_in_telemetry from True to False in the BaseInputMixin class. Updated documentation to clarify that telemetry tracking is now opt-in and can be explicitly enabled for individual input types, enhancing data privacy and control. * fix: Update telemetry tracking defaults for input types Modified the default value of `track_in_telemetry` for various input classes to enhance data privacy. Regular inputs now default to False, while safe inputs like `IntInput` and `BoolInput` default to True, ensuring explicit opt-in for telemetry tracking. Updated related tests to reflect these changes. * feat: add chunk_index and total_chunks fields to ComponentInputsPayload This commit adds two new optional fields to ComponentInputsPayload: - chunk_index: Index of this chunk in a split payload sequence - total_chunks: Total number of chunks in the split sequence Both fields default to None and use camelCase aliases for serialization. This is Task 1 of the telemetry query parameter splitting implementation. Tests included: - Verify fields exist and can be set - Verify camelCase serialization aliases work correctly - Verify fields default to None when not provided Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: update ComponentInputsPayload to support automatic splitting of oversized inputs This commit enhances the ComponentInputsPayload class by implementing functionality to automatically split input values into multiple chunks if they exceed the maximum URL size limit. Key changes include: - Added methods for calculating URL size, truncating oversized values, and splitting payloads. - Updated component_inputs field to accept a dictionary instead of a string for better handling of input values. - Improved documentation for the ComponentInputsPayload class to reflect the new splitting behavior and usage examples. These changes aim to improve telemetry data handling and ensure compliance with URL length restrictions. * refactor: enhance log_package_component_inputs to handle oversized payloads This commit updates the log_package_component_inputs method in the TelemetryService class to split component input payloads into multiple requests if they exceed the maximum URL size limit. Key changes include: - Added logic to split the payload using the new split_if_needed method. - Each chunk is queued separately for telemetry logging. These improvements ensure better handling of telemetry data while adhering to URL length restrictions. * refactor: centralize maximum telemetry URL size constant This commit introduces a centralized constant, MAX_TELEMETRY_URL_SIZE, to define the maximum URL length for telemetry GET requests. Key changes include: - Added MAX_TELEMETRY_URL_SIZE constant to schema.py for better maintainability. - Updated split_if_needed method in ComponentInputsPayload to use the new constant instead of a hardcoded value. - Adjusted the TelemetryService to reference the centralized constant for URL size limits. These changes enhance code clarity and ensure consistent handling of URL size limits across the telemetry service. * refactor: update ComponentInputsPayload tests to use dictionary inputs This commit modifies the tests for ComponentInputsPayload to utilize a dictionary for component inputs instead of a serialized JSON string. Key changes include: - Renamed the test method to reflect the new input type. - Removed unnecessary serialization steps and assertions related to JSON strings. - Added assertions to verify the correct handling of dictionary inputs. These changes streamline the testing process and improve clarity in how component inputs are represented. * test: add integration tests for telemetry service payload splitting This commit introduces integration tests for the TelemetryService to verify its handling of large and small payloads. Key changes include: - Added tests to ensure large payloads are split into multiple chunks and queued correctly. - Implemented a test to confirm that small payloads are not split and result in a single queued event. - Created a mock settings service for testing purposes. These tests enhance the reliability of the telemetry service by ensuring proper payload management. * test: enhance ComponentInputsPayload tests with additional scenarios This commit expands the test suite for ComponentInputsPayload by adding various scenarios to ensure robust handling of input payloads. Key changes include: - Introduced tests for calculating URL size, ensuring it returns a positive integer and accounts for encoding. - Added tests to verify the splitting logic for large payloads, including checks for chunk metadata and preservation of fixed fields. - Implemented property-based tests using Hypothesis to validate that all chunks respect the maximum URL size and preserve original data. These enhancements improve the reliability and coverage of the ComponentInputsPayload tests, ensuring proper functionality under various conditions. * [autofix.ci] apply automated fixes * optimize query param encoding Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> * refactor: extract telemetry logging logic into a separate function This commit introduces a new function, _log_component_input_telemetry, to centralize the logic for logging component input telemetry. The function is called in two places within the generate_flow_events function, improving code readability and maintainability by reducing duplication. This change enhances the clarity of telemetry handling in the flow generation process. * refactor: optimize truncation logic in ComponentInputsPayload This commit refines the truncation logic for input values in the ComponentInputsPayload class. The previous binary search method for string values has been simplified, allowing for direct truncation of both string and non-string values. This change enhances code clarity and maintains functionality while ensuring optimal handling of oversized inputs. * refactor: update telemetry tracking logic to respect opt-in flag This commit modifies the telemetry tracking logic in the Component class to change the default behavior of the `track_in_telemetry` attribute from True to False. This adjustment enhances user privacy by requiring explicit consent for tracking input objects in telemetry. The change ensures that sensitive field types are still auto-excluded from tracking, maintaining the integrity of the telemetry data. * refactor: update tests to use dictionary format for component inputs This commit modifies the integration tests for telemetry payload validation and component input telemetry to utilize dictionaries for component inputs instead of serialized JSON strings. Key changes include: - Updated assertions to compare dictionary inputs directly. - Enhanced clarity and maintainability of the test cases by removing unnecessary serialization steps. These changes improve the representation of component inputs in tests, aligning with recent refactoring efforts. * [autofix.ci] apply automated fixes * refactor: specify type for current_chunk_inputs in ComponentInputsPayload This commit updates the type annotation for the current_chunk_inputs variable in the ComponentInputsPayload class to explicitly define it as a dictionary. This change enhances code clarity and maintainability by providing better type information for developers working with the code. * test: add component_id to ComponentPayload tests This commit enhances the test cases for the ComponentPayload class by adding a component_id parameter to various initialization tests. The updates ensure that the component_id is properly tested across different scenarios, including valid parameters, error messages, and edge cases. This change improves the robustness of the tests and aligns with recent updates to the ComponentPayload structure. * [autofix.ci] apply automated fixes * feat: add component_id to ComponentPayload in build_vertex function * fix: update MAX_TELEMETRY_URL_SIZE to 2048 and adjust related tests This commit increases the maximum URL size for telemetry GET requests from 2000 to 2048 bytes to align with Scarf's specifications. Corresponding test assertions have been updated to reference the new constant, ensuring consistency across the codebase. * [autofix.ci] apply automated fixes * feat(telemetry): add track_in_telemetry field to starter project configurations * refactor(telemetry): remove unused blank line in test imports * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * update starter templates * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: Claude <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> * feat: Add gpt-5.1 model to Language models (#10590) * Add gpt-5.1 model to starter projects Added 'gpt-5.1' to the list of available models in all starter project JSON files to support the new model version. This update ensures users can select gpt-5.1 in agent configurations. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Update component_index.json * [autofix.ci] apply automated fixes * Update component_index.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: Use the proper Embeddings import for Qdrant vector store (#10613) * Use the proper Embeddings import for Qdrant vector store * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: Madhavan <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: Ensure split text test is more robust (#10622) * fix: Ensure split text test is more robust * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: use issubclass in the pool creation (#10232) * use issubclass in the pool creation * [autofix.ci] apply automated fixes * add poolclass pytests * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: Hamza Rashid <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: cristhianzl <[email protected]> * feat: make it possible to load graphs using `get_graph` function in scripts (#9913) * feat: Enhance graph loading functionality to support async retrieval - Updated `load_graph_from_script` to be an async function, allowing for the retrieval of the graph via an async `get_graph` function if available. - Implemented fallback to the existing `graph` variable for backward compatibility. - Enhanced `find_graph_variable` to identify both `get_graph` function definitions and `graph` variable assignments, improving flexibility in script handling. * feat: Update load_graph_from_script to support async graph retrieval - Refactored `load_graph_from_script` to be an async function, enabling the use of an async `get_graph` function for graph retrieval. - Implemented a fallback mechanism to access the `graph` variable for backward compatibility. - Enhanced error handling to provide clearer messages when neither `graph` nor `get_graph()` is found in the script. * feat: Refactor simple_agent.py to support async graph creation - Introduced an async `get_graph` function to handle the initialization of components and graph creation without blocking. - Updated the logging configuration and component setup to be part of the async function, improving the overall flow and responsiveness. - Enhanced documentation for the `get_graph` function to clarify its purpose and return type. * feat: Update serve_command and run functions to support async graph loading - Refactored `serve_command` to be an async function using `syncify`, allowing for non-blocking execution. - Updated calls to `load_graph_from_path` and `load_graph_from_script` within `serve_command` and `run` to await their results, enhancing performance and responsiveness. - Improved overall async handling in the CLI commands for better integration with async workflows. * feat: Refactor load_graph_from_path to support async execution - Changed `load_graph_from_path` to an async function, enabling non-blocking graph loading. - Updated the call to `load_graph_from_script` to use await, improving performance during graph retrieval. - Enhanced the overall async handling in the CLI for better integration with async workflows. * feat: Enhance async handling in simple_agent and related tests - Updated `get_graph` function in `simple_agent.py` to utilize async component initialization for improved responsiveness. - Modified test cases in `test_simple_agent_in_lfx_run.py` to validate the async behavior of `get_graph`. - Refactored various test functions across multiple files to support async execution, ensuring compatibility with the new async workflows. - Improved documentation for async functions to clarify their purpose and usage. * docs: Implement async get_graph function for improved component initialization - Introduced an async `get_graph` function in `README.md` to facilitate non-blocking component initialization. - Enhanced the logging configuration and component setup within the async function, ensuring a smoother flow. - Updated documentation to clarify the purpose and return type of the `get_graph` function, aligning with the async handling improvements. * refactor: reorder imports in simple_agent test file * style: reorder imports in simple_agent test file * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: prevent UI from getting stuck when switching to cURL mode after parse errors * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes --------- Co-authored-by: Koren Lazar <[email protected]> Co-authored-by: Koren Lazar <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Edwin Jose <[email protected]> Co-authored-by: Cristhian Zanforlin Lousa <[email protected]> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> Co-authored-by: Sami Marreed <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> Co-authored-by: Madhavan <[email protected]> Co-authored-by: Madhavan <[email protected]> Co-authored-by: Eric Hare <[email protected]> Co-authored-by: ming <[email protected]> Co-authored-by: Hamza Rashid <[email protected]>



Makes how to define Graph scripts that require async calls a bit clearer
Summary by CodeRabbit