Commit graph

11,619 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
611cb7f57c 📝 docs(README.md): Add CLI usage and environment variables sections to the README
The README file now includes a new section that provides information on how to use the command-line interface (CLI) of Langflow. It explains the available options and their usage. Additionally, a section on environment variables is added, which explains how to configure CLI options using environment variables. This provides users with more flexibility in customizing the behavior of the Langflow server.
2023-07-05 13:07:16 -03:00
Gabriel Luiz Freitas Almeida
70b634cbcf 🔧 chore(__main__.py): refactor serve function to use environment variables for configuration options
🌟 feat(__main__.py): add support for environment variables to configure serve function
The serve function in __main__.py has been refactored to use environment variables for configuration options. The following configuration options now support environment variables: host, workers, port, log_level, log_file, path, open_browser, and remove_api_keys. This change allows for greater flexibility and easier configuration of the serve function by using environment variables instead of command line options.
2023-07-05 13:07:02 -03:00
Gabriel Luiz Freitas Almeida
29f840aed9 🔧 chore(.env.example): update example values and add new configuration options
The .env.example file has been updated to include example values and new configuration options. The LANGFLOW_DATABASE_URL example has been updated to include both Postgres and SQLite examples. New configuration options have been added for cache type, server host, worker processes, server port, logging level, log file path, frontend directory path, whether to open the browser after starting the server, and whether to remove API keys from the projects saved in the database. These changes provide more flexibility and customization options for the application.
2023-07-05 13:06:50 -03:00
gustavoschaedler
ae5bc1e203 Refactor custom.py for better error handling
- Modifies the `CustomComponent` class to handle errors using `HTTPException` from FastAPI
- Removes the unused `HTTPExceptionWithTraceback` class
- Updates the error response format with `err.msg` and `traceback.format_exc()`
2023-07-05 16:23:32 +01:00
gustavoschaedler
a21582589c import custom.py: Add HTTPExceptionWithTraceback class
This commit adds a new class `HTTPExceptionWithTraceback` that extends `HTTPException` from the `fastapi` module. This new class includes a `traceback` attribute. Additionally, in the `extract_class_info` method of the `CustomComponent` class, a try-except block is added to catch any syntax errors raised by parsing the provided code. If a syntax error is encountered, an HTTPException is raised with the error message and traceback.
2023-07-05 16:22:22 +01:00
Gabriel Luiz Freitas Almeida
95b8555503 🐛 fix(settings.py): change environment variable name from LANGFLOW_DATABASE_URL to langflow_database_url for consistency
The environment variable name is changed from LANGFLOW_DATABASE_URL to langflow_database_url to maintain consistency with the naming conventions used in the codebase. This ensures that the code is more readable and easier to understand.
2023-07-05 12:10:32 -03:00
Gabriel Luiz Freitas Almeida
8214b22c09 🔧 chore(__main__.py): update cache and database environment variable names for clarity and consistency
The `cache` option has been changed to use the `LANGFLOW_LANGCHAIN_CACHE` environment variable instead of `LANGCHAIN_CACHE` for clarity and consistency. Similarly, the `database_url` option now uses the `LANGFLOW_DATABASE_URL` environment variable instead of the previous behavior of using a local SQLite database by default. This change allows for more flexibility in configuring the cache and database connections.
2023-07-05 12:10:09 -03:00
Gabriel Luiz Freitas Almeida
4b1fb4a49e 🐛 fix(utils.py): rename cache_class variable to cache_type for clarity and consistency
🔧 chore(utils.py): refactor `setup_llm_caching` to extract cache setup logic into a separate function for better modularity and readability
The variable `cache_class` has been renamed to `cache_type` to improve clarity and consistency with the naming conventions. The `setup_llm_caching` function has been refactored to extract the cache setup logic into a separate function called `set_langchain_cache`. This improves modularity and readability of the code.
2023-07-05 12:09:53 -03:00
Gabriel Luiz Freitas Almeida
cb1ab1a79e 📝 docs(.env.example): add example .env file with langflow_database_url set to sqlite database URL
The .env.example file is added to provide an example of how to configure the .env file. It includes a commented out example of a PostgreSQL database URL and a new line is added with the langflow_database_url set to a SQLite database URL. This allows users to easily copy the file to .env and modify the values according to their needs.
2023-07-05 12:00:42 -03:00
anovazzi1
53cfec6321
Add round buttons constants classes (#609)
Improves code verbosity and organization of Tailwind classes.
2023-07-05 11:59:43 -03:00
Gabriel Luiz Freitas Almeida
8cee7e701f 🔺 chore(pyproject.toml): update langchain-serve version to >0.0.51
The langchain-serve package has been updated to version >0.0.51. This update may include bug fixes, new features, or other improvements.
2023-07-05 11:54:41 -03:00
anovazzi1
d93dbef31b style(index.css): remove unused text-color class and update components-disclosure-title class to use text-primary class for consistent styling
style(DisclosureComponent): update Icon class to use text-primary class for consistent styling
style(FlowPage): remove logspace-icon-text class and update the structure of the icon and text elements for better alignment and spacing
2023-07-05 11:51:06 -03:00
Gabriel Luiz Freitas Almeida
552edf072b 🔧 chore(settings.py): make database_url optional to handle cases where it is not provided
The `database_url` setting is now declared as an optional string (`Optional[str]`) instead of a required string. This change allows the application to handle cases where the `database_url` is not provided, providing more flexibility in the configuration.
2023-07-05 11:50:32 -03:00
Gabriel Luiz Freitas Almeida
d713d38ca7 🔧 chore(__main__.py): refactor loading of environment variables to allow overriding with .env file
The os module is imported to make use of the os.getenv() function. The loading of the environment variables is refactored to check for the presence of the "langflow_database_url" environment variable and use it as the value for the database_url variable if it is not provided. This allows for more flexibility in configuring the database URL. Additionally, the loading of environment variables is refactored to allow overriding with a .env file if the env_file parameter is provided. This allows for easier configuration management.
🔧 chore(__main__.py): import os module and refactor loading of environment variables
2023-07-05 11:50:07 -03:00
Gabriel Luiz Freitas Almeida
c0efe4dbcf 🔧 chore(__init__.py): add noqa comments to import statements to ignore linting errors
The noqa comments have been added to the import statements to ignore the linting errors raised by the linter. This ensures that the linting errors related to the imports are ignored and the code can be properly executed without any issues.
2023-07-05 11:49:22 -03:00
Gabriel Luiz Freitas Almeida
20da596d9a 🐛 fix(base.py): handle case when no database_url is provided and raise an error
 feat(base.py): add error handling when creating database and tables to provide more informative error messages
The code now checks if the `settings.database_url` is provided and raises a `RuntimeError` if it is not. This ensures that the application does not attempt to create a database connection without a valid URL. Additionally, error handling has been added when creating the database and tables. If an exception occurs during the creation process, an error message is logged and a `RuntimeError` is raised with a more informative error message. This helps in identifying and resolving any issues related to the database creation process.
2023-07-05 11:47:55 -03:00
gustavoschaedler
53656dcc1f feat: Add dynamic field support
This commit adds support for dynamic fields in the template field creator class. The "dynamic" attribute has been added to the class definition and its default value is set to False.
2023-07-05 15:04:22 +01:00
anovazzi1
ffb8e17eb6 Merge branch 'python_custom_node_component' of personal:logspace-ai/langflow into python_custom_node_component 2023-07-05 10:52:19 -03:00
anovazzi1
900aacb5fb debug dynamic on console 2023-07-05 10:52:10 -03:00
gustavoschaedler
bc809c6a9e Add dynamic option for custom component code in FrontendNode. 2023-07-05 14:51:57 +01:00
gustavoschaedler
617552d212 Merge branch 'python_custom_node_component' of github.com:logspace-ai/langflow into python_custom_node_component 2023-07-05 14:44:18 +01:00
gustavoschaedler
fd16b385ab feat: Add dynamic field to code field in types module
This commit adds a dynamic field to the code field in the types module. The dynamic field is set to True, indicating that the field allows updates.

refactor: Remove dynamic field from FrontendNode class

In the FrontendNode class of the base module, the dynamic field has been removed. This change aligns with the removal of the dynamic field in the types module.

refactor: Remove dynamic field from CustomComponentNode class

The dynamic field has been removed from the CustomComponentNode class in the tools module. This aligns with the removal of the dynamic field in the FrontendNode class.
2023-07-05 14:44:11 +01:00
anovazzi1
8b0a39f6ee fix(codeAreaModal): move postCustomComponent call inside else block to prevent unnecessary API calls when condition is false
fix(codeAreaModal): remove commented out code for axios.get call
2023-07-05 10:44:00 -03:00
Gabriel Luiz Freitas Almeida
8d77e51037 🔧 chore(pre-commit): change file mode from 100644 to 100755 for better execution permissions
The file mode of the pre-commit hook has been changed from 100644 to 100755. This change ensures that the pre-commit hook has the necessary execution permissions, allowing it to be executed properly before each commit.
2023-07-05 09:49:18 -03:00
Gabriel Luiz Freitas Almeida
a69225bb07 🔧 chore(loading.py): remove unused import statement
🐛 fix(loading.py): remove unnecessary None default value for file_filter parameter
The unused import statement from langchain.prompts.base has been removed to improve code cleanliness. The None default value for the file_filter parameter in the instantiate_documentloader function has been removed as it is unnecessary and can be safely assumed that the parameter will always be provided.
2023-07-05 09:46:27 -03:00
Gabriel Luiz Freitas Almeida
5879ad99f2 🔥 refactor(main.py): remove unused /dynamic_node endpoint and template_node variable
💡 chore(main.py): clean up code by removing an unused endpoint and a template_node variable that is no longer needed
The /dynamic_node endpoint and the template_node variable are no longer used in the application and can be safely removed. This improves code cleanliness and reduces unnecessary complexity.
2023-07-05 09:41:40 -03:00
Gabriel Luiz Freitas Almeida
3059e8c670 🐛 fix(base.py): fix add_edge method to prevent adding duplicate edges
🐛 fix(base.py): fix __eq__ method in Edge class to correctly compare objects
The add_edge method in the Vertex class has been modified to prevent adding duplicate edges. Now, before adding an edge, it checks if the edge already exists in the edges list to avoid duplicates.

The __eq__ method in the Edge class has been fixed to correctly compare objects. It now compares the string representation of the objects to determine equality, ensuring that the comparison is accurate.
2023-07-05 09:37:25 -03:00
Cristhian Zanforlin Lousa
864fb2f8ef Merge branch 'form_io' of https://github.com/logspace-ai/langflow into form_io 2023-07-05 06:52:07 -03:00
Cristhian Zanforlin Lousa
b8e76b0be4 🐛 fix(parameterComponent): remove unnecessary line break to improve code readability
🐛 fix(utils.ts): set 'type' property to an empty string instead of undefined to avoid potential issues
2023-07-05 06:52:01 -03:00
Gabriel Luiz Freitas Almeida
6d9bcd5e65 🔧 chore(Makefile): make pre-commit hook executable
The pre-commit hook in the .githooks directory was not executable, causing it to not be triggered. This commit makes the pre-commit hook executable by adding the `chmod +x` command to set the executable permission on the pre-commit hook file.
2023-07-05 00:03:32 -03:00
Gabriel Luiz Freitas Almeida
10bbb8e901 style: improve readability 2023-07-05 00:01:06 -03:00
Gabriel Luiz Freitas Almeida
834429cd37 fix: add verification for formKeysData 2023-07-04 23:58:54 -03:00
gustavoschaedler
48345dd8dd Refactor MyPythonClass build method to accept openai_api_key parameter.
- The `build` method of `MyPythonClass` is modified to accept an `openai_api_key` parameter instead of using a hardcoded value.
- This change allows for dynamic usage of different API keys when constructing an instance of `ConversationChain`.
- The `my_conversation` method now takes `openai_api_key` as an argument and uses it to initialize the `llm` instance of `OpenAI`.
- The `build` method simply delegates the `openai_api_key` argument to the `my_conversation` method and returns the resulting `ConversationChain` instance.
2023-07-05 03:37:18 +01:00
gustavoschaedler
839e9737cc Refactor code to extract class name from custom code
- Updatethe `get_function_custom` function to use the `validate.extract_class_name` function to extract class name from the `code` parameter.
- Modify `instantiate_tool` function to update the `class_object` with the return value of `get_function_custom` and call the `build` method on the instantiated object with the remaining params.
- Add a new function `extract_class_name` in the `validate` module to extract class name from the `code` parameter.
2023-07-05 03:34:16 +01:00
Gabriel Luiz Freitas Almeida
5445adbbce 🐛 fix(validate.py): set new field value with the old value if variable already exists in the template
The code now checks if the variable already exists in the template and if so, sets the new field value with the old value. This ensures that the existing value is preserved when adding new variables to the template.
2023-07-04 23:32:25 -03:00
Gabriel Luiz Freitas Almeida
244aeae916 🔧 chore(validate.py): add multiline option to input_variables field in add_new_variables_to_template function
The multiline option is added to the input_variables field in the add_new_variables_to_template function. This allows the field to accept multiline input, which can be useful in certain scenarios where multiple lines of text need to be entered.
2023-07-04 23:30:24 -03:00
Gabriel Luiz Freitas Almeida
44011f3dd5 🐛 fix(GenericNode/index.tsx): fix class order in div element to ensure correct styling
 feat(GenericNode/index.tsx): improve readability and maintainability by extracting repeated class names into variables
The class order in the div element has been fixed to ensure the correct styling is applied. Repeated class names have been extracted into variables to improve readability and maintainability of the code.
2023-07-04 23:30:23 -03:00
gustavoschaedler
ac569f3405 Refactor code, improve type validation, and update build function name 2023-07-05 02:03:22 +01:00
gustavoschaedler
64e5a3a98d Add a dynamic flag to CustomComponentNode
- Added a dynamic flag to CustomComponentNode class in tools.py for enabling dynamic behavior.
- This flag allows for flexibility in executing the Python class.
- The flag defaults to True.
2023-07-05 01:30:40 +01:00
Igor Carvalho
84aa84cc08 feat: Add community page constants classes 2023-07-04 21:02:43 -03:00
gustavoschaedler
4028554ef6 Refactor build method argument name for clarity
Previously, the `build` method in the `MyPythonClass` class had an argument named `name`, which could be confusing. This commit changes the argument name to `my_custom_input` to improve readability and clarity.
2023-07-05 00:57:16 +01:00
gustavoschaedler
92b747b6da Update Vertex params with code type and add a my_conversation method to the MyPythonClass. Modify the instantiate_tool function to properly handle the CustomComponent node type. Add a dynamic field to the FrontendNode class. 2023-07-05 00:46:51 +01:00
Igor Carvalho
fdad5e7da3 feat: add main page constants classes 2023-07-04 20:44:38 -03:00
Igor Carvalho
04c3cb2d4e feat: add flowpage constants classes 2023-07-04 20:30:03 -03:00
Igor Carvalho
b6192162b0 feat: add side bar components disclosure constants classes 2023-07-04 20:17:09 -03:00
Igor Carvalho
f545b9cf9b feat: add round buttons constants classes 2023-07-04 20:04:01 -03:00
Cristhian Zanforlin Lousa
3f0cc57cd5 🐛 fix(parameterComponent): fix styling issue in tooltip and icon rendering in ParameterComponent 2023-07-04 19:24:37 -03:00
Cristhian Zanforlin Lousa
80efed1d91 adjust edge tooltips 2023-07-04 19:11:15 -03:00
Cristhian Zanforlin Lousa
4f33f02d4f 🐛 fix(parameterComponent): fix syntax error in refHtml.current assignment
🐛 fix(parameterComponent): fix classNames usage in span element
🐛 fix(parameterComponent): remove unnecessary line break element
🐛 fix(parameterComponent): fix className usage in span element
🐛 fix(ShadTooltipComponent): add className prop to TooltipContent component
🐛 fix(utils): fix syntax error in groupByFamily function
 feat(parameterComponent): add support for grouping and displaying multiple types in parameterComponent
 feat(utils): add support for grouping and filtering data in groupByFamily function
2023-07-04 19:08:19 -03:00
anovazzi1
5c0424846b
Add extra side bar constants classes (#602)
Improves code verbosity and organization of Tailwind classes.
2023-07-04 18:42:01 -03:00