Commit graph

5,079 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
e536272759
fix(langflow): handle KeyboardInterrupt and terminate process in run function for graceful shutdown (#2551)
* fix(langflow): handle KeyboardInterrupt and terminate process in run function for graceful shutdown

* refactor(langflow): remove unnecessary try-except block and sys.exit calls in run_langflow function

* fix(langflow): handle exceptions properly and exit with appropriate status codes

* refactor: update multiprocess imports in langflow/__main__.py

Adds type ignore
2024-07-05 15:04:33 +00:00
codeflash-ai[bot]
4954b3fa66
perf: ️ Speed up convert_kwargs() by 9% in src/backend/base/langflow/interface/initialize/loading.py (#2529)
* refactor(base.py): refactor logic to find start_component_id based on multiple keywords for improved flexibility and readability

* feat(schema.py): add WebhookInput component type to INPUT_COMPONENTS list for handling webhook inputs in the graph schema

* refactor(base.py): refactor logic to determine start_component_id based on webhook or chat component presence in input vertices

* refactor: prioritize webhook component for determining start_component_id

* ️ Speed up convert_kwargs() by 9%
To optimize the given Python program, we can focus on a few key areas.

1. **Avoid Repeated Lookups:** Instead of repeatedly looking up keys and values in the dictionary, we can iterate over items directly.
2. **Efficient JSON Parsing:** Using `orjson` is already a good choice for performance. We will handle the exception based on `orjson` capabilities.
3. **In-place Modification:** We can modify the dictionary in place without creating additional lists.

Here is the optimized program.



### Changes Made.

1. **Direct Looping:** We iterate directly over `params.items()` to process keys and values together, which helps avoid multiple lookups.
2. **Exception Handling:** We catch `orjson.JSONDecodeError` directly, avoiding unnecessary import and potential mismatches.
3. **Deferred Removal:** We collect keys to remove in `items_to_remove` and then remove them outside the loop, which helps avoid modification issues during iteration.

This should result in more efficient iteration and handling while reducing overhead from unnecessary operations.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-07-05 07:51:50 -07:00
Gabriel Luiz Freitas Almeida
3900c58983
fix(ordering): correctly remove vertex from list of runnable vertices (#2554) 2024-07-05 13:30:54 +00:00
ming
c444a6905c
feat: opentelemetry and prometheus (#2543)
* opentelemetry and prometheus

* set env override in create_app

* add prometheus_client to pyproject

* update top level poetry.lock
2024-07-05 12:50:53 +00:00
Jordan Frazier
a933139927
docs: small updates to astra vectorize docs (#2497)
small updates to vectorize docs

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-07-04 18:25:58 +00:00
Gabriel Luiz Freitas Almeida
03329b232e
fix: make webhook api call honor webhook component as input (#2511)
* refactor(base.py): refactor logic to find start_component_id based on multiple keywords for improved flexibility and readability

* feat(schema.py): add WebhookInput component type to INPUT_COMPONENTS list for handling webhook inputs in the graph schema

* refactor(base.py): refactor logic to determine start_component_id based on webhook or chat component presence in input vertices

* refactor: prioritize webhook component for determining start_component_id

* feat(utils.py): add function find_start_component_id to find component ID based on priority list of input types

* refactor(graph/base.py): refactor logic to find start component id in Graph class for better readability and maintainability

* test(test_webhook.py): override pytest fixture to check for OpenAI API key in environment variables before running tests

* test(test_webhook.py): update webhook json

* feat(schema.py): update WebhookInput component type name

* refactor: log package run telemetry in simplified_run_flow

* test: add test for webhook flow on run endpoint

* refactor(graph/base.py): skip unbuilt vertices when getting vertex outputs in Graph class

* refactor: simplify data_input assignment in LCTextSplitterComponent

* refactor: remove unused build method in CharacterTextSplitterComponent

* refactor: update imports in CharacterTextSplitter.py
2024-07-04 11:11:55 -07:00
Nicolò Boschi
86aaab0cec
feat: migrate text splitters to Component syntax (#2530)
* feat: migrate text splitters to Component syntax

* [autofix.ci] apply automated fixes

---------

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-07-04 10:29:33 -07:00
Gabriel Luiz Freitas Almeida
bf5e7b343a
fix(base.py): only add successors if is_start (#2513) 2024-07-04 14:25:16 +02:00
Gabriel Luiz Freitas Almeida
15aa68a342
fix: make end_all_traces be called at the correct moment (#2516)
* fix(tracing/service.py): remove wait_for_all_tracers call

* refactor: set reasonable timeout for TelemetryService client

* fix: handle HTTP and request errors in TelemetryService

Handle HTTPStatusError and RequestError exceptions separately in the send_telemetry_data method of TelemetryService to provide more specific error messages. Also, catch any unexpected exceptions and log them with an appropriate error message.

* fix: cancel worker task and close client in TelemetryService stop method

Cancel the worker task and close the client in the stop method of TelemetryService to ensure proper cleanup and prevent potential resource leaks. Also handle any exceptions that may occur during the cleanup process and log appropriate error messages.

* style(telemetry/service.py): fix indentation issue in await statement to comply with PEP8 guidelines

* feat(graph): add method to remove vertex from runnables in Graph class

* fix(chat.py): fix issue where vertex was not being removed from runnables list to prevent duplication of results

* fix(chat.py): defines when the end_all_traces call should happen
2024-07-04 14:24:45 +02:00
Gabriel Luiz Freitas Almeida
a9f955d916
fix: handle unknown artifact type in post_process_raw function (#2527)
Handle the case where the artifact type is unknown and the raw value is not None in the post_process_raw function. Set the raw value to "Built Successfully " in this case.
2024-07-04 14:18:37 +02:00
Cristhian Zanforlin Lousa
8980e75723
bugfix: fix api request custom component (#2470)
* bugfix: fix api request custom component

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-07-04 05:05:22 -07:00
Lucas Oliveira
17b730b6cf
fix: update node logic (#2515)
* Fixed bug where updating the node does not remove edited status

* Fixed order of edited override

* Made all node-changing functions to alter type the right way

* Update StoreMessageComponent for enhanced message handling

- Changed base class from CustomComponent to Component
- Added multiple input fields: message, sender, sender_name, session_id
- Included output field for stored messages
- Improved logic to handle both string and Message types
- Enhanced error handling and validation for message storage

* Apply Ruff formatting

* Update StoreMessageComponent for enhanced message handling

* Apply Ruff formatting

* Feat: add more types

* Format code

* feat: Add CreateListComponent for creating a list of texts

This commit adds a new component called CreateListComponent, which is responsible for creating a list of texts. The component takes in one or more texts as input and outputs a list of Data objects. This component is useful for scenarios where a list of texts needs to be processed or manipulated.

The CreateListComponent class is added to the helpers module in the langflow.components package. It includes the necessary inputs and outputs, as well as a create_list method that generates the list of Data objects based on the input texts.

This commit also includes some minor changes to other files, such as renaming the UUIDGeneratorComponent to IDGeneratorComponent and updating import statements.

* [autofix.ci] apply automated fixes

* Changed native categories to use the keys of the style utils categories, which is updated

* change component name

* chore: add the name attribute to the CustomComponent

* chore: assign the value of name to the components

* chore: change the logic of the type value returned

* chore: extract code to new func

* chore: change component_name value

* [autofix.ci] apply automated fixes

* Formatted files

---------

Co-authored-by: Rodrigo <rodrigosilvanader@gmail.com>
Co-authored-by: rodrigosnader <rodrigosnader@users.noreply.github.com>
Co-authored-by: igorrCarvalho <igorsilvabhz6@gmail.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-07-03 17:55:01 -03:00
ming
a2ec87b44f
feat: key components health check (#2510)
key components health check
2024-07-03 12:42:34 -07:00
Cristhian Zanforlin Lousa
74845ffae9
fix: memory chat bot name (#2509)
* chore: refresh starter projects components

* format

* bugfix: change memory chatbot to correct name

* bugfix: change memory chatbot to correct name

---------

Co-authored-by: Nicolò Boschi <boschi1997@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-07-03 10:34:13 -07:00
Gabriel Luiz Freitas Almeida
ef870cbf85
fix(base.py): update get_successors function call to include 'recursive=False' parameter (#2504)
This fixes a bug where components were called in the wrong order.
2024-07-03 08:22:37 -07:00
Gabriel Luiz Freitas Almeida
01ff15f5a3
fix: improve handling of ToolCallingAgent output in ToolCallingAgentComponent (#2494)
* fix: improve handling of ToolCallingAgent output in ToolCallingAgentComponent

The code changes in `ToolCallingAgent.py` modify the `ToolCallingAgentComponent` class to improve the handling of the output from the `ToolCallingAgent`. The changes include updating the logic to handle both single results and lists of results, extracting the relevant text from the results, and assigning it to the `result_string` variable. This ensures that the `result_string` contains the appropriate output to be returned as a `Message` object.

* fix(ToolCallingAgent.py): fix variable name typo from 'result' to 'results' for correct data processing

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 14:36:40 -07:00
Gabriel Luiz Freitas Almeida
2eb786cdd9
feat(utils.py): add error handling for missing template_config in build_custom_component_template (#2491) 2024-07-02 14:21:57 -07:00
Gabriel Luiz Freitas Almeida
fb6d462a61
feat(pyproject.toml): update package versions to 1.0.6 for langflow and 0.0.82 for langflow-base to reflect latest changes and improvements (#2479)
* feat(pyproject.toml): update package versions to 1.0.6 for langflow and 0.0.82 for langflow-base to reflect latest changes and improvements

* chore(lock): new lock

* fix: update ChatGroq output in GroqModel.py
2024-07-02 12:59:55 -07:00
Lucas Oliveira
629df8fef3
fix: create data component not saving old values on check and save (#2483)
Fixed Create Data component to maintain old values and use new code structure

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 12:20:52 -07:00
Gabriel Luiz Freitas Almeida
e424076677
fix(service.py): improve handling of environment variables in DatabaseVariableService to update or create variables based on changes in secret_key (#2481)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 12:19:47 -07:00
Nicolò Boschi
fb29b248be
fix: run_flow_from_json circular dependency (#2485)
* fix: run_flow_from_json circular dependency

* fix: run_flow_from_json circular dependency

* fix: run_flow_from_json circular dependency

* fix mypy

* fix mypy

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 12:16:12 -07:00
Gabriel Luiz Freitas Almeida
5f0e74e5d2
fix(tracing_service): use correct trace name and attribute name (#2484)
* fix(tracing_service): use correct trace name and attribute name

* fix: update tracing_service attribute name in LCModelComponent

* feat: add trace_name property in CustomComponent

* fix: update trace_name usage in Component build method

* feat: update log method in CustomComponent to use trace_name

* fix: update trace_name usage in Component build method

* feat(custom_component): add logs to CustomComponent

The `CustomComponent` class now includes a `_logs` attribute to store log messages. This attribute is initialized as an empty list in the constructor. The `log` method has been updated to accept an optional `name` parameter, which allows specifying a custom name for the log message. If no name is provided, a default name is generated based on the number of logs already stored.

This change enhances the logging functionality of the `CustomComponent` and provides more flexibility in managing log messages.

* feat(tracing_service): add logs to TracingService

This commit adds a `_logs` attribute to the `TracingService` class to store log messages. The attribute is initialized as a defaultdict of lists in the constructor. The `add_log` method has been updated to append logs to the corresponding trace name in the `_logs` dictionary. This change enhances the logging functionality of the `TracingService` and allows for better management of log messages.

* chore(tracing_service): improve error handling in stop method

* refactor(tracing/service.py): update _logs data structure to support both Log objects and generic dictionaries for flexibility in handling different types of data

refactor(tracing/service.py): add conditional check to only add metadata if it is provided for better control over the information being added

* refactor: update build_model method return type annotation

* refactor(CohereModel.py): update return type of build_model method to only LanguageModel for clarity and consistency

* chore(GroqModel.py): add stop_sequences parameter to GroqModel query method

* refactor(AstraDB.py): reorganize imports and update cached_vectorstore type

* refactor: update cached_vectorstore type and input order in CassandraVectorStoreComponent

* chore(GroqModel.py): remove unused stop_sequences parameter in GroqModel query method
2024-07-02 11:49:27 -07:00
Nicolò Boschi
0853056ee1
fix(security): require langchain-experimental>=0.0.61 (#2476)
* security: require langchain-experimental>=0.0.61

* security: require langchain-experimental>=0.0.61
2024-07-02 18:09:21 +02:00
Nicolò Boschi
30c369f064
feat(cassandra/astradb): hybrid search support (#2396)
* cassandra/astradb: hybrid search support

* fix

* fix
2024-07-02 16:09:11 +02:00
João Pedro Miranda C. Hluchan
805df8298a
fix: resolve Model Issues and add huggingface dependency (#2339)
* chore: adding default values to Azure OpenAI mandatory component

* fix: huggingface model component:
  - Change Huggingface-hub version from 0.20.0 to 0.22.0;
  - Internal model_id resolver not working, create a field to model_id;

* feat: add HuggingFace as extra dependency

* chore: remove redundant atribution on children

* fix: remove user environment variables from ChatLiteLLMModelComponent

---------

Co-authored-by: joaoguilhermeS <j.guilherme.s.oliveira2@gmail.com>
2024-07-02 14:04:26 +00:00
Nicolò Boschi
9bc683bdc7
fix(bedrock): fix error 'Key cache already exists' (#2423)
* bedrock: fix error 'Key cache already exists'

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 15:19:08 +02:00
Nicolò Boschi
0494bc2122
fix: azure openai model component: resource not found (#2426)
* fix azure openai model component: resource not found

* type

* type

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 15:18:47 +02:00
Nicolò Boschi
6ef7776004
fix(astradb): make fields required (#2428)
* astradb: make fields required

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 15:18:34 +02:00
Nicolò Boschi
653be0b358
fix (astra/cassandra): avoid duplicated ingestion (#2455)
* astra/cassandra: avoid duplicated ingestion

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-02 13:11:17 +00:00
Nicolò Boschi
f2bf62e284
ci: fix mypy checks (#2431)
* ci: fix mypy

* ci: fix mypy

* ci: fix mypy

* run fe checks

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-01 14:42:14 -07:00
Dmitry Galanov
bd20885a3b (fix) Add gpt4 to openai_constants.py (#2416)
(fix) Add gpt4 to openai_constants

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-07-01 13:53:55 -03:00
ming
3015d2f138 loguru support standout logging with json and csv (#2415)
support standout logging with json and csv

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-01 13:53:55 -03:00
Lucas Oliveira
b31c5e6b4a Fix Global Variables (#2430)
* chore: update linting workflows to include dev branch in merge_group

* Update README.md

Add 1.0 banner

* Update README.md

* chore: update package versions in pyproject.toml files

* Added db value to every onChange on parameters

* Refactored global variables to find variables on the first render, and to execute just one onChange to update both values and db

* Changed group recursion function to include check for global variables already applied or outdated

* Removed already inserted component check for default fields on global variables

* Fixed import error

* Added required parameters to update node on drop

* Removed check for unused hardcoded name

* Added global variables handling on nodes when adding a flow

* Fixed maximum update depth when deleting used global variable

* Fixed type error on addNewVariableButton modal

* Fixed openai api key on starter flows

* Fixed values to get the .env values by default on the starter projects

* Formatted flows

* fix erros reported by mypy

* [autofix.ci] apply automated fixes

* 🐛 (prototypes/__init__.py): fix missing comma in the list of imported components to prevent syntax error

* chore: Fix type hinting in ConditionalRouterComponent

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Rodrigo Nader <rodrigosilvanader@gmail.com>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-01 13:53:55 -03:00
Gabriel Luiz Freitas Almeida
fd1c5cc84e ♻️ (code_parser.py): remove redundant condition that caused Component to not be parsed (#2406)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-01 13:53:55 -03:00
Gabriel Luiz Freitas Almeida
6a6bb3e13a fix: Add LanguageModel to field_typing module (#2410)
* feat: Add LanguageModel to field_typing module

* chore: Fix type annotations in model build methods

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-01 13:53:55 -03:00
Gabriel Luiz Freitas Almeida
73e38a0c73 chore: Refactor authentication key generation (#2443)
Refactor the `ensure_valid_key` function in `utils.py` to improve the generation of a valid key for authentication. The function now checks if the input key is too short and generates a random key if necessary. Additionally, the key is now URL-safe base64-encoded. This change enhances the security and reliability of the authentication process.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-01 13:53:55 -03:00
Gabriel Luiz Freitas Almeida
cd3f6c4c52 chore: fix lint errors (#2445)
* chore: Fix type hinting in ConditionalRouterComponent

* refactor: Update PassComponent to PassMessageComponent
2024-07-01 13:53:55 -03:00
italojohnny
9f2e608fcd fix delete messages 2024-07-01 13:53:55 -03:00
autofix-ci[bot]
70e9f06834 [autofix.ci] apply automated fixes 2024-07-01 13:53:55 -03:00
Rodrigo
093fa018f1 feat: Add CreateListComponent for creating a list of texts
This commit adds a new component called CreateListComponent, which is responsible for creating a list of texts. The component takes in one or more texts as input and outputs a list of Data objects. This component is useful for scenarios where a list of texts needs to be processed or manipulated.

The CreateListComponent class is added to the helpers module in the langflow.components package. It includes the necessary inputs and outputs, as well as a create_list method that generates the list of Data objects based on the input texts.

This commit also includes some minor changes to other files, such as renaming the UUIDGeneratorComponent to IDGeneratorComponent and updating import statements.
2024-07-01 13:53:55 -03:00
Gabriel Luiz Freitas Almeida
b19264506c chore: Add inputs parameter to end method in BaseTracer 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
a180e9e7c4 chore: Update LangSmithTracer constructor parameter type to UUID 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
293adb0417 🐛 (custom_component.py): fix issue where name was not being set correctly when name is None and self.display_name is True 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
08b2322a73 ♻️ (base.py): Refactor add_trace and end_trace methods to use Union type for optional arguments to improve code readability and type safety 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
e94d8254fb 📝 (base.py): add abstract method __init__ to BaseTracer class with required parameters to enforce implementation in subclasses 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
f8ace79af3 chore: Add metadata parameter to end method in BaseTracer
This commit adds a new optional `metadata` parameter to the `end` method in the `BaseTracer` class. The `metadata` parameter allows for passing additional information related to the tracing process. This enhancement provides more flexibility and extensibility to the tracing functionality.
2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
67a34ffcb8 Refactor: handle error when retrieving messages from monitor service
This commit refactors the code in the `migrate_messages_from_monitor_service_to_database` function to handle errors that may occur when retrieving messages from the monitor service. If an exception is raised, the error is logged and the function returns `False`. This ensures that the migration process can continue even if there is an issue with retrieving the messages.
2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
089ad6695c chore: Update LangSmithTracer import in tracing service 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
2efaa2804a refactor: Update LangSmithTracer to use convert_to_langchain_types from utils.py 2024-07-01 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
d7008f7662 refactor: Remove unused methods and abstract class from BaseTracer 2024-07-01 13:53:39 -03:00