The handleBuild function has been refactored to process data in chunks instead of waiting for the entire response to be received. This improves the performance of the function and allows for real-time updates. The SSE context has been added to update the data in real-time as it is received.
🔨 refactor(chatComponent): refactor handleBuild function to process data in chunks
🎉 feat(SSEContext.tsx): add SSEContext and SSEProvider components to handle server-sent events
The SSEProvider component was added to the App component to provide the SSEContext to the TabsManagerComponent. The SSEContext component was also added to handle server-sent events. The SSEContext component provides a way to update the sseData state and to access the sseData state from any component that uses the useSSE hook.
🐛 fix(chat.py): fix generator_build method to yield node_repr and node_id
✨ feat(chat.py): add valid and id fields to error response to improve error handling
🔧 refactor(manager.py): change logger.exception to logger.error to log exceptions
🔧 refactor(graph/base.py): add logging to generator_build method to improve debugging
🔧 refactor(vertex/base.py): rename cache.base to cache.utils to improve semantics
The post_build method in chat.py was renamed to stream_build to better reflect its functionality. The generator_build method in graph/base.py was fixed to yield node_repr and node_id instead of node._built_object_repr() and node.id. The error response in chat.py now includes valid and id fields to improve error handling. logger.exception in manager.py was changed to logger.error to log exceptions. The generator_build method in graph/base.py now logs the sorted vertices to improve debugging. The cache.base module in vertex/base.py was renamed to cache.utils to better reflect its functionality.
✨ feat(chat.py): add SSE support to post_build endpoint to stream build progress to the client
The post_build endpoint now returns a StreamingResponse object that streams Server-Sent Events (SSE) to the client. This allows the client to receive build progress updates in real-time. The event_stream function is responsible for generating the SSE events and is called by the StreamingResponse object. The SSE events contain information about the build progress, including whether the build was successful or not, the parameters used to build each node, and the node ID. The chat_manager.set_cache method is called to cache the built graph object.
🔥 refactor(manager.py): remove unused build method and rename set_cache to set_client_cache
🚀 chore(manager.py): add async keyword to close_connection method
The close_connection method now accepts an integer as the status parameter instead of a status enum. The build method was removed as it was not being used. The set_cache method was renamed to set_client_cache to improve semantics. The close_connection method was updated to be an async method.
🚀 feat(base.py): add generator_build method to build each node in the graph and yield it
The topological_sort method performs a topological sort of the vertices in the graph, returning a list of vertices in topological order. The generator_build method builds each node in the graph and yields it. These methods are useful for building the graph in a specific order, which is important for certain algorithms that rely on the order of the nodes.
The console.log statements were commented out in the following files:
- src/frontend/src/components/intComponent/index.tsx
- src/frontend/src/contexts/tabsContext.tsx
- src/frontend/src/modals/EditNodeModal/index.tsx
- src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx
- src/frontend/src/pages/FlowPage/index.tsx
The console.log statements were not necessary and were removed to reduce noise in the console.
The validate route was updated to use a regex pattern instead of a string pattern to match all routes that start with "/api/v1/validate/". This change ensures that all routes that match the pattern are correctly routed to the validate endpoint.
✨ feat(chatComponent): add loading animation to build trigger component
The BuildTrigger component is added to the chatComponent to allow users to build a flow. The component is triggered by clicking on a button and sends a POST request to the server to build the flow. A loading animation is added to the component to indicate that the flow is being built. The postBuild function is added to the API controller to handle the POST request.
✨ feat(chatComponent): add BuildTrigger component to check if flow is built before showing ChatTrigger component
The ChatTrigger component now checks if the flow is built before allowing the user to open the chat. If the flow is not built, an error message is displayed instead. The BuildTrigger component is added to check if the flow is built before showing the ChatTrigger component. This improves the user experience by preventing the user from opening the chat before the flow is built.
🎨 refactor(run.py): update import statement for compute_dict_hash, load_cache, and memoize_dict
The import of logger in base.py was not being used, so it was removed to improve code readability. In run.py, the import statement for compute_dict_hash, load_cache, and memoize_dict was updated to reflect the new location of these functions in the cache.utils module. This improves the organization of the code and makes it easier to find the relevant functions.
✨ feat(manager.py): add build method to build langchain object and store it in an in-memory cache
The `process_message` method now checks if the langchain object has been built and stored in the in-memory cache before processing the message. If the object is not found, the connection is closed with an error message. A new `build` method has been added to build the langchain object and store it in an in-memory cache. This method is called before processing any messages.
✨ feat(cache/utils.py): add support for clearing old cache files and memoization of dictionary functions
The CACHE variable in CacheManager class has been renamed to _cache to follow naming conventions. The utils.py module now supports clearing old cache files and memoization of dictionary functions. The clear_old_cache_files function removes old cache files if the number of cache files exceeds the max_cache_size. The memoize_dict decorator memoizes dictionary functions and clears the cache when the clear_cache method is called.
This commit adds a new class InMemoryCache to implement an in-memory cache with a Least Recently Used (LRU) eviction policy. The cache supports setting a maximum size and expiration time for cached items. The cache is thread-safe using a threading Lock. The InMemoryCache class inherits from the BaseCache class and implements the get, set, get_or_set, delete, clear, __contains__, __getitem__, __setitem__, __delitem__, __len__, and __repr__ methods.
This commit refactors the BaseCache class to use abstract methods instead of concrete methods. This makes the class more flexible and allows for different implementations of the cache. The abstract methods include get, set, delete, clear, __contains__, __getitem__, __setitem__, and __delitem__.
✨ feat(cache/__init__.py): add InMemoryCache to exported modules
🔖 refactor(endpoints.py): remove unused import statement
The post_build endpoint in chat.py now has exception handling to catch any errors that may occur during the build process. InMemoryCache is now exported as part of the cache module. The endpoints.py file has been refactored to remove an unused import statement.
🐛 fix(langflow): fix version import error in version endpoint
The version endpoint is added to the API to allow clients to retrieve the version of the Langflow package. The version is obtained using the `metadata.version` function from the `importlib` module. In case the package metadata is not available, an empty string is returned. The version endpoint was previously returning an error due to an import error. The error is fixed by importing the `__version__` variable from the `langflow` module.
✨ feat(App.tsx): add getVersion function to retrieve app version from API
The fetch call to retrieve the app version has been replaced with a call to the getVersion function. This function retrieves the app version from the API. This change improves the code's readability and reduces the amount of code needed to retrieve the app version.
🐛 fix(GenericNode/index.tsx): replace fetch call with postValidateNode function call to validate node
✨ feat(GenericNode/index.tsx): add postValidateNode function to validate node via API
The fetch call to validate the node has been replaced with a call to the postValidateNode function. This function validates the node via the API. This change improves the code's readability and reduces the amount of code needed to validate the node.
🐛 fix(codeAreaModal/index.tsx): replace checkCode function call with postValidateCode function call to validate code
✨ feat(codeAreaModal/index.tsx): add postValidateCode function to validate code via API
The checkCode function call to validate the code has been replaced with a call to the postValidateCode function. This function validates the code via the API. This change improves the code's readability and reduces the amount of code needed to validate the code.
✨ feat(API): add getVersion function to retrieve the version of the API
The API routes have been updated to include the /api/v1/ prefix to improve semantics and avoid conflicts with other routes. The getVersion function has been added to retrieve the version of the API.
The `load_dotenv` function from the `dotenv` package is now used to load environment variables from a `.env` file. This allows for a more flexible configuration of the application as environment variables can be loaded from a file instead of being hardcoded in the code. The `.env` file path can be specified via the `env_file` parameter.
✨ feat(ApiModal): use getPythonApiCode and getCurlCode functions to generate python and curl code
✨ feat(cardComponent): add RenameLabel component to allow renaming of flow name and description
🐛 fix(cardComponent): fix CardDescription height to prevent overflow
The getPythonApiCode, getCurlCode, and getPythonCode functions were refactored into separate functions to improve code readability and maintainability. The ApiModal component now uses the getPythonApiCode and getCurlCode functions to generate the python and curl code. The CardComponent now has a RenameLabel component that allows renaming of the flow name and description. The CardDescription height was also fixed to prevent overflow.
💄 style(cardComponent): update layout of card footer and remove unused code
The background color of the card component has been updated to a lighter shade of blue. The icons used for editing and deleting a flow have been updated to use the Lucide icon library. The layout of the card footer has been updated to align the content to the right and remove unused code.
✨ feat(menuBar): add support for custom emoji and color for each flow
This commit replaces the heroicons with lucide-react icons to improve the consistency of the icon set used in the application. The code has also been refactored to improve readability. Additionally, support for custom emoji and color for each flow has been added to improve the user experience.
The flowName prop has been changed to a flow object to improve semantics and make the code more readable. The cURL code snippet has been added to the API modal to provide an alternative way to interact with the API.
🔨 refactor(ApiModal): change flowName prop to flow object to improve semantics
The tabs trigger border radius has been changed from rounded-sm to rounded-lg to improve the appearance of the tabs. Try-catch blocks have been added to handle errors when processing flow data to prevent the application from breaking. A new function, saveFlowToDatabase, has been added to save new flows to the database. This function is called when a new flow is created, and the ID counter is incremented after the flow is saved. The new flow is then added to the list of flows, and the tab index is set to the new flow.
🎨 style(ui/tabs.tsx): change tabs trigger border radius from rounded-sm to rounded-lg
The graph_data variable was previously assigned to flow_obj.flow, which is incorrect as the flow_obj object does not have a flow attribute. Instead, the correct attribute to use is flow_obj.data.
🔨 refactor(MainPage): remove handleSaveFlow prop from MenuBar component
🔨 refactor(MainPage): export MenuBar component as named export
The axios library is replaced with the fetch API for the getVersion and getHealth functions to reduce the bundle size and improve performance. The handleSaveFlow prop is removed from the MenuBar component as it is not used. The MenuBar component is now exported as a named export to improve code readability and maintainability.
The fetch URL was incorrect and was calling the API with an absolute path instead of a relative path. This caused the API call to fail. The URL has been changed to a relative path to fix the issue.
🐛 fix(base.py): improve error message when invalid payload is received
The logger is added to the Graph class to improve debugging capabilities. The error message when an invalid payload is received is improved to include the keys that were found in the payload. This makes it easier to identify the issue and fix it.
The `display_name` field is added to the `FrontendNode` class to allow for a more user-friendly name to be displayed in the UI. If `display_name` is not set, the `name` field will be used instead.
The new component MenuBar was created to handle the menu bar in the MainPage. It contains all the logic and UI elements related to the menu bar. The component receives props such as activeTab, setRename, rename, flows, tabIndex, and handleSaveFlow. The handleSaveFlow function was moved from the MainPage component to the MenuBar component. The code related to the menu bar was removed from the MainPage component and replaced by the MenuBar component.
🚀 feat(API/index.ts): add getVersion function to fetch API version
🚀 feat(cardComponent/index.tsx): add CardComponent to display flow data
🚀 feat(types/flow/index.ts): add FlowStyleType to represent flow styles
The getVersion function was added to fetch the version of the API. The CardComponent was added to display flow data. The FlowStyleType was added to represent flow styles.