-
Notifications
You must be signed in to change notification settings - Fork 8.3k
(feat) Dev APIs: Add lifecycle events with AGUI protocol #10780
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
|
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 WalkthroughAdds an async lifecycle observability system: a new Changes
Sequence DiagramsequenceDiagram
participant Caller as Caller
participant Decor as `@observable`
participant Host as Graph/Vertex
participant EM as EventManager
participant Enc as EventEncoder
Caller->>Host: call observed method (e.g., _run/_build, kwargs include event_manager)
Host->>Decor: invocation (decorator wrapper)
Decor->>Host: before_callback_event(...)
activate Host
note right of Host `#D3E5FF`: build raw metrics & start payload
Host-->>Decor: Run/StepStartedEvent payload
deactivate Host
Decor->>EM: publish(start payload)
activate EM
EM->>Enc: encode(start payload)
deactivate EM
Decor->>Host: execute original method
activate Host
Host-->>Decor: result / exception
deactivate Host
alt success
Decor->>Host: after_callback_event(result,...)
activate Host
note right of Host `#D3E5FF`: build raw metrics & finish payload
Host-->>Decor: Run/StepFinishedEvent payload
deactivate Host
Decor->>EM: publish(finish payload)
activate EM
EM->>Enc: encode(finish payload)
deactivate EM
Decor-->>Caller: return result
else error
Decor->>Host: error_callback_event(exception,...)
activate Host
Host-->>Decor: error payload (optional)
deactivate Host
Decor->>EM: publish(error payload)
Decor-->>Caller: return None (exception swallowed by decorator)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
7c77458 to
ddac500
Compare
ca11b66 to
388f08f
Compare
| raise ValueError(msg) | ||
| vertex.update_raw_params(inputs, overwrite=True) | ||
|
|
||
| @observable |
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.
Heads up: I will remove this once the PR is reviewed and everybody has understood what the intended use of the observable decorator is. This shouldn't go to production since it's not necessary to be called until we are ready for our streaming APIs.
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (40.80%) 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 #10780 +/- ##
==========================================
+ Coverage 34.03% 34.10% +0.07%
==========================================
Files 1407 1408 +1
Lines 66661 66770 +109
Branches 9839 9858 +19
==========================================
+ Hits 22689 22773 +84
- Misses 42787 42804 +17
- Partials 1185 1193 +8
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: 5
🧹 Nitpick comments (4)
src/lfx/src/lfx/events/observability/lifecycle_events.py (1)
70-70: TODO comments indicate incomplete implementation.The event publishing logic is not yet implemented. Ensure this is tracked for completion before production use.
Would you like me to open an issue to track the completion of event publishing logic?
Also applies to: 82-83
src/lfx/src/lfx/graph/vertex/base.py (1)
845-861: Redundanthasattrchecks for methods defined in the same class.The
hasattr(self, "raw_event_metrics")checks are unnecessary sinceraw_event_metricsis defined in this same class and will always exist.def before_callback_event(self, *args, **kwargs): """Should be a AGUI compatible event. VERTEX class generates a StepStartedEvent event. """ - metrics = {} - if hasattr(self, "raw_event_metrics"): - metrics = self.raw_event_metrics({"component_id": self.id}) - + metrics = self.raw_event_metrics({"component_id": self.id}) return StepStartedEvent(step_name=self.display_name, raw_event={"langflow": metrics}) def after_callback_event(self, result, *args, **kwargs): """Should be a AGUI compatible event. VERTEX class generates a StepFinishedEvent event. """ - metrics = {} - if hasattr(self, "raw_event_metrics"): - metrics = self.raw_event_metrics({"component_id": self.id}) + metrics = self.raw_event_metrics({"component_id": self.id}) return StepFinishedEvent(step_name=self.display_name, raw_event={"langflow": metrics})src/lfx/src/lfx/graph/graph/base.py (1)
2306-2316: Redundanthasattrchecks and unusedresultparameter.
- The
hasattr(self, "raw_event_metrics")checks are unnecessary since the method is defined in this class.- The
resultparameter inafter_callback_eventis received but never used -RunFinishedEventis created withresult=None. If the result should be included in the event, update accordingly.- The unused
*args, **kwargsare part of the callback protocol contract, so the ARG002 warnings can be suppressed with# noqa: ARG002.- def before_callback_event(self, *args, **kwargs): - metrics = {} - if hasattr(self, "raw_event_metrics"): - metrics = self.raw_event_metrics({"total_components": len(self.vertices)}) + def before_callback_event(self, *args, **kwargs): # noqa: ARG002 + metrics = self.raw_event_metrics({"total_components": len(self.vertices)}) return RunStartedEvent(run_id=self._run_id, thread_id=self.flow_id, raw_event=metrics) - def after_callback_event(self, result: Any = None, *args, **kwargs): - metrics = {} - if hasattr(self, "raw_event_metrics"): - metrics = self.raw_event_metrics({"total_components": len(self.vertices)}) - return RunFinishedEvent(run_id=self._run_id, thread_id=self.flow_id, result=None, raw_event=metrics) + def after_callback_event(self, result: Any = None, *args, **kwargs): # noqa: ARG002 + metrics = self.raw_event_metrics({"total_components": len(self.vertices)}) + return RunFinishedEvent(run_id=self._run_id, thread_id=self.flow_id, result=result, raw_event=metrics)pyproject.toml (1)
141-142: Dependency addition looks good.The
ag-ui-protocol>=0.1.10is correctly added and uv.lock is updated. Version 0.1.10 is the latest release (Nov 2025), so the constraint is currently appropriate. If future patch versions become available, consider tightening to>=0.1.10,<0.2.0to minimize the risk of unexpected changes.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
pyproject.toml(1 hunks)src/lfx/pyproject.toml(1 hunks)src/lfx/src/lfx/events/observability/lifecycle_events.py(1 hunks)src/lfx/src/lfx/graph/graph/base.py(4 hunks)src/lfx/src/lfx/graph/vertex/base.py(5 hunks)src/lfx/tests/unit/events/observability/test_lifecycle_events.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{pyproject.toml,uv.lock}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Use
uv(>=0.4) for Python dependency management in backend development
Files:
pyproject.toml
**/test_*.py
📄 CodeRabbit inference engine (Custom checks)
**/test_*.py: Review test files for excessive use of mocks that may indicate poor test design - check if tests have too many mock objects that obscure what's actually being tested
Warn when mocks are used instead of testing real behavior and interactions, and suggest using real objects or test doubles when mocks become excessive
Ensure mocks are used appropriately for external dependencies only, not for core logic
Backend test files should follow the naming convention test_*.py with proper pytest structure
Test files should have descriptive test function names that explain what is being tested
Tests should be organized logically with proper setup and teardown
Consider including edge cases and error conditions for comprehensive test coverage
Verify tests cover both positive and negative scenarios where appropriate
For async functions in backend tests, ensure proper async testing patterns are used with pytest
For API endpoints, verify both success and error response testing
Files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
🧠 Learnings (9)
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Test both sync and async code paths, mock external dependencies appropriately, test error handling and edge cases, validate input/output behavior, and test component initialization and configuration
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Use `pytest.mark.asyncio` decorator for async component tests and ensure async methods are properly awaited
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-12-03T18:17:26.525Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-12-03T18:17:26.525Z
Learning: Applies to **/test_*.py : For async functions in backend tests, ensure proper async testing patterns are used with pytest
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Be aware of ContextVar propagation in async tests; test both direct event loop execution and `asyncio.to_thread` scenarios; ensure proper context isolation between test cases
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Use `monkeypatch` fixture to mock internal functions for testing error handling scenarios; validate error status codes and error message content in responses
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-12-03T18:17:26.525Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-12-03T18:17:26.525Z
Learning: Applies to **/test_*.py : Ensure mocks are used appropriately for external dependencies only, not for core logic
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/frontend/**/*.{test,spec}.{ts,tsx,js,jsx} : Use `pytest.mark.asyncio` decorator for async frontend tests; structure tests to verify component behavior, state updates, and proper cleanup
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Test background tasks using `asyncio.create_task()` and verify completion with `asyncio.wait_for()` with appropriate timeout constraints
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Use async fixtures with proper cleanup using try/finally blocks to ensure resources are properly released after tests complete
Applied to files:
src/lfx/tests/unit/events/observability/test_lifecycle_events.py
🧬 Code graph analysis (3)
src/lfx/tests/unit/events/observability/test_lifecycle_events.py (1)
src/lfx/src/lfx/events/observability/lifecycle_events.py (1)
observable(11-101)
src/lfx/src/lfx/graph/vertex/base.py (2)
src/lfx/src/lfx/events/observability/lifecycle_events.py (1)
observable(11-101)src/lfx/src/lfx/graph/graph/base.py (3)
raw_event_metrics(2301-2304)before_callback_event(2306-2310)after_callback_event(2312-2316)
src/lfx/src/lfx/graph/graph/base.py (3)
src/lfx/src/lfx/events/observability/lifecycle_events.py (1)
observable(11-101)src/lfx/src/lfx/graph/vertex/base.py (3)
raw_event_metrics(834-843)before_callback_event(845-853)after_callback_event(855-862)src/lfx/tests/unit/events/observability/test_lifecycle_events.py (2)
before_callback_event(75-76)after_callback_event(78-79)
🪛 GitHub Actions: Ruff Style Check
src/lfx/src/lfx/events/observability/lifecycle_events.py
[error] 76-76: RUF013 PEP 484 prohibits implicit Optional.
🪛 GitHub Check: Ruff Style Check (3.13)
src/lfx/src/lfx/events/observability/lifecycle_events.py
[failure] 96-96: Ruff (BLE001)
src/lfx/src/lfx/events/observability/lifecycle_events.py:96:16: BLE001 Do not catch blind exception: Exception
[failure] 76-76: Ruff (RUF013)
src/lfx/src/lfx/events/observability/lifecycle_events.py:76:41: RUF013 PEP 484 prohibits implicit Optional
src/lfx/src/lfx/graph/vertex/base.py
[failure] 835-840: Ruff (D205)
src/lfx/src/lfx/graph/vertex/base.py:835:9: D205 1 blank line required between summary line and description
[failure] 834-834: Ruff (B006)
src/lfx/src/lfx/graph/vertex/base.py:834:57: B006 Do not use mutable data structures for argument defaults
src/lfx/src/lfx/graph/graph/base.py
[failure] 2312-2312: Ruff (ARG002)
src/lfx/src/lfx/graph/graph/base.py:2312:65: ARG002 Unused method argument: kwargs
[failure] 2312-2312: Ruff (ARG002)
src/lfx/src/lfx/graph/graph/base.py:2312:57: ARG002 Unused method argument: args
[failure] 2312-2312: Ruff (ARG002)
src/lfx/src/lfx/graph/graph/base.py:2312:36: ARG002 Unused method argument: result
[failure] 2306-2306: Ruff (ARG002)
src/lfx/src/lfx/graph/graph/base.py:2306:46: ARG002 Unused method argument: kwargs
[failure] 2306-2306: Ruff (ARG002)
src/lfx/src/lfx/graph/graph/base.py:2306:38: ARG002 Unused method argument: args
[failure] 2301-2301: Ruff (B006)
src/lfx/src/lfx/graph/graph/base.py:2301:57: B006 Do not use mutable data structures for argument defaults
⏰ 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). (26)
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 13/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 12/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 11/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/13
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/13
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- 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: Run Backend Tests / LFX Tests - Python 3.10
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Update Component Index
🔇 Additional comments (10)
src/lfx/pyproject.toml (1)
44-44: LGTM!The dependency addition is consistent with the root
pyproject.tomland appropriate for the lifecycle events feature in the lfx package.src/lfx/tests/unit/events/observability/test_lifecycle_events.py (3)
147-168: Test correctly validates exception swallowing behavior, but consider adding a test for re-raised exceptions.The test verifies the current behavior where exceptions are swallowed. If the implementation changes to re-raise exceptions (as suggested in the decorator review), this test will need updating.
72-100: Good test class structure with clear separation of concerns.The test classes appropriately demonstrate observable usage with and without callback implementations. The mocking strategy correctly targets external dependencies rather than core logic, per coding guidelines.
31-66: Well-structured fixtures with proper cleanup.The fixtures follow best practices with context manager patching and autouse reset for test isolation.
src/lfx/src/lfx/graph/vertex/base.py (3)
11-13: LGTM on imports.The new imports for AGUI events and the observable decorator are appropriate for the lifecycle event integration.
117-117: LGTM on new raw_metrics field.The field provides a clean way to attach custom metrics to vertex events.
389-389: LGTM on observable decorator usage.The decorator is correctly applied to the
_buildmethod to enable lifecycle event emission.src/lfx/src/lfx/graph/graph/base.py (3)
18-20: LGTM on imports.The new imports for AGUI events and the observable decorator are appropriate for the lifecycle event integration.
734-734: Noted: Temporary decorator usage for review purposes.Acknowledging the author's comment that this decorator application is for review understanding and may be removed before production.
1424-1425: Fallback cache function change looks correct.The fallback no-op
set_cache_funcis appropriately defined for when the chat service is unavailable.
ac80720 to
1c1361f
Compare
|
@coderabbitai generate docstrings |
✅ Actions performedInitiated docstring generation; will generate only if new commits exist. |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @dkaushik94. * #10780 (comment) The following files were modified: * `src/lfx/src/lfx/events/observability/lifecycle_events.py` * `src/lfx/src/lfx/graph/graph/base.py` * `src/lfx/src/lfx/graph/vertex/base.py` * `src/lfx/tests/unit/events/observability/test_lifecycle_events.py`
d46a140 to
590ed7d
Compare
|
@coderabbitai generate docstrings |
✅ Actions performedInitiated docstring generation; will generate only if new commits exist. |
Docstrings generation was requested by @dkaushik94. * #10780 (comment) The following files were modified: * `src/lfx/src/lfx/events/observability/lifecycle_events.py` * `src/lfx/src/lfx/graph/graph/base.py` * `src/lfx/src/lfx/graph/vertex/base.py` * `src/lfx/tests/unit/events/observability/test_lifecycle_events.py`
5b8031e to
7d1235a
Compare
a7c1d66 to
3258db0
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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
🧹 Nitpick comments (1)
pyproject.toml (1)
143-143: Consider adding an upper bound for this pre-1.0 dependency.The version constraint
>=0.1.10is permissive for a pre-1.0 package. As a best practice, add an upper bound to protect against potential breaking changes in minor version bumps (e.g., 0.1.x → 0.2.x). This pattern is already used throughout the codebase for similar dependencies (e.g.,astrapy>=2.1.0,<3.0.0,google-search-results>=2.4.1,<3.0.0). The constraint is already consistent withsrc/lfx/pyproject.toml.Suggested version constraint
- "ag-ui-protocol>=0.1.10", + "ag-ui-protocol>=0.1.10,<0.2.0",
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pyproject.toml
🧰 Additional context used
📓 Path-based instructions (1)
{pyproject.toml,uv.lock}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Use
uv(>=0.4) for Python dependency management in backend development
Files:
pyproject.toml
⏰ 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). (15)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Frontend Unit Tests / Frontend Jest Unit Tests
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
- GitHub Check: Test Starter Templates
🔇 Additional comments (1)
pyproject.toml (1)
142-142: LGTM: Formatting adjustment for new dependency.The trailing comma addition is a clean formatting change to accommodate the new
ag-ui-protocoldependency.
6ab731b to
fb58273
Compare
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.
LGTM from an implmentation pointof view but I want to make sure our names are more meaningful.
do we want #11111 merged first?
fb58273 to
9a6abed
Compare
3687a98 to
5bbe83b
Compare
Jkavia
left a comment
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.
looks good, these changes are not called anywhere yet so safe to merge for now.
439e898 to
6deba06
Compare
Added AGUI events to vertices and the graph. Created Decorator to add observability to Langflow workflows. TODO: Unit tests, feature gating to nullify impact in current production code paths. Added unit tests for lifecycle_events. Refraining from using event_manager for now since this capability is goig to stay dormant until APIs are ready for streaming. Added unit tests for before_callback_event and after_callback_event in graph and vertex classes.
6deba06 to
33e7af1
Compare
Adding support for lifecycle events for components and workflows. This will be a part of the new Developer APIs for Langflow and the APIs will be AG-UI compliant.
AG UI event reference
Design pattern introduced:
@observabledecorator introduced to leverage event generation for build methods of any component class.before_callback_eventandafter_callback_eventin order to become observable and should generate the suitable protocol events. In case users don't define these methods, the default behaviour is silent failure to generate the payloads.raw_eventfield, without violating AGUI compliance.Summary by CodeRabbit
New Features
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.
Testing Instructions:
Try this cURL command and add print statements in
before_callbackandafter_callbackmethods to print payloads in the console primed for publishing to queues later. Verify AGUI compliance.curl --request POST --url 'http://localhost:3000/api/v1/run/<YOUR FLOW ID here>?stream=true' --header 'Content-Type: application/json' --data '{"output_type": "chat","input_type": "chat","input_value": "What do you think about online betting platforms?","session_id": ""}'