Commit Graph

14131 Commits

Author SHA1 Message Date
80db2b92d2 fix: suppress LangChainDeprecationWarning messages (#4319)
* fix: suppress LangChainDeprecationWarning messages

* fix: suppress LangChainDeprecationWarning messages
2024-10-30 23:52:46 +00:00
d38e79bde6 docs: Update CLI page and add new environment variables page (#4311)
* Update drafts

* Sync CLI and env variables

* More drafts

* Converge CLI pages

* Formalize env variables page

* Remove Required column

* Remove some variables

* More tweaks to env

* Small changes to CLI config

* Add anchor links to env variables and cli options

* Add cross references between cli and env options

* Some qol tweaks to env variable page

* Remove unused env variables

* Fix double period

* Fix typo

---------

Co-authored-by: Ítalo Johnny <italojohnnydosanjos@gmail.com>
2024-10-30 12:52:17 +00:00
6ca864931d ci: add pytest failure annotations (#4324)
* Add pytest-github-actions-annotate-failures to dependencies in pyproject.toml

* feat: add --exclude-warning-annotations option to pytest commands in Makefile

* feat: add pytest-github-actions-annotate-failures to dev dependencies in pyproject.toml and uv.lock

* Add PYTEST_RUN_PATH environment variable to GitHub Actions workflow

* Remove '--exclude-warning-annotations' option from pytest commands in Makefile
2024-10-30 09:29:24 -03:00
0fd3d93b1d chore: update devcontainer configuration and Dockerfile (#4298)
* Add Dockerfile for devcontainer with Rust and UV setup

* Update devcontainer configuration to use Dockerfile and enhance features

- Switch from using a pre-built image to building from a Dockerfile.
- Replace Poetry feature with Hadolint for linting Dockerfiles.
- Add new VSCode extensions: Ruff, Autodocstring, Indent Rainbow, and Hadolint.
- Set default terminal profile to zsh in VSCode settings.
- Add a postStartCommand to initialize the environment.
- Change remote user to 'vscode'.

* Update test command in VSCode tasks to 'make unit_tests'

* chore: remove unnecessary comment

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-10-30 11:11:16 +00:00
6c3c32851b refactor: update inputs in ToolCallingAgentComponent and add astream_events setup (#4240)
* Refactor `ToolCallingAgentComponent` to enhance input handling and update descriptions

* Add async event processing for agent execution in agent.py

- Introduced `process_agent_events` method to handle asynchronous event processing for agent execution.
- Added individual async handlers for different event types: `handle_chain_start`, `handle_chain_end`, `handle_chat_model_stream`, `handle_tool_start`, and `handle_tool_end`.
- Updated agent execution to use `astream_events` for improved event handling.
- Enhanced logging for better traceability of agent and tool execution events.

* Refactor agent component to use MessageTextInput and improve prompt handling

* Refactor tool calling agent component: update prompt handling and input naming conventions

* Remove input key validation from create_agent_runnable method in tool_calling.py

* Enhance agent logging by removing redundant checks and adding scratchpad logging

* Refactor `process_agent_events` to a standalone function with enhanced logging capabilities

* Refactor log callback messages to improve emoji placement consistency

* Use `jsonable_encoder` to encode agent scratchpad messages before logging

* style: simplify double string on the same line

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-10-29 21:25:58 +00:00
b39ee0ae2d refactor: update OpenTelemetry initialization to avoid multiple calls (#4306)
* Ensure single initialization of OpenTelemetry and optimize meter provider setup

* Simplify condition by removing redundant class attribute
2024-10-29 15:04:22 +00:00
ccba14bec4 feat: Allow variables to be defined outside a Component (#4316)
* feat: Allow variables to be defined outside a Component

Fixes #4315

Modify `prepare_global_scope` function in `src/backend/base/langflow/utils/validate.py` to evaluate classes, functions, and variables defined outside the Component's class.

* **Function Changes:**
  - Add evaluation of external classes using `ast.ClassDef`.
  - Add evaluation of external functions using `ast.FunctionDef`.
  - Add evaluation of external variables using `ast.Assign`.

* **Unit Tests:**
  - Add tests in `src/backend/tests/unit/test_validate_code.py` to verify the evaluation of external classes, functions, and variables.
  - Include tests for multiple external classes and external variables and functions.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/langflow-ai/langflow/issues/4315?shareId=XXXX-XXXX-XXXX-XXXX).

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-29 06:45:38 -07:00
fb0084d478 feat: Add alembic log path as env var change (#4272)
* Added alembic log path as env var change

* [autofix.ci] apply automated fixes

* Improved platform independence of path check

* fix: arg-type mypy error

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ítalo Johnny <italojohnnydosanjos@gmail.com>
2024-10-29 10:28:41 +00:00
924e02f46d fix: make asyncio cancellation handling compatible with 3.10 (#4303)
Fix asyncio cancellation handling for Python 3.11 compatibility

Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
2024-10-28 21:56:30 +00:00
882f20d64f fix: make JSON serialization work with Callable objects (#4302)
Enhance JSON serialization with custom encoder for Callable objects
2024-10-28 20:45:29 +00:00
fadb20115d test: add unit tests for routes (#4249) 2024-10-28 20:06:05 +00:00
a88fd9bbb0 feat: add new .env variable "LANGFLOW_FEATURE_MVP_COMPONENTS" to show/hide integration sidebar components (#4270)
*  (authContext.tsx): Add functionality to fetch global variables on authentication
🔧 (api.tsx): Replace universal-cookie import with react-cookie for consistency
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency
🔧 (use-get-global-variables.ts): Add check to only fetch global variables if user is authenticated
 (use-get-mutation-global-variables.ts): Add mutation function to fetch and update global variables
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency

* 📝 (endpoints.py): add feature_flags field to ConfigResponse schema
📝 (endpoints.py): modify get_config function to include feature_flags in the response
📝 (feature_flags.py): add mvp_components field to FeatureFlags settings
📝 (schemas.py): add feature_flags field to ConfigResponse schema

*  (use-get-config.ts): Add feature_flags field to ConfigResponse interface to support feature flags in the application
🔧 (utilityStore.ts): Add featureFlags field and setFeatureFlags function to utilityStore to manage feature flags in the application
💡 (extraSidebarComponent/index.tsx): Use featureFlags from utilityStore to conditionally render components based on feature flags in ExtraSidebar component

* ♻️ (frontend/package-lock.json): remove extraneous flag from is-unicode-supported package to clean up unnecessary information

*  (integration-side-bar.spec.ts): Add integration tests to ensure correct visibility of integrations in the sidebar based on the value of mvp_components.

*  (integration-side-bar.spec.ts): update integration-side-bar tests to use feature_flags object for mvp_components flag for better readability and maintainability.

*  (integration-side-bar.spec.ts): add a 4-second delay before making the API call to improve test reliability

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/api/v1/schemas.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/api/v1/endpoints.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* formata

* [autofix.ci] apply automated fixes

*  (extraSidebarComponent/index.tsx): update featureFlags property access to use optional chaining for better error handling
📝 (stop-building.spec.ts): add ua-parser-js import to get user agent information and update control key based on user's operating system for better user experience. Also, refactor code to improve readability and add comments for better understanding.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-10-28 19:36:52 +00:00
d53107ce11 fix: Make logger file sink non-blocking when used with asyncio (#4301)
The Loguru FileSink is blocking so it is bad to use it in the event loop.
Use instead an AsyncSink wrapping the FileSink to delegate the log writing to the default thread pool.
NB: when the AsyncFileSink is used, logs produced outside of the event loop are not written to the file.
2024-10-28 17:38:40 +01:00
4aa7aed0a9 fix: input value error when tweaks are active (#4288)
fix: remove input value when tweaks are active to prevent error on api call
2024-10-28 15:49:43 +00:00
c8bdcf36b0 fix: Fix async usage in app startup (#4285)
Fix async usage in app startup
2024-10-27 15:00:28 +00:00
eccdb3a566 fix: Remove sync Graph.run() (#4287)
Remove sync Graph.run()
2024-10-27 14:44:43 +00:00
d567b8518c fix: Fix issues with use of async (#4296)
* Fix issues with use of async

* Update src/backend/base/langflow/custom/custom_component/component.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-10-27 07:30:33 -07:00
73b5cc0098 refactor: remove unnecessary 'client' fixture and update test durations (#4283)
* Remove unnecessary use of 'client' fixture in test_superuser

* Remove unnecessary use of 'usefixtures' decorator in test files

* Update test fixtures to improve test duration tracking

* Remove unnecessary 'client' fixture from test cases
2024-10-27 14:16:45 +00:00
1ef1fcb515 fix: Fix Astra DB collection indexing params (#4255)
Fix Astra DB collection indexing params
2024-10-27 01:55:30 +00:00
a0c42d148d fix: Add missing inputs for HuggingFace model component and include pytest (#4291)
* fix: Add missing inputs for HuggingFace model component and include pytest

- Added missing inputs to the HuggingFace model component.
- Implemented pytest to ensure the inputs are correctly handled.

* remove print statement
2024-10-26 19:41:32 +00:00
3131c0ce08 fix: Fix async cache (#4265)
Fix async cache
2024-10-26 08:30:51 +00:00
2880f585fb fix: assistants optional dependencies (#4278)
assistants optional dependencies
2024-10-25 18:35:18 -04:00
ee101e643c fix: refine subflow field filtering to include '|' character check (#4277)
* Refine subflow field filtering to include '|' character check

* Add resource cleanup in test_components_path to ensure proper closure

* Remove unnecessary try-finally block in test_cli.py

* Remove unused pytest fixture decorator from test_components_path function

* Update test duration tracking in backend tests
2024-10-25 13:10:41 +00:00
78e6ee1a8a fix: Solves Issues with Set Function in Component Class and Enhance Input Handling (#4258)
* Enhance Component Input Handling and Add Unit Tests

Enhance component input handling and add unit tests for mixed input scenarios.

* [autofix.ci] apply automated fixes

* fix: handle JSON serialization for lists and dicts in _process_connection_or_parameters

- Updated the _process_connection_or_parameters function to handle lists and dictionaries properly.
- Ensured that each element in a list is checked for serializability and converted to a string if necessary.
- Added logic to convert dictionaries to JSON strings, handling non-serializable contents by converting them to strings.
- This change prevents JSON serialization errors when processing component parameters.

* reverting the changes

* [autofix.ci] apply automated fixes

* Update component.py

updates _process_connection_or_parameters to handles situations where the list is not all component.

Also handles any serialisation isseus caused by _process_connection_or_parameters

* [autofix.ci] apply automated fixes

* Update component.py

update make sure it is not a list str | int | float | bool | type(None)

Serialisation removed

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-24 13:52:52 -04:00
5be41ae13e fix: make sure data is json serializable (#4269)
* Refactor `recursive_serialize_or_str` function into a separate module

- Moved the `recursive_serialize_or_str` function from `schema.py` to a new `serialize.py` module for better modularity and reusability.
- Updated imports in `data.py`, `artifact.py`, and `schema.py` to reflect the new location of the `recursive_serialize_or_str` function.
- Enhanced the `recursive_serialize_or_str` function to handle `datetime` objects by converting them to ISO format.

* Enhance data serialization with recursive handling in `to_json` method

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2024-10-24 16:47:02 +00:00
374d3af9c6 fix: correctly call the /variable endpoint after the user is authenticated (#4267)
*  (authContext.tsx): Add functionality to fetch global variables on authentication
🔧 (api.tsx): Replace universal-cookie import with react-cookie for consistency
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency
🔧 (use-get-global-variables.ts): Add check to only fetch global variables if user is authenticated
 (use-get-mutation-global-variables.ts): Add mutation function to fetch and update global variables
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency

*  (use-get-folders.ts): add authentication check before fetching folders data to ensure only authenticated users can access the data
2024-10-24 13:12:29 -03:00
5811857ca2 refactor: Tool Output Management: Add Component-Specific Variable for Conditional Tool Output (#4259)
Implement conditional tool output handling

- Updated `component.py` to check for `FEATURE_FLAGS.add_toolkit_output` and call `_append_tool_output` if the component has the `add_tool_output` attribute set to True.
- Ensured that the tool output behavior is correctly managed based on feature flags and component attributes in `custom_component.py`.
2024-10-23 22:44:00 +00:00
4075212c34 docs: Langfuse integration (#4245)
Add doc for Langfuse integration
2024-10-23 19:38:15 +00:00
735c7330da feat: Add LM Studio Model and Embeddings Component (#4021) 2024-10-23 18:46:36 +00:00
921743da5f fix: restore radius (#4257)
restore radius
2024-10-23 18:24:35 +00:00
e910148907 feat: theme color updates (#4256)
theme color updates
2024-10-23 13:04:48 -05:00
1fb72b826f feat: Add AstraGraphVectorStoreComponent (#4248)
Add AstraGraphVectorStoreComponent
2024-10-23 15:54:56 +00:00
e93397d118 chore: update dependencies and enable HTTP/2 support for AsyncClient in tests (#4173)
* Update dependencies in pyproject.toml: fastapi, httpx, python-multipart

* Enable HTTP/2 support for AsyncClient in test configurations
2024-10-23 13:02:06 +00:00
9b1c382641 fix: updating components to access secret key with new method get_secret_value() (#4243)
* updating components to access secret key with new method

* [autofix.ci] apply automated fixes

* 📝 (text_embedder.py): Add error messages as constants for better error handling and readability
📝 (text_embedder.py): Improve error handling and validation for embedding model and text content
📝 (text_embedder.py): Ensure proper protocol for the base URL in the embedding model client
📝 (text_embedder.py): Validate the output of embeddings and handle exceptions with logging
📝 (text_embedder.py): Refactor code to encapsulate results in a Data object and update status accordingly
📝 (similarity.spec.ts): Add a delay before clicking the button to run the text output test for better synchronization

* uv fix

* [autofix.ci] apply automated fixes

* 📝 (text_embedder.py): refactor error messages to use inline strings for better readability and maintainability
🐛 (text_embedder.py): fix issue with extracting the first element from embeddings list to ensure correct data handling

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
2024-10-22 23:21:58 +00:00
f44aca5b41 ref: Fix some ruff rules for private access (SLF) (#4139)
* Add ruff rules for private access (SLF)

* Changes following review

* Rename Vertex._data to Vertex.full_data
2024-10-22 23:04:12 +00:00
8224bce532 ref: Add ruff rules for bandit (S) (#4111)
* Add ruff rules for bandit (S)

* Changes following review
2024-10-22 22:33:37 +00:00
6180a6daed FEAT: Upgrade langchain (0.3.x) and associated packages including langchain-astradb (#4229)
* Start on big langchain dep upgrade

* Update pyproject.toml

* add new lock

* Rebase on post1 changes

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-10-22 18:30:21 +00:00
4bb4f02e5b feature: add new playground ui (#4193)
* create newmodal.tsx

* Add new icons to styleUtils.ts

* Refactor import path for IOModal in chatComponent/index.tsx

* Refactor import path for IOModal in chatComponent/index.tsx

* Refactor session selector UI in IOFieldView component

* Refactor NodeToolbarComponent to add a minimum width to SelectContent

* Refactor IOModal to use newChatView component for ChatView

* improve html structure to ensure aligment of texts

* Refactor IOModal to improve sidebar behavior and alignment

* add new input

* Add Image icon to nodeIconsLucide in styleUtils.ts

* Refactor uploadFileButton to use Image icon instead of PaperclipIcon

* Refactor chat input layout for improved alignment and behavior

* Refactor buttonSendWrapper component to show a "Stop" button with loading indicator

* add a new TextAreaWrapper component

* add icons and update colors

* Add CornerDownLeft icon to nodeIconsLucide in styleUtils.ts

* Refactor buttonSendWrapper component to use default button state

* create newFilePreview

* Refactor file preview component and update button styling

* Refactor file preview component and update button styling

* fix overflow bug

* Refactor ChatView component to include a lockChat feature and display a flow running message

* [autofix.ci] apply automated fixes

* Refactor ChatView component to fix padding issue

* [autofix.ci] apply automated fixes

* Refactor dependencies in uv.lock to use a more specific version specifier for astra-assistants package

* Refactor ChatView component to import newChatMessage instead of chatMessage

* Refactor IOModal newModal component to conditionally display the session name

* Refactor TextAreaWrapper component to update placeholder text and fix padding issue

* Refactor TextAreaWrapper component to update placeholder text and fix padding issue

* Refactor ChatView component to update lockChat UI and display flow running message

* Refactor ChatView component to update lockChat UI and display flow running message

* Refactor ChatMessage component to update sender name UI and fix message width issue

* Refactor EditMessageButton component to update button UI and add tooltips

* Refactor EditMessageButton component to update button UI and add tooltips

* Refactor EditMessageField component to update UI and add functionality

* update edit message field

* fix group reference

* Refactor CodeTabsComponent to update UI, add functionality, and improve code structure

* Refactor CodeTabsComponent to update UI and improve code structure

* Refactor CodeTabsComponent to simplify and improve UI

* [autofix.ci] apply automated fixes

* Refactor ChatView component to fix UI layout issue

* fix overflow code boundaries problems

* Refactor CSS to update background color variables

* Refactor ChatCodeTabComponent to update UI and improve code structure

* fix broken rebase changes

* [autofix.ci] apply automated fixes

* Refactor EditMessageButton component to remove delete functionality

* Refactor SessionSelector component to update UI and improve code structure

* Refactor SessionSelector component to update UI and improve code structure

* [autofix.ci] apply automated fixes

* refactor session selector to use old code and keep updates on newSessionSelector

* create new button send wrapper

* restore old button send wrapper and update imports

* restore upload file button and create new UploadFileButton

* [autofix.ci] apply automated fixes

* Add feature flag for new IO modal

* Refactor IOModal imports to support feature flag

* update package-lock.json

* [autofix.ci] apply automated fixes

* remove console.log

* Refactor session selector event handlers

* Refactor file deletion in ChatInput component

* [autofix.ci] apply automated fixes

* Refactor file handling in ChatInput component

* [autofix.ci] apply automated fixes

* add user icon to messages

* feat: Add "Run Flow" button to ChatInput component

This commit adds a new button labeled "Run Flow" to the ChatInput component. When clicked, it triggers the sendMessage function with a repeat value of 1. Additionally, if there is no input in the chat, a message is displayed prompting the user to add a Chat Input component to their flow.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-22 18:07:27 +00:00
21bdad0ffb fix: Update Azure OpenAI API versions and improve version selection (#4232)
Update Azure OpenAI API versions and improve version selection

This PR updates the `AZURE_OPENAI_API_VERSIONS` list in the `AzureChatOpenAIComponent` class to include the latest GA and preview versions of the Azure OpenAI API. It also improves the default version selection logic.

Changes:
- Updated `AZURE_OPENAI_API_VERSIONS` list:
  - Added the latest GA version: "2024-06-01"
  - Added recent preview versions: "2024-07-01-preview", "2024-08-01-preview", "2024-09-01-preview", "2024-10-01-preview"
  - Removed older versions that are no longer relevant
  - Reordered the list to prioritize newer versions
- Improved the `api_version` DropdownInput:
  - Now sorts options in reverse chronological order
  - Default value now selects the latest non-preview version, falling back to the first version if all are preview

The updated list now reflects the most current API versions as of the latest documentation update, and the improved selection logic ensures users are presented with the most appropriate default version.
2024-10-22 17:24:49 +00:00
b6f74fb275 ref: Move get_settings_service out of Depends() (#4239)
Move get_settings_service out of Depends()
2024-10-22 16:55:40 +00:00
6e39dedaae ref: Rename component modules to lower case (ruff N999) (#4220)
* Rename component modules to lower case (ruff N999)

* git rename workaround (1/2)

* git rename workaround (2/2)

* Rollback changes on schema __init__

* Fix tests
2024-10-22 16:46:32 +00:00
51a420f31a fix: sidebar_categories route (#4237)
chore: add default value to beta attribute
2024-10-22 15:49:12 +00:00
4fc4e49c6c chore: apply changes to pyproject.toml from v1.0.19.1 (#4238)
* apply changes to pyproject.toml from v1.0.19.1

* back out langflow and langflow version for now
2024-10-22 15:16:28 +00:00
48148f0df6 fix: logger config and env file loading (#4174)
* fix: logger config and env file loading

* fix: mypy error assignment and arg-type
2024-10-22 14:29:32 +00:00
f0eb7b50a6 ref: Some fixes for ruff rules preview mode (#4197)
* Some fixes for ruff rules preview mode

* Fix mypy error

* More Annotated[] types for fastapi endpoints

* Use type aliases for Depends(get_session) and Depends(get_current_active_user)
2024-10-22 14:04:31 +00:00
e308f8d84d build(deps): bump hono from 4.6.1 to 4.6.5 in /src/frontend (#4161)
Bumps [hono](https://github.com/honojs/hono) from 4.6.1 to 4.6.5.
- [Release notes](https://github.com/honojs/hono/releases)
- [Commits](https://github.com/honojs/hono/compare/v4.6.1...v4.6.5)

---
updated-dependencies:
- dependency-name: hono
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-22 12:26:41 +00:00
507eda997a ref: Auto-fix some ruff ANN rules (#4210)
* Auto-fix some ruff ANN rules

* Fix mypy errors

* Changes following review

* Fix ServiceFactory
2024-10-22 13:55:48 +02:00
c85cd91e09 ref: Move get services out of API methods (#4216)
* Move get services out of API methods

* Rollback files API to be able to mock the dependency
2024-10-22 11:27:31 +00:00
349a2b49a4 fix: Use an async client for Redis cache (#4231)
Use an async client for Redis cache
2024-10-21 21:16:06 +00:00
99bcaab9d8 ref: Remove useless fastapi Depends (#4217)
Remove useless fastapi Depends
2024-10-21 20:53:17 +00:00