Commit graph

1,812 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
585aeeab6e 🔥 refactor(base.py): remove unnecessary build method call in Graph class
The build method call in the for loop of the build_vertices method is unnecessary as the vertices are already sorted and built in the topological_sort method. The yield from statement is used to return the sorted vertices.
2023-06-12 13:05:27 -03:00
Gabriel Luiz Freitas Almeida
64397d2830 🔨 refactor(buildTrigger): change allNodesValid to validationResults array and add finished variable to improve readability
🚀 feat(buildTrigger): add waiting for stream to finish and return validation results for each node
The allNodesValid variable has been changed to a validationResults array to store the validation results for each node. A finished variable has been added to improve readability and to wait for the stream to finish. The function now returns an array of validation results for each node.
2023-06-12 13:05:02 -03:00
Gabriel Luiz Freitas Almeida
baeadf018d feat(chat.py): improve SSE response by adding node id and valid flag
The changes in this commit handle exceptions that may occur when creating a streaming response. The try-except block ensures that any exceptions are caught and an appropriate response is returned. Additionally, the SSE response has been improved by adding a valid flag and node id to the response. This provides more information to the client about the status of the node build and allows for better error handling.
🐛 fix(chat.py): handle exceptions when creating a streaming response
2023-06-12 13:03:46 -03:00
Gabriel Luiz Freitas Almeida
806d815a10 feat(index.tsx): add support for streaming build process using EventSource
The commented out code for the /build/{client_id} endpoint has been removed as it is no longer needed. The new implementation uses the /build/init endpoint to initiate the build process and then establishes an SSE connection using EventSource to stream the build process. This allows for a more efficient and responsive build process as the client can receive updates in real-time.
🔥 chore(chat.py, index.tsx): remove commented out code for /build/{client_id} endpoint
2023-06-12 11:49:59 -03:00
Gabriel Luiz Freitas Almeida
76f1aa8adf 🐛 fix(chat.py): add check for client_id in in_memory_cache before handling websocket
 feat(chat.py): add support for storing graph data and returning a unique session ID for building langchain object
 feat(chat.py): add support for streaming the build process based on stored flow data
The fix adds a check for the client_id in the in_memory_cache before handling the websocket. This ensures that the flow has been built before sending messages.

The first feature adds support for storing graph data and returning a unique session ID for building the langchain object. This allows the user to build the flow and then send messages.

The second feature adds support for streaming the build process based on stored flow data. This allows the user to see the progress of the build process.
2023-06-12 11:49:24 -03:00
Gabriel Luiz Freitas Almeida
bcff7a42eb 🔥 chore(test_websocket.py): remove unused import
The import statement for TestClient is unused and can be safely removed.
2023-06-12 10:44:03 -03:00
Gabriel Luiz Freitas Almeida
5fe1435f9e 🔥 chore(test_websocket.py): remove unused imports
The imports for json and patch were not used in the file and were removed to improve code readability and maintainability.
2023-06-12 09:55:48 -03:00
Gabriel Luiz Freitas Almeida
4485f55d53 🔥 chore(test_websocket.py): remove outdated test_chat_history test
The test_chat_history test is outdated and no longer works with the current implementation of the application. It has been removed to avoid confusion and to keep the test suite clean.
2023-06-12 09:51:32 -03:00
Gabriel Luiz Freitas Almeida
6b57e20504 formatting 2023-06-12 09:45:28 -03:00
Gabriel Luiz Freitas Almeida
4f4a0ff4c7 🔨 refactor(chatComponent): refactor handleBuild function to use async/await and extract constants to improve readability
🐛 fix(chatComponent): fix issue with progressEvent not being properly destructured
🚀 feat(chatComponent): add minimum loading time to improve user experience
The handleBuild function was refactored to use async/await and constants were extracted to improve readability. The issue with progressEvent not being properly destructured was fixed. A minimum loading time was added to improve user experience by ensuring that the loading spinner is displayed for at least a certain amount of time.
2023-06-12 09:44:12 -03:00
Gabriel Luiz Freitas Almeida
42d11894a2 🔀 chore(base.py): change return type of generator_build method from List[Vertex] to Generator
The return type of the generator_build method has been changed from List[Vertex] to Generator to improve the semantics of the method. The method now yields each vertex in the graph instead of returning a list of vertices.
2023-06-12 09:35:19 -03:00
Gabriel Luiz Freitas Almeida
a15cc30da5 🔥 refactor(manager.py): remove unused imports and dependencies
🔥 refactor(utils.py): remove unused imports and dependencies
The changes remove unused imports and dependencies from the codebase, which improves the code's readability and maintainability.
2023-06-12 09:33:54 -03:00
Gabriel Luiz Freitas Almeida
25f22ae88c 🔇 chore(frontend): comment out console.log statements
The console.log statements were commented out in the tabsContext.tsx, EditNodeModal/index.tsx, NodeToolbarComponent/index.tsx, and FlowPage/index.tsx files to remove unnecessary logging in the console.
2023-06-12 09:33:03 -03:00
Gabriel Luiz Freitas Almeida
68288be80e feat (GenericNode): replace validation with SSE validation 2023-06-12 09:31:43 -03:00
Gabriel Luiz Freitas Almeida
eaae1dda27 feat(chatComponent): add SSE context to update data in real-time
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
2023-06-12 09:31:01 -03:00
Gabriel Luiz Freitas Almeida
42d5a501bb 🚀 feat(App.tsx): add SSEProvider to App component
🎉 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.
2023-06-12 09:30:47 -03:00
Gabriel Luiz Freitas Almeida
036818e9b9 🔧 refactor(chat.py): rename post_build to stream_build to improve semantics
🐛 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.
2023-06-12 09:30:20 -03:00
Gabriel Luiz Freitas Almeida
273f452f7b 🔧 chore(chat.py): add SSE support to post_build endpoint
 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.
2023-06-12 07:50:00 -03:00
Gabriel Luiz Freitas Almeida
76a49c8663 🐛 fix(manager.py): change status parameter type from status to int in close_connection method
🔥 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.
2023-06-12 07:49:49 -03:00
Gabriel Luiz Freitas Almeida
9ebd02e331 🚀 feat(base.py): add topological_sort method to perform a topological sort of the vertices in the graph
🚀 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.
2023-06-12 07:49:35 -03:00
Gabriel Luiz Freitas Almeida
f88b14f33d 🚀 feat(chatComponent): add build trigger component to allow users to build a flow
 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.
2023-06-11 18:09:17 -03:00
Gabriel Luiz Freitas Almeida
2c0a9aee95 🚸 chore(chatTrigger): add error message when chat is triggered before flow is built
 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.
2023-06-11 18:08:52 -03:00
Gabriel Luiz Freitas Almeida
395af24101 🚀 chore(vite.config.ts): add build route to apiRoutes array
The build route was added to the apiRoutes array to allow the frontend to access the build files.
2023-06-11 18:08:35 -03:00
Gabriel Luiz Freitas Almeida
f2e4a93df5 🐛 fix(base.py): remove unused import of logger
🎨 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.
2023-06-11 18:08:20 -03:00
Gabriel Luiz Freitas Almeida
ccf9477b7f 🐛 fix(manager.py): add check for langchain object in process_message to avoid errors
 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.
2023-06-11 18:08:01 -03:00
Gabriel Luiz Freitas Almeida
dacc90d901 🐛 fix(cache/manager.py): change CACHE variable to _cache to follow naming conventions
 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.
2023-06-11 18:07:45 -03:00
Gabriel Luiz Freitas Almeida
02163cf775 feat(flow.py): add InMemoryCache class to implement an in-memory cache with LRU eviction policy
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.
2023-06-11 18:07:28 -03:00
Gabriel Luiz Freitas Almeida
a27e5d58dd 🔨 refactor(base.py): refactor BaseCache class to use abstract 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__.
2023-06-11 18:07:17 -03:00
Gabriel Luiz Freitas Almeida
bdbc46f01d 🐛 fix(chat.py): add exception handling to post_build endpoint
 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.
2023-06-11 18:06:57 -03:00
Gabriel Luiz Freitas Almeida
efbdd6fee7 🚀 feat(langflow): add version endpoint to API
🐛 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.
2023-06-11 12:48:06 -03:00
Gabriel Luiz Freitas Almeida
0eaa86c5ca 🔧 chore(__main__.py): add support for loading environment variables from a .env file
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.
2023-06-11 11:14:43 -03:00
Gabriel Luiz Freitas Almeida
61207db4da 🐛 fix(App.tsx): change fetch URL to relative path to fix incorrect API call
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.
2023-06-09 17:17:55 -03:00
Gabriel Luiz Freitas Almeida
bc07766575 🔊 chore(base.py): add logger to Graph class
🐛 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.
2023-06-09 17:08:11 -03:00
Gabriel Luiz Freitas Almeida
bfb4a8e609 🔖 chore(base.py): add display_name field to FrontendNode
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.
2023-06-09 17:08:01 -03:00
Gabriel Luiz Freitas Almeida
c216c78b1b
🚀 feat(langflow): add new Retrieval chains (#456) 2023-06-09 16:25:43 -03:00
Gabriel Luiz Freitas Almeida
fdf24f269b
Merge branch 'dev' into agent_and_qa_chain 2023-06-09 16:25:29 -03:00
Gustavo Schaedler
547e10b374 Remove condition for the execution of make publish, the execution is done by GitHub actions 2023-06-09 20:15:00 +01:00
Gustavo Schaedler
8a08ebdbe7 Remove some commented out code + add condition for the execution of make publish 2023-06-09 20:09:25 +01:00
Alexandre Henrique Pereira Tavares
b02ed92b84
Implemented add_extra_fields method for the documentloaders (#408) 2023-06-09 15:24:56 -03:00
Alexandre Henrique
f7bdb711f1 Merged frontend_node/llm from origin/dev into add_extra_fields_documentloaders 2023-06-09 15:05:56 -03:00
Gabriel Luiz Freitas Almeida
51ecc05563 🐛 fix(vite.config.ts): remove /api/v1 prefix from proxy target URL
 feat(vite.config.ts): add rewrite function to proxy configuration to add /api/v1 prefix to requests
The /api/v1 prefix was removed from the proxy target URL as it was already being added by the rewrite function. The rewrite function was added to the proxy configuration to add the /api/v1 prefix to requests, which is required by the backend API.

Fixes #458
2023-06-09 14:31:09 -03:00
Gabriel Luiz Freitas Almeida
eac5057d4f 🚀 feat(launch.json): add configuration for debugging frontend in Chrome
The new configuration allows for debugging the frontend in Chrome by launching the application on http://localhost:3000/* and setting the webRoot to the frontend directory. This will enable developers to debug the frontend code more efficiently. The existing configuration for debugging the backend has been renamed to "Debug Backend" for better clarity. The "justMyCode" property has been set to true to exclude external libraries from debugging.
2023-06-09 14:19:04 -03:00
Cristhian Zanforlin Lousa
111252fbb2
NodeToolbar Feature Implementation and Dialog UI Migration (#462)
Description
This pull request implements the NodeToolbar feature and migrates the
dialog UI to shadCN. The NodeToolbar introduces three actions:
duplicate, delete, and edit. The edit action allows users to modify the
advanced configuration of the tools. Additionally, this pull request
migrates the dialog UI to shadCN, specifically updating the prompt
dialog, code dialog, export dialog, python functions dialog and
tooltips. These enhancements improve the user experience and provide a
more efficient and modern interface.

Changes Made
Added NodeToolbar component to the application.
Implemented duplicate functionality, allowing users to create copies of
the selected nodes.
Implemented delete functionality, enabling users to remove selected
nodes.
Implemented edit functionality, providing users with the ability to
modify the advanced configuration of the tools.
Migrated the prompt dialog UI to shadCN, improving its appearance and
functionality.
Migrated the code dialog UI to shadCN, enhancing its usability and
aesthetics.
Migrated the export dialog UI to shadCN, resulting in a more streamlined
and intuitive interface.
Migrated the python functions dialog UI to shadCN, ensuring consistency
with the rest of the application's design.
Migrated the headlessUI tooltip to shadCN.

FYI: Need to improve the dialog subtitles texts.
2023-06-09 10:22:36 -03:00
Cristhian Zanforlin Lousa
f18f2f9851 adjust space codacy 2023-06-09 10:10:08 -03:00
Gabriel Luiz Freitas Almeida
f9528591d9
Better serrver start (#461) 2023-06-09 06:47:15 -03:00
Gabriel Luiz Freitas Almeida
eb3421711f
Add advanced parameters to llamacpp node (#465) 2023-06-08 18:40:41 -03:00
Gabriel Luiz Freitas Almeida
2b8333ee95
Merge branch 'dev' into fix_llama 2023-06-08 18:31:39 -03:00
Gabriel Luiz Freitas Almeida
5484a08230 🔖 chore(pyproject.toml): bump up version to 0.0.88
The version number in the pyproject.toml file has been updated from 0.0.87 to 0.0.88. This is a chore commit as it does not introduce any new features or fix any bugs, but it is necessary to keep track of the package version.
2023-06-08 18:15:26 -03:00
Gabriel Luiz Freitas Almeida
a443d0aa83 🔨 refactor(llms.py): extract formatting methods for Azure and Llama fields
This commit extracts the formatting methods for Azure and Llama fields from the `format_field` method to improve readability and maintainability of the code. The `format_azure_field` method formats the fields for Azure, while the `format_llama_field` method formats the fields for Llama. These methods are called conditionally based on the name of the field.
2023-06-08 18:14:03 -03:00
Gabriel Luiz Freitas Almeida
7ed19c739b 🐛 fix(tabsContext.tsx): add try-catch block to handle JSON parsing errors
🐛 fix(API/index.ts): remove duplicate forward slash in API routes
The try-catch block was added to handle JSON parsing errors that may occur when parsing the cookieObject. This ensures that the application does not crash when such errors occur.

The duplicate forward slash in the API routes was removed to ensure that the routes are correctly formed and the API requests are sent to the correct endpoints.
2023-06-08 17:51:06 -03:00