Commit graph

8,701 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
5e2f4b8f83
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
2024-05-31 11:02:06 -07:00
ogabrielluiz
1f8d0eb1c0 chore: Update package versions in pyproject.toml files
The package versions in the pyproject.toml files for "langflow" and "langflow-base" have been updated. The version of "langflow" was changed from 1.0.0a42 to 1.0.0a43, and the version of "langflow-base" was changed from 0.0.53 to 0.0.54. This update ensures that the latest versions of the packages are being used in the codebase.

Note: The commit message has been generated based on the provided code changes and recent commits.
2024-05-31 14:35:07 -03:00
cristhianzl
57c38acace 💡 (schemas.py): add newline at end of file to follow PEP 8 guidelines 2024-05-31 13:43:41 -03:00
cristhianzl
602ebf7b15 (monitor.py): add MessageIds schema for structured message deletion
♻️ (monitor.py): change delete_messages endpoint to POST for better semantics
♻️ (monitor.py): update delete_messages to use MessageIds schema
 (schemas.py): add MessageIds schema for structured message deletion
🐛 (service.py): fix SQL query in delete_messages to use correct column name
 (index.tsx): add toTitleCase utility to format column headers
 (API/index.ts): add deleteMessagesFn to handle message deletion via API
 (headerMessages): add HeaderMessagesComponent for message management UI
 (use-messages-table): add useMessagesTable hook to fetch and manage messages
 (use-remove-messages): add useRemoveMessages hook to handle message deletion

♻️ (messagesPage): refactor messages page to use new messages store
 (messagesStore): create zustand store for managing messages state
 (types): add types for messages and zustand messages store
2024-05-31 13:43:28 -03:00
ogabrielluiz
a3a09fed3b refactor: Fix serialize_datetime function in model.py 2024-05-31 11:41:17 -03:00
ogabrielluiz
031b82c665 refactor: Update serialize_datetime function in model.py 2024-05-31 11:25:36 -03:00
ogabrielluiz
82404d1ed9 refactor: Update serialize_datetime function in model.py
The serialize_datetime function in model.py has been updated to handle the "updated_at" and "created_at" fields. The function now converts datetime values to ISO 8601 format with timezone information. This change ensures consistent serialization of datetime values in the codebase.

