-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add webhook endpoint, and other fixes (#1766)
* Update FastAPI app configuration in main.py * Add webhook endpoint * Add Observer model and related changes to database models * Update refresh button text in ParameterComponent * Update database models and main.py, and add webhook endpoint and utils for flow model * Add WebhookComponent to langflow data components * Update webhook component names in flow data and remove unused code in edge/base.py and graph/base.py * 🐛 (endpoints.py): fix an issue where the user_id was not being correctly assigned based on the api_key_user or flow object * 📝 (endpoints.py): Update documentation for the webhook_run_flow endpoint to provide clearer information on its purpose, arguments, and return value. Remove outdated request JSON structure and example request sections. Add information on the arguments and exceptions raised for better clarity. * chore: Remove unnecessary trailing commas in code files * feat: Add yield statement to get_lifespan function * feat: Update webhook columns revision ID * Refactor import statements for OpenAI conversational agent * refactor(constants.ts): remove unused tabsArray function and update function name to createTabsArray for clarity feat(constants.ts): add support for including webhook code in tabs array based on flow webhook property feat(index.tsx): update function calls to use new createTabsArray function and include webhook code in tabs array based on flow webhook property refactor(utils.ts): remove trailing commas in function parameters to improve code consistency and readability feat(utils.ts): add support for including webhook cURL code and tweaks code in tabs array creation for better code organization and presentation * chore: Update folder_id parameter type to str in API endpoints * feat: Handle invalid JSON payload in WebhookComponent The code changes in `Webhook.py` modify the `build` method of the `WebhookComponent` class. If an invalid JSON payload is provided, instead of raising a `ValueError`, the code now handles the exception by creating a default payload with the provided data. The commit also includes a message that describes the invalid JSON payload for better error tracking. Note: This commit message follows the convention used in the recent user commits. * refactor: Remove unnecessary code in main.py * refactor: Update Alembic revision IDs for webhook columns The Alembic revision IDs for adding webhook columns have been updated to reflect the latest changes. This ensures consistency and proper tracking of the database schema modifications. Note: The commit message has been generated based on the provided code changes and recent commits. * 🐛 (endpoints.py): Fix handling of flow_id_or_name variable to correctly identify flow ID or endpoint name for running a flow. Improve error handling for invalid UUID strings and flow not found scenarios. * refactor: Handle invalid JSON payload in WebhookComponent The code changes in `Webhook.py` modify the `build` method of the `WebhookComponent` class. If an invalid JSON payload is provided, instead of raising a `ValueError`, the code now handles the exception by creating a default payload with the provided data. * refactor: Update get_flow_by_id function to handle None flow_id parameter The get_flow_by_id function in utils.py has been updated to handle the case where the flow_id parameter is None. Previously, the function would raise an exception if flow_id was not provided. Now, if flow_id is None, the function returns None instead of querying the database. This change improves the robustness of the function and allows for more flexible usage. Note: The commit message has been generated based on the provided code changes and recent commits. * 📝 (endpoints.py): Add import statement for get_flow_by_id_or_endpoint_name function 📝 (flow.py): Add get_flow_by_id_or_endpoint_name function to retrieve a Flow object by ID or endpoint name * refactor: Update get_flow_by_id_or_endpoint_name function to handle None flow_id parameter * 🐛 (flow.py): replace ValueError with HTTPException to return a 404 status code when flow identifier is not found * refactor: Update error message for flow identifier not found The code changes in `test_endpoints.py` update the error message when a flow identifier is not found. Previously, the error message referenced the flow ID directly, but now it uses the more generic term "Flow identifier" to account for cases where the identifier could be an endpoint name. This change improves the clarity and flexibility of the error message. Note: This commit message has been generated based on the provided code changes and recent commits. * 🔧 (endpoints.py): remove unnecessary flow_id_or_name parameter from the simple_run_flow function call to improve code readability and maintainability
- Loading branch information
1 parent
1f8d0eb
commit 5e2f4b8
Showing
41 changed files
with
467 additions
and
294 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/backend/base/langflow/alembic/versions/631faacf5da2_add_webhook_columns.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Add webhook columns | ||
Revision ID: 631faacf5da2 | ||
Revises: 1c79524817ed | ||
Create Date: 2024-04-22 15:14:43.454784 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.engine.reflection import Inspector | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "631faacf5da2" | ||
down_revision: Union[str, None] = "1c79524817ed" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
inspector = Inspector.from_engine(conn) # type: ignore | ||
table_names = inspector.get_table_names() | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
column_names = [column["name"] for column in inspector.get_columns("flow")] | ||
with op.batch_alter_table("flow", schema=None) as batch_op: | ||
if "flow" in table_names and "webhook" not in column_names: | ||
batch_op.add_column(sa.Column("webhook", sa.Boolean(), nullable=True)) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
conn = op.get_bind() | ||
inspector = Inspector.from_engine(conn) # type: ignore | ||
table_names = inspector.get_table_names() | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
column_names = [column["name"] for column in inspector.get_columns("flow")] | ||
with op.batch_alter_table("flow", schema=None) as batch_op: | ||
if "flow" in table_names and "webhook" in column_names: | ||
batch_op.drop_column("webhook") | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.