Commit graph

598 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
05bd7b415a
Adding Building Progress Bar with DaisyUI and Radial Progress (#522) 2023-06-22 00:20:01 +00:00
Gabriel Luiz Freitas Almeida
d3d33162e8 🐛 fix(chat.py): change event name from "node" to "message" in stream_build function
The event name was changed from "node" to "message" to better reflect the nature of the data being sent. The data being sent is a message response from the server, not a node in the graph.
2023-06-21 15:04:36 -03:00
Gabriel Luiz Freitas Almeida
38c2eaa897 🔥 refactor(chat.py): remove unused import statement
🐛 fix(chat.py): fix StreamData class import statement
 feat(chat.py): add progress tracking and node building events to stream_build function
The unused import statement has been removed to improve code readability. The StreamData class import statement has been fixed to avoid errors. Progress tracking and node building events have been added to the stream_build function to provide more information to the user about the build process.
2023-06-21 14:53:54 -03:00
Gabriel Luiz Freitas Almeida
fae1ca349f 🔧 chore(schemas.py): add StreamData model and __str__ method to improve readability of stream data
The StreamData model is added to represent the data that is streamed from the server. The __str__ method is added to improve the readability of the stream data by returning a formatted string that includes the event and data attributes.
2023-06-21 14:53:53 -03:00
Gabriel Luiz Freitas Almeida
0fb33825d9 🐛 fix(chat.py): change data to error in yield statement when flow_id is invalid
🐛 fix(chat.py): catch exception when building graph and yield error message
When the flow_id is invalid, the yield statement should return an error message instead of data. Additionally, when building the graph, an exception could occur, so we added a try-except block to catch any exceptions and yield an error message instead of data.
2023-06-21 14:04:45 -03:00
Gabriel Luiz Freitas Almeida
fef8324886
Fix: Restore Notion and Slack directory loaders. (#476) 2023-06-21 13:57:00 +00:00
Gabriel Luiz Freitas Almeida
2029b08d2e Merge remote-tracking branch 'origin/main' into dev 2023-06-20 16:18:37 -03:00
Gabriel Luiz Freitas Almeida
5f5bf06ab2 🐛 fix(flows.py): fix conditional statement in update_flow function
The conditional statement in the update_flow function was incorrect. The if statement was checking for the opposite of what was intended. The fix changes the if statement to check for the correct condition.
2023-06-20 16:11:33 -03:00
Gabriel Luiz Freitas Almeida
f511ddc20f Merge remote-tracking branch 'origin/main' into dev 2023-06-19 17:17:07 -03:00
Gabriel Luiz Freitas Almeida
825f2798c3 🐛 fix(chat.py): fix node to vertex variable name in stream_build function
 feat(chat.py): add progress logging to stream_build function
The variable node was renamed to vertex to improve semantics and consistency with the naming conventions. Progress logging was added to the stream_build function to provide feedback to the user on the progress of the build process.

🐛 fix(index.tsx): fix typo in setSuccessData function call
 feat(index.tsx): add success logging to handleBuild function
A typo in the setSuccessData function call was fixed. Success logging was added to the handleBuild function to provide feedback to the user on the success of the build process.
2023-06-19 16:03:25 -03:00
Gabriel Luiz Freitas Almeida
f180fa6f26 🐛 fix(process.py): change input parameter type hint to include Path type
The input parameter now accepts a Path object in addition to a string or dictionary. This improves the flexibility of the function and allows for easier file handling.
2023-06-19 14:25:10 -03:00
Gabriel Luiz Freitas Almeida
11185affdd 🐛 fix(process.py): refactor fix_memory_inputs function to improve readability and reduce nesting
The fix_memory_inputs function was refactored to reduce nesting and improve readability. The function now checks if the langchain_object has a memory attribute and if it is not None before proceeding. The try-except block was also refactored to reduce nesting.
2023-06-19 12:02:15 -03:00
Gabriel Luiz Freitas Almeida
83c28dcabe 🔨 refactor(process.py): refactor process_tweaks function to improve readability and maintainability
 feat(process.py): add input validation to process_tweaks function
The process_tweaks function has been refactored to improve readability and maintainability. The apply_tweaks function has been added to apply the tweaks to the node. The validate_input function has been added to validate the input parameters. The process_tweaks function now raises a ValueError if the input is not in the expected format.
2023-06-19 11:59:34 -03:00
Gabriel Luiz Freitas Almeida
6886828ddd 🔀 refactor(process.py): change load_flow_from_json function signature to accept either a JSON file path or a JSON object
🔀 refactor(base.py): import Chain from langchain.chains.base instead of importing it from langflow.graph.vertex.types
🔀 refactor(process.py): remove print statement from process_tweaks function
🔀 refactor(process.py): change load_flow_from_json function signature to accept optional tweaks parameter
🔀 refactor(process.py): change return type of build method in Graph class from List[Vertex] to Chain
🧪 test(loading.py): add test case for loading a flow from a JSON file and applying tweaks
🧪 test(loading.py): remove unused import statement
The import statement for Chain in base.py is now more explicit and imports it from langchain.chains.base instead of importing it from langflow.graph.vertex.types. The load_flow_from_json function in process.py now accepts either a JSON file path or a JSON object. The print statement in process_tweaks function has been removed. The load_flow_from_json function in process.py now accepts an optional tweaks parameter. The return type of the build method in the Graph class has been changed from List[Vertex] to Chain. A new test case has been added to loading.py to test loading a flow from a JSON file and applying tweaks. An unused import statement has been removed from loading.py.
2023-06-19 11:36:43 -03:00
Gabriel Luiz Freitas Almeida
e01993b7f1 🐛 fix(__main__.py): add support for running Langflow on Windows
 feat(__main__.py): add support for running Langflow on MacOS and Linux using gunicorn
The changes add support for running Langflow on Windows by using uvicorn instead of gunicorn. This is because Windows doesn't support gunicorn. The changes also add support for running Langflow on MacOS and Linux using gunicorn. This is because MacOS requires an env variable to be set to use gunicorn.
2023-06-19 09:55:29 -03:00
Gabriel Luiz Freitas Almeida
b93d5020b3 🐛 fix(process.py): caching objects does not depend on is_first_message anymore 2023-06-17 13:34:35 -03:00
Gabriel Luiz Freitas Almeida
3a324ed45a Merge remote-tracking branch 'origin/main' into dev 2023-06-16 19:28:47 -03:00
Gabriel Luiz Freitas Almeida
fee54b817b 🐛 fix(process.py): fix conditional statement to check if "nodes" is in graph_data
The conditional statement was checking if "nodes" is in "graph_data['data']" instead of checking if "nodes" is in "graph_data". This fix ensures that the correct data is processed and avoids potential errors.
2023-06-16 19:06:46 -03:00
Gabriel Luiz Freitas Almeida
9ff68eef82 🔥 chore(main.py): remove unnecessary newline at the beginning of the file
The only change in this commit is the removal of an unnecessary newline at the beginning of the file. This improves the code's readability and consistency.
2023-06-16 19:01:41 -03:00
Gabriel Luiz Freitas Almeida
b06e7a058a 🐛 fix(chat.py): add type hint to flow_data_store variable
🔥 chore(main.py): remove unused imports and variables
The `flow_data_store` variable in `chat.py` was missing a type hint, which was added to improve code readability and maintainability. In `main.py`, unused imports and variables were removed to improve code cleanliness.
2023-06-16 18:52:55 -03:00
Gabriel Luiz Freitas Almeida
bf621c78b4 🐛 fix(__main__.py): fix issue where app was not serving the index.html file when a 404 error occurred
 feat(main.py): remove static_path argument from create_app function
The fix to the issue where the app was not serving the index.html file when a 404 error occurred was done by adding an exception handler to the app that returns the index.html file when a 404 error occurs. The create_app function was modified to remove the static_path argument as it was not being used in the function.
2023-06-16 18:36:06 -03:00
Gabriel Luiz Freitas Almeida
319a57eb19 🐛 fix(__main__.py): check if port is in use and get a free port if it is
 feat(__main__.py): add support for health check endpoint and use it to check server status
The `serve` function now checks if the specified port is in use and gets a free port if it is. This ensures that the server can run on a free port and avoids conflicts with other running applications. The `serve` function also now uses a health check endpoint to check the status of the server. The `setup_static_files` function now takes a `Path` object instead of a string for the static files directory. The `create_app` function now takes a `Path` object instead of a string for the static files directory.
2023-06-16 17:39:52 -03:00
Gabriel Luiz Freitas Almeida
b476d0dd74 🐛 fix(endpoints.py): add try-except block when processing tweaks to catch and log exceptions
🐛 fix(process.py): fix KeyError when processing tweaks on graph_data with missing "data" key
The try-except block added in endpoints.py catches any exceptions that occur when processing tweaks and logs them to the logger. This helps with debugging and identifying issues with the processing of tweaks. In process.py, a KeyError was fixed by checking if the "data" key exists in the graph_data dictionary before accessing the "nodes" key.
2023-06-16 16:35:49 -03:00
gustavoschaedler
ceb6fda4c6 Tests fix 2023-06-16 19:47:35 +01:00
Gabriel Luiz Freitas Almeida
1f135d09ec 🐛 fix(custom.py): handle case where vectorstoreroutertoolkit is already a list
The constructor of VectorStoreRouterAgent expects a non-list object for vectorstoreroutertoolkit. However, in some cases, vectorstoreroutertoolkit is already a list. This commit fixes the issue by checking if vectorstoreroutertoolkit is a list and using it directly if it is.
2023-06-16 15:41:14 -03:00
Gabriel Luiz Freitas Almeida
deb056df32 feat(chat.py): use LRUCache from cachetools to limit the size of flow_data_store
The cachetools package is added as a dependency to improve caching. In chat.py, a ValueError is raised if no ID is provided in init_build to prevent errors. The flow_data_store dictionary is replaced with an LRUCache from cachetools to limit the size of the cache to 10 items. This improves performance by reducing the memory usage of the application.
📦 chore(pyproject.toml): add cachetools dependency to improve caching
🐛 fix(chat.py): raise ValueError if no ID is provided in init_build
2023-06-16 15:07:39 -03:00
Gabriel Luiz Freitas Almeida
f42830ca47 🔨 refactor(endpoints.py): remove unused get_flow_from_token function and HTTPBearer import
🐛 fix(endpoints.py): add check for flow data before processing
🔨 refactor(process.py): add type hints to process_tweaks function
The get_flow_from_token function and HTTPBearer import are removed as they are not used in the code. A check for flow data is added before processing to avoid errors when the flow data is None. The process_tweaks function is updated to include type hints for the graph_data and tweaks parameters.
2023-06-16 14:56:00 -03:00
Gabriel Luiz Freitas Almeida
2bd51c6104 🔥 refactor(utils.py): remove unused functions save_cache and load_cache
The functions save_cache and load_cache are not used in the codebase and can be safely removed to improve code readability and maintainability.
2023-06-16 14:31:16 -03:00
Gabriel Luiz Freitas Almeida
a099fd05ad 🔥 refactor(cache/base.py): remove empty pass statement in BaseCache abstract method
🔥 refactor(utils/validate.py): remove try-except block in create_function method
The pass statement in the BaseCache abstract method is redundant and can be removed. Similarly, the try-except block in the create_function method is not necessary as the exception is being suppressed.
2023-06-16 14:22:14 -03:00
Gabriel Luiz Freitas Almeida
5568db9f1b 🔥 refactor(base.py): remove empty pass statements in BaseCache abstract class methods
The pass statements in the BaseCache abstract class methods are redundant and can be removed as they do not add any value to the code.
2023-06-16 13:58:23 -03:00
Gabriel Luiz Freitas Almeida
d897de48f9 🎨 style(agents.py): change name and display_name of InitializeAgentNode to improve readability
The name and display_name of the InitializeAgentNode class have been changed to "AgentInitializer" and "AgentInitializer" respectively. This improves the readability of the code and makes it easier to understand the purpose of the class.
2023-06-16 12:24:41 -03:00
Gabriel Luiz Freitas Almeida
fb53522311 🚀 chore(custom.py): rename "initialize_agent" to "AgentInitializer" in CUSTOM_AGENTS dictionary
The "initialize_agent" key in the CUSTOM_AGENTS dictionary has been renamed to "AgentInitializer" to improve naming consistency with the other agents in the dictionary.
2023-06-16 12:13:04 -03:00
gustavoschaedler
92a285bb2e Adjusted the name of the agent AgentInitializer to initialize_agent temporarily to fix a bug in the frontendnode 2023-06-16 15:38:20 +01:00
Gabriel Luiz Freitas Almeida
4faa1e7240 🔨 refactor(base.py): add LLMCheckerChain to from_method_nodes dictionary
🔨 refactor(chains.py): comment out unused code block
The `from_method_nodes` dictionary in `base.py` has been updated to include the `LLMCheckerChain` class. This allows the `from_llm` method to be called on the `LLMCheckerChain` class.

The code block in `chains.py` that deals with the `PromptTemplate` field type has been commented out as it is currently unused. This is to prevent confusion and to keep the codebase clean.
2023-06-16 08:55:38 -03:00
Gabriel Luiz Freitas Almeida
12db6f52fb 🐛 fix(main.py): add a custom 404 handler to return the index.html file when a 404 error occurs
The create_app function now accepts a static_path parameter that defaults to "static". The setup_static_files function is created to mount the static files directory to the app. A custom 404 handler is added to the app to return the index.html file when a 404 error occurs. This allows the app to serve static files such as HTML, CSS, and JavaScript files.
🚀 feat(__main__.py, main.py): add support for serving static files
 feat(__main__.py): create a setup_static_files function to mount the static files directory to the app
2023-06-15 20:48:01 -03:00
Gabriel Luiz Freitas Almeida
2addbf2e0c 🔧 chore(settings.py): change save_api_keys to remove_api_keys to improve semantics
The `save_api_keys` variable has been renamed to `remove_api_keys` to improve the semantics of the code. The new variable name better reflects the functionality of the code, which is to remove API keys from the projects saved in the database.
🔧 chore(__main__.py): change save_api_keys to remove_api_keys to improve semantics
2023-06-15 19:29:29 -03:00
Gabriel Luiz Freitas Almeida
e76917b53e 🔧 refactor(__main__.py): refactor update_settings function to accept save_api_keys parameter
 feat(__main__.py): add save_api_keys parameter to serve command to allow users to save API keys in their projects
The update_settings function now accepts a save_api_keys parameter, which allows the user to specify whether or not to save API keys in their projects. The serve command now has a save_api_keys parameter that defaults to True, allowing users to save API keys in their projects. This feature improves the user experience by allowing them to save API keys for future use.
2023-06-15 18:22:12 -03:00
Gabriel Luiz Freitas Almeida
7d61e3dd16 🆕 feat(utils.py): add function to remove API keys from flow data
This commit adds a new function called `remove_api_keys` to the `utils.py` file. The function takes in a dictionary representing a flow and removes any API keys from the flow data. The function iterates through each node in the flow and checks if the node contains any API keys. If an API key is found, the function sets the value of the key to `None`. This function is useful for removing sensitive information from flow data before it is stored or transmitted.
2023-06-15 18:16:23 -03:00
Gabriel Luiz Freitas Almeida
da24690bf7 🔒 chore(flows.py): add support for removing API keys from flow data if save_api_keys setting is False
The `remove_api_keys` function is now called on the `flow_data` dictionary if the `save_api_keys` setting is False. This ensures that sensitive information is not saved in the database.
2023-06-15 18:16:02 -03:00
Gabriel Luiz Freitas Almeida
99ce643010 🐛 fix(llms.py): add condition to show password field for 'tokens' field name
The condition to show the password field was not working for the 'tokens' field name. The condition has been updated to include 'tokens' in the field name and show the password field.
2023-06-15 18:14:48 -03:00
Gabriel Luiz Freitas Almeida
265646ded3 🐛 fix(chat.py): change the prefix of the error message to 'data' to fix the server response
The error message prefix was changed from 'data' to 'error' to fix the server response.
2023-06-15 15:08:38 -03:00
Gabriel Luiz Freitas Almeida
03076b3577 🔨 refactor(flows.py): change response model of update_flow endpoint to FlowRead
🔨 refactor(parameterComponent): remove unused imports and refactor onChange function to handleOnNewValue
 feat(tabsContext): add tabsState and setTabsState to TabsContextType and TabsProvider
🔨 refactor(flowSettingsModal): refactor handleSaveFlow function to update flow and setTabsState with isPending false
The update_flow endpoint now returns a FlowRead response model instead of FlowReadWithStyle. The parameterComponent file has been refactored to remove unused imports and to use a handleOnNewValue function to handle onChange events. The TabsContextType and TabsProvider have been updated to include tabsState and setTabsState. The flowSettingsModal has been refactored to update the flow and setTabsState with isPending false.

🔨 refactor(extraSidebarComponent): add tabsState and setTabsState to TabsContextType
🐛 fix(extraSidebarComponent): disable save button when flow is not pending
🐛 fix(extraSidebarComponent): update flow state after saving
The TabsContextType now includes tabsState and setTabsState to allow for the management of the state of each tab. The save button is now disabled when the flow is not pending. The flow state is now updated after saving to reflect the changes made.
2023-06-15 15:08:37 -03:00
Gabriel Luiz Freitas Almeida
5ce9fa17cf 📝 docs(chains.py): update description of CombineDocsChainNode
The description of CombineDocsChainNode was updated to reflect the actual functionality of the node. The node is now used to load a question answering chain instead of constructing a chain from combined documents.
2023-06-15 11:40:29 -03:00
Gabriel Luiz Freitas Almeida
61a6710adf 🔒 chore(llms.py): set password field to False for fields not containing 'key' or 'token' in their name
The openai_api_version field value is no longer set as it is not needed. The password field is now set to False for fields not containing 'key' or 'token' in their name to improve security.
🐛 fix(llms.py): remove setting of openai_api_version field value
2023-06-15 09:45:15 -03:00
Gabriel Luiz Freitas Almeida
a23121aa54 🐛 fix(chat.py): yield error message when an exception occurs during stream_build
🔧 chore(base.py): fix typo in docstring
The fix in chat.py ensures that an error message is yielded when an exception occurs during stream_build. This helps to provide more information to the client-side when an error occurs. The typo in base.py's docstring is fixed to improve readability.
2023-06-15 07:44:11 -03:00
Gabriel Luiz Freitas Almeida
3920eb50d6 Merge remote-tracking branch 'origin/validation_fix' into db 2023-06-15 07:37:26 -03:00
Rodrigo Nader
fd59bd77b3 Refactor SQL agent and related nodes
- Rename `VectorStoreAgent` to `Vector store agent` in `custom.py`
- Replace "Construct a sql agent from an LLM and tools." with "Construct an SQL agent from an LLM and tools." in `custom.py`
- Update descriptions of `SQLAgentNode`, `TimeTravelGuideChainNode`, `CombineDocsChainNode`, and `ToolNode` in related files
- Increase width of `ExtraSidebarComponent` container in `index.tsx` from 52 to 56
2023-06-14 23:54:39 -03:00
anovazzi1
bba2942d37 format code 2023-06-14 19:33:21 -03:00
Gabriel Luiz Freitas Almeida
56b16dac60 🔨 refactor(documentloaders.py): move build_template function outside of DocumentLoaderFrontNode class
The build_template function is now outside of the DocumentLoaderFrontNode class to improve code organization and make it more modular. This change also makes it easier to reuse the function in other parts of the codebase.
2023-06-14 17:15:54 -03:00
Gabriel Luiz Freitas Almeida
010c1b7b50 Merge remote-tracking branch 'origin/NewId' into db 2023-06-14 14:56:46 -03:00