Note: The commit message has been generated based on the provided code changes and recent commits.
2024-05-31 11:22:40 -03:00
ogabrielluiz
f79289f966 feat: Add API endpoints for managing messages
This commit adds new API endpoints for managing messages. It includes the ability to delete messages by their IDs, update a specific message, and delete all messages associated with a session. These changes are implemented in the `monitor.py`, `schema.py`, and `service.py` files.
2024-05-31 09:38:05 -03:00
Lucas Oliveira
a119c3777a Changed empty component to open New Project modal 2024-05-30 20:15:48 -03:00
Lucas Oliveira
cd9429ac9d Changed message of terminal as Run Langflow. 2024-05-30 20:07:33 -03:00
Lucas Oliveira
f5462b1f8d Made node description editable by clicking once and changed cursor type 2024-05-30 19:49:56 -03:00
Lucas Oliveira
b1a5fb5de6 Removed Pencil of name of node 2024-05-30 19:48:36 -03:00
Gabriel Luiz Freitas Almeida
67207eb171
Fix endpoint URL interpolation issue in getCurlCode (#2026)
* chore: Update getCurlCode to fix endpoint URL interpolation issue
2024-05-30 13:18:56 -07:00
igorrCarvalho
d091bf9611 Fix: formatFileName function cant truncate when numberToTruncate are bigger than name length 2024-05-30 17:14:39 -03:00
igorrCarvalho
a88193aeee Refactor: Create function to get style classes 2024-05-30 17:09:26 -03:00
igorrCarvalho
7ea7d9a407 Refactor: Create specific folder for handleDownload function 2024-05-30 17:05:20 -03:00
igorrCarvalho
b02b4ee4eb Refactor: Create wrap for download button 2024-05-30 17:00:39 -03:00
igorrCarvalho
7e09131800 Feat: Implement download file on chat function 2024-05-30 16:52:50 -03:00
igorrCarvalho
e56ce2f2b4 Feat: enhance sending files UI 2024-05-30 16:38:35 -03:00
Gabriel Luiz Freitas Almeida
eb68558905
Update utils.py to handle SecretStr field type as str with password and load_from_db attributes (#2005)
* chore: Update utils.py to handle SecretStr field type as str with password and load_from_db attributes

* Update utils.py to handle SecretStr field type as str with password and load_from_db attributes
2024-05-30 12:02:54 -07:00
Gabriel Luiz Freitas Almeida
4c113d5ac0
Add Upstash Vector Store support (#2004)
* docs(migration): add UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN to the list of default environment variables
pyproject.toml: add upstash-vector package as a dependency with version 0.4.0
src/backend/base/langflow/components/vectorsearch/UpstashSearch.py: create UpstashSearchComponent for implementing a Vector Store using Upstash
src/backend/base/langflow/components/vectorstores/Upstash.py: create UpstashVectorStoreComponent for implementing a Vector Store using Upstash
src/backend/base/langflow/services/settings/constants.py: add UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN to the list of variables to get from the environment

*  (UpstashSearch.py): Add support for 'number_of_results' and 'text_key' parameters in UpstashSearchComponent to enhance search functionality
♻️ (Upstash.py): Refactor UpstashVectorStoreComponent to include 'text_key' parameter for consistency and improved functionality

* ♻️ (Upstash.py): refactor UpstashVectorStoreComponent to improve code readability and maintainability by restructuring the instantiation of UpstashVectorStore instances based on conditions and adding support for adding documents directly to the instance.

* feat: Update langchain-core, langchainhub, langsmith, and requests dependencies to latest versions
2024-05-30 12:02:40 -07:00
igorrCarvalho
830d5a6ca8 Feat: add diferent loading for file and image 2024-05-30 15:11:28 -03:00
cristhianzl
5bdf80da65 (RecordsOutputComponent): add support for dynamic column modes and rows
♻️ (TableComponent): remove unused useCallback import and add autoHeight
 (convert-to-table-rows): add helper function to convert objects to table rows
♻️ (SwitchOutputView): refactor to use new convertToTableRows helper and improve type checks
♻️ (OutputModal): change modal size to medium-log for better visualization
♻️ (IOFieldView): refactor to use new rows and columnMode props in RecordsOutputComponent

♻️ (baseModal): remove unnecessary comma in ReactElement type array
 (baseModal): add new size option "medium-log" for modal component
♻️ (textOutputView): simplify TextOutputView component props
♻️ (api): add params and messages to VertexBuildTypeAPI
♻️ (api): add type to logs in VertexDataTypeAPI
♻️ (api): make artifacts optional in VertexDataTypeAPI
♻️ (chat): make artifacts optional in FlowPoolObjectType
 (components): add playgroundDisabled to InputListComponentType
♻️ (components): fix formatting in various component types

♻️ (utils.ts): remove unused imports to clean up the code
 (utils.ts): add 'all' mode to extractColumnsFromRows for more flexibility
2024-05-30 14:34:32 -03:00
Nicolò Boschi
7abfb0b232
feat: read flows from local directory at startup (#1989)
* feat: read flows from local directory at startup

* cleanup

* add check

* fix

* fix

* fix by endpoint name

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-05-30 08:58:57 -07:00
Nicolò Boschi
44121515ed
fix: create superuser at startup to avoid concurrency issues (#2019)
* fix: create superuser at startup to avoid concurrency issues

* fix import

* fix mypy

* fix mypy
2024-05-30 08:54:48 -07:00
Gabriel Luiz Freitas Almeida
94e8bf1e2b
Add support for running flows by endpoint name (#2012)
* feat: Add support for running flows by endpoint name

This commit modifies the `simplified_run_flow` endpoint in `endpoints.py` to allow running flows using the endpoint name instead of the flow ID. It introduces a new route parameter `flow_id_or_name` which can accept either a UUID or a string representing the endpoint name. The code first attempts to parse the parameter as a UUID, and if that fails, it queries the database to find a flow with the matching endpoint name. This change improves the usability of the API by providing an alternative way to identify flows for execution.

* feat: Add endpoint_name field to FlowType

This commit adds the `endpoint_name` field to the `FlowType` interface in the `index.ts` file. The `endpoint_name` field is an optional string that represents the name of the endpoint associated with the flow. This change allows for more flexibility in identifying flows by endpoint name instead of just the flow ID. It improves the usability of the codebase by providing an alternative way to reference flows.

* 🐛 (endpoints.py): change type of flow_id_or_name parameter from Union[str, UUID] to str to simplify the API and improve readability

* feat: Add migration utility functions for table, column, foreign key, and constraint existence checks

This commit adds utility functions to the `migration.py` module in the `langflow.utils` package. These functions provide convenient ways to check the existence of tables, columns, foreign keys, and constraints in a database using SQLAlchemy. The functions `table_exists`, `column_exists`, `foreign_key_exists`, and `constraint_exists` take the table name, column name, foreign key name, and constraint name respectively, along with the SQLAlchemy engine or connection object. They use the `Inspector` class from `sqlalchemy.engine.reflection` to retrieve the necessary information and return a boolean value indicating whether the specified element exists in the database. These utility functions improve the readability and maintainability of the codebase by encapsulating the common existence checks in a reusable and modular way.

* feat: Add unique constraints for per-user folders and flows

This commit adds unique constraints for per-user folders and flows in the database. It introduces the `unique_folder_name` constraint for the `folder` table, ensuring that each user can have only one folder with a specific name. Similarly, it adds the `unique_flow_endpoint_name` and `unique_flow_name` constraints for the `flow` table, enforcing uniqueness of endpoint names and flow names per user. These constraints improve data integrity and prevent duplicate entries in the database, providing a more robust and reliable system.

* feat: Add poetry installation and caching steps to GitHub Actions workflow

This commit updates the GitHub Actions workflow file `action.yml` to include additional steps for installing poetry and caching its dependencies. The `run` step now installs poetry using the specified version and ensures that the poetry binary is available in the PATH. Additionally, the workflow now includes a step to restore pip and poetry cached dependencies using the `actions/cache` action. These changes improve the workflow by providing a more efficient and reliable way to manage poetry dependencies and caching.

* refactor: Improve error handling in update_flow function

This commit improves the error handling in the `update_flow` function in `flows.py`. It adds a new `elif` condition to check if the exception is an instance of `HTTPException` and re-raises it. This ensures that any `HTTPException` raised during the update process is properly handled and returned as a response. Additionally, it removes the unnecessary `else` block and simplifies the code logic. This refactor enhances the reliability and maintainability of the `update_flow` function.
2024-05-30 07:46:28 -07:00
cristhianzl
4c927517b2 Merge branch 'cz/inspection' of https://github.com/langflow-ai/langflow into cz/inspection 2024-05-30 11:00:10 -03:00
cristhianzl
395fbad81a (index.tsx): add value prop to TextOutputView component to display text output value
🐛 (index.tsx): fix typo in TextOutputView component usage
2024-05-30 11:00:03 -03:00
Gabriel Luiz Freitas Almeida
e5986ec727
Added curl parse to API Request component and fixed dict issues (#2013)
* Refactor code to remove console.log statements

* Refactor code to remove console.log statements

* ⬆️ (pyproject.toml): upgrade uncurl dependency to version 0.0.11

* 📝 (flows.py): Add docstring to the read_flows function to provide information about its purpose, arguments, and return value
📝 (parse.py): Add comments and docstrings to the parse_context function to explain its purpose and how it works
📝 (APIRequest.py): Add a new method update_build_config to handle parsing of curl commands and update build configuration based on the parsed context

* refactor: Improve value change detection logic in DictComponent

* refactor: Improve value change detection logic in DictAreaModal

* refactor: Update APIRequest to handle parsing of curl commands and update build configuration

This commit updates the APIRequest class in APIRequest.py to handle parsing of curl commands and update the build configuration based on the parsed context. It introduces a new method, update_build_config, which parses the curl command using the parse_context function and updates the build configuration with the parsed information. Additionally, it handles JSON decoding errors when parsing the data field of the curl command. This improvement enhances the functionality and flexibility of the APIRequest component.

* feat: Add support for handling headers as dictionaries in APIRequest

* refactor: Parse curl commands and update build configuration in APIRequest

This commit refactors the APIRequest class in APIRequest.py to handle parsing of curl commands and update the build configuration based on the parsed context. It introduces a new method, update_build_config, which parses the curl command using the parse_context function and updates the build configuration with the parsed information. Additionally, it handles JSON decoding errors when parsing the data field of the curl command. This improvement enhances the functionality and flexibility of the APIRequest component.

*  (test_data_components.py): add new test case to parse curl command into build configuration for API requests

* 🐛 (src/backend/base/langflow/components/data/APIRequest.py): fix type hinting issue for bodies variable in APIRequest class
2024-05-30 06:50:31 -07:00
Cristhian Zanforlin Lousa
fb018eda10
Fix Application Crash with Multiple Nested Dict Components in Flow (#2011)
* ♻️ (dictComponent): improve value change detection logic
🐛 (parameterComponent): remove unnecessary console.log statement

* ♻️ (frontend): remove redundant comments and clean up code formatting

♻️ (editNodeModal): refactor to use nodeId instead of passing data directly

* ♻️ (editNodeModal): refactor to use data prop instead of nodeId for better data handling
♻️ (nodeToolbarComponent): refactor to improve code readability and consistency
2024-05-29 19:26:12 -07:00
anovazzi1
86b6672bbd refactor name props 2024-05-29 21:03:54 -03:00
anovazzi1
0ae9d8db6a chore: Refactor ParameterComponent handle button rendering
This commit refactors the rendering of the handle button in the ParameterComponent. It improves the readability and maintainability of the code by simplifying the logic and removing unnecessary ternary operators.
2024-05-29 20:36:37 -03:00
cristhianzl
6bbb3688ee merge fix 2024-05-29 20:15:29 -03:00
cristhianzl
312a959ae1 Merge branch 'cz/inspection' of https://github.com/langflow-ai/langflow into cz/inspection 2024-05-29 20:15:23 -03:00
cristhianzl
e6f466188c merge fix 2024-05-29 20:15:13 -03:00
anovazzi1
0d6547991f feat: Add OutputModal component for displaying output preview
This commit adds the OutputModal component to the ParameterComponent. The OutputModal component is responsible for displaying the output preview when the user clicks on the "Inspect Output" button. It improves the user experience by allowing them to easily view the output without leaving the current page.
2024-05-29 20:06:45 -03:00
igorrCarvalho
9c19d5cdf1 Refactor: Move util function to proper folder 2024-05-29 18:13:33 -03:00
igorrCarvalho
261d5d2af1 Refactor: Increase file preview width 2024-05-29 18:09:59 -03:00
igorrCarvalho
40eaa0903b Refactor: enhance upload file button UI and enhance File and Image preview UI 2024-05-29 17:48:38 -03:00
anovazzi1
a99d0c7eb0 refactor(tableComponent): update column definitions to include checkbox selection logic for first column
feat(API): add support for excluding specific columns in getMessagesTable function

fix(flowLogsModal): pass excludedFields parameter to getMessagesTable function

refactor(GlobalVariablesPage): remove unnecessary checkbox selection properties from column definitions

fix(messagesPage): pass excludedFields parameter to getMessagesTable function

refactor(utils): add support for excluding specific columns in extractColumnsFromRows function
2024-05-29 17:48:12 -03:00
anovazzi1
022ef7c028 feat: Add Messages page to SettingsPage
Refactor the SettingsPage component to include a new "Messages" page. This page will be accessible through the "/settings/messages" route and will display messages related to user settings. The necessary changes have been made to the index.tsx file of the SettingsPage component and the routes.tsx file.
2024-05-29 17:15:21 -03:00
italojohnny
d05e7c12f4 add new type to Log 2024-05-29 16:12:53 -03:00
italojohnny
b091c237b6 add variable to store unformatted data 2024-05-29 16:12:14 -03:00
italojohnny
c1cf8fe564 change return to dict for token cases 2024-05-29 16:01:54 -03:00
cristhianzl
43ba306b34 (chatInput): add useHandleFileChange hook to handle file input changes 2024-05-29 16:01:28 -03:00
cristhianzl
0d17211177 (textAreaWrapper): refactor TextAreaWrapper to improve readability and maintainability
 (uploadFileButton): add UploadFileButton component for file uploads in chat input
2024-05-29 16:01:13 -03:00
cristhianzl
89943b2c3e (chatInput): add file upload functionality with drag-and-drop support 2024-05-29 16:00:57 -03:00
cristhianzl
a1d1ad22ce (chatInput): add helper function to generate class names for file preview
♻️ (chatInput): refactor file preview class name logic to use helper function
2024-05-29 12:39:44 -03:00
cristhianzl
826f9656d9 (chatInput): add focus state handling and dynamic styling for text area
♻️ (filePreviewChat): refactor file preview component for better UX and code clarity
2024-05-29 12:36:18 -03:00
igorrCarvalho
0eb6f6b212 Merge dev 2024-05-29 12:35:09 -03:00