-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: get messages from messages table for the playground #3874
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…session management.
…to _build_vertex function.
…re updating message text in the database
…nd assign the message value to ensure consistency and avoid potential bugs
ogabrielluiz
approved these changes
Oct 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lucaseduoli
approved these changes
Oct 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
… and 'input_value' keys
…6.3.1 for bug fixes or new features 🔧 (duckduckgo.spec.ts): refactor test to handle multiple possible outcomes when waiting for selectors and improve readability
…content on code modal
diogocabral
pushed a commit
to headlinevc/langflow
that referenced
this pull request
Nov 26, 2024
…w-ai#3874) * refactor: Update MessageBase text attribute based on isinstance check. * feat: Add update_message function to update a message in the database. * refactor(chat): Update imports and remove unnecessary config method in ChatComponent. * refactor: Add stream_message method to ChatComponent. * refactor: Update method call in ChatOutput component. * feat: Add callback function to custom component and update build_results signature. * feat: Add callback parameter to instantiate_class function. * feat(graph): Add callback functions for sync and async operations. * feat: Add callback function support to vertex build process. * feat: Add handling for added message in InterfaceVertex class. * feat: Add callback support to Graph methods. * feat(chat): Add callback function to build_vertices function. * refactor: Simplify update_message function and use session_scope for session management. * fix: Call set_callback method if available on custom component. * refactor(chat): Update chat message chunk handling and ID conversion. * feat: Add null check before setting cache in build_vertex_stream function. * refactor: Fix send_event_wrapper function and add callback parameter to _build_vertex function. * refactor: Simplify conditional statement and import order in ChatOutput. * [autofix.ci] apply automated fixes * refactor: move log method to Component class. * refactor: Simplify CallbackFunction definition. * feat: Initialize _current_output attribute in Component class. * feat: store current output name in custom component during processing. * feat: Add current output and component ID to log data. * fix: Add condition to check current output before invoking callback. * refactor: Update callback to log_callback in graph methods. * feat: Add test for callback graph execution with log messages. * update projects * fix(chat.py): fix condition to check if message text is a string before updating message text in the database * refactor(ChatOutput.py): update ChatOutput class to correctly store and assign the message value to ensure consistency and avoid potential bugs * refactor(chat.py): update return type of store_message method to return a single Message object instead of a list of Messages refactor(chat.py): update logic to correctly handle updating and returning a single stored message object instead of a list of messages * update starter projects * refactor(component.py): update type hint for name parameter in log method to be more explicit * feat: Add EventManager class for managing events and event registration * refactor: Update log_callback to event_manager in custom component classes * refactor(component.py): rename _log_callback to _event_manager and update method call to on_log for better clarity and consistency * refactor(chat.py): rename _log_callback method to _event_manager.on_token for clarity and consistency in method naming * refactor: Rename log_callback to event_manager for clarity and consistency * refactor: Update Vertex class to use EventManager instead of log_callback for better clarity and consistency * refactor: update build_flow to use EventManager * refactor: Update EventManager class to use Protocol for event callbacks * if event_type is not passed, it uses the default send_event * Add method to register event functions in EventManager - Introduced `register_event_function` method to allow passing custom event functions. - Updated `noop` method to accept `event_type` parameter. - Adjusted `__getattr__` to return `EventCallback` type. * update test_callback_graph * Add unit tests for EventManager in test_event_manager.py - Added tests for event registration, including default event type, empty string names, and specific event types. - Added tests for custom event functions and unregistered event access. - Added tests for event sending, including JSON formatting, empty data, and large payloads. - Added tests for handling JSON serialization errors and the noop function. * feat: Add callback function support to vertex build process. * feat: Add callback support to Graph methods. * feat(chat): Add callback function to build_vertices function. * [autofix.ci] apply automated fixes * refactor: Update callback to log_callback in graph methods. * fetching data from messages and builds at the same time, need to remove duplicates * refactor: Sort chat history by timestamp in ChatView component * fix: update serialization and improve error handling (langflow-ai#3516) * feat(utils): add support for V1BaseModel in serialize_field Add support for V1BaseModel instances in the serialize_field function by checking for a "to_json" method. If the method is not present, return the attribute values as a dictionary. * refactor: Update field serializer function and error handling in build_flow function * remove use memo to prevent bugs * feat: add updateMessagePartial method to MessagesStoreType * feat: update message partially in MessagesStoreType This commit adds the `updateMessagePartial` method to the `MessagesStoreType` in `messagesStore.ts`. This method allows updating a specific message by merging the changes with the existing message object. * feat: add log callback for start message in ChatComponent * feat: update log_callback name * feat: add log_callback for message in ChatComponent that are not streaming * refactor: remove console.log statement in buildFlowVertices function * refactor: store message in ChatInput after updating flow_id This commit refactors the `ChatInput` component by moving the logic to store the message after updating the `flow_id` property. This ensures that the message is properly stored in the correct flow. The previous implementation had the logic to store the message before updating the `flow_id`, which could lead to incorrect storage of messages. This change improves the reliability and accuracy of message storage in the `ChatInput` component. * refactor: move message storage logic in ChatInput after updating flow_id * refactor: update ChatComponent to use stored_message.id instead of self.graph.flow_id Update the `ChatComponent` class in `chat.py` to use the `stored_message.id` property instead of `self.graph.flow_id` when logging a message. This ensures that the correct message ID is used for logging purposes. The previous implementation used the flow ID, which could lead to incorrect logging. This change improves the accuracy of message logging in the `ChatComponent`. * refactor: remove unused code and console.log statements * raw: temp serializer fix * streaming working but the message comes in one shot * refactor: optimize message update in useMessagesStore Improve the efficiency of updating messages in the `useMessagesStore` function of `messagesStore.ts`. Instead of iterating through the entire message list, this refactor searches for the message to update by iterating backwards from the end. This approach allows for faster message retrieval and update. The code has been modified to use a for loop and break out of the loop once the message is found. This change enhances the performance of the message update process. * Refactor `serialize_flow_id` method to correctly handle UUID serialization in `message.py` * Refactor `send_event` method to use `jsonable_encoder` for data serialization * refactor: optimize message update in useMessagesStore * streaming working with timeout * refactor: update buildUtils.ts to use data instead of data.data in addMessage function * version with reactState for chatHistory * refactor: update on_message method in ChatComponent * refactor: update on_message method in ChatComponent * refactor: Remove unused dependency in package-lock.json * Refactor chatView component and add hiddenSession prop * Refactor chatView component and update hiddenSessions prop * Refactor chatView component to use visibleSessions prop instead of hiddenSessions * Refactor IOModal component to remove redundant code * Refactor chatView component to include focusChat prop * Refactor chatView component to include focusChat prop and trigger focus on chat when new session is set * Refactor IOModal component to update visible sessions when new session is added * feat: Add session parameter to buildFlowVertices function * feat: Add someFlowTemplateFields function Add the someFlowTemplateFields function to the reactflowUtils module. This function checks if any of the nodes in the provided array have template fields that pass a given validation function. * feat: Add session parameter to buildFlowVertices function * feat: Add session parameter to buildFlowVertices function * update Session logic on ioModal * Refactor ChatView component: Remove unused eraser button The eraser button in the ChatView component was removed as it was not being used and served no purpose. This change improves code cleanliness and removes unnecessary code. * Refactor Vertex class: Inject session_id if provided in inputs * Refactor build_flow function: Set default session if inputs are empty * Refactor InputValueRequest schema: Add session parameter * Refactor IOModal component: Update session logic * Refactor buildFlowVertices function: Update input handling * Refactor MessagesStoreType in zustand/messages/index.ts: Remove unused columns property and setColumns method * Refactor MessagesStoreType: Remove unused columns property and setColumns method * Refactor SessionView component: Update columns extraction logic * Refactor ChatView component: Remove unused variables * Refactor useGetMessagesQuery: Remove unused setColumns method * Refactor RenderIcons component: Set default value for filteredShortcut prop to prevent bug * create edit message component for chat view * Refactor useUpdateMessage: Add refetch option to trigger query refetch * Refactor IOModal component: Remove unused variables and update useGetMessagesQuery * Refactor ChatView component: Add session ID to message object * update chat message to handle message edit * update types * fix: Update API call to send entire message object * Refactor EditMessageField component: Add timeout to onBlur event * Refactor EditMessageField component: Update layout of edit message field * create migration * add fields to data table * feat: Add "edit" flag to message_dict in update_message API endpoint * Refactor EditMessageField component: Improve onBlur event handling and add button click flag * Refactor code to include "edit" flag in message types * feat: Add EditMessageButton component for editing chat messages * Refactor ChatMessage component: Add EditMessageButton and improve layout * fix: Add refetch query for current flow messages not all flows * Refactor ChatMessage component: Add ShadTooltip for EditMessageButton * add info into edit message field * fix: migrate * fix running chat input directly from the flow * [autofix.ci] apply automated fixes * fix edit flag * Refactor IOModal component to generate a unique session ID based on the current date and time * [autofix.ci] apply automated fixes * Refactor IOModal component to improve session management and interaction * [autofix.ci] apply automated fixes * Refactor sessionSelector component to improve session management and interaction * chore: Refactor sessionSelector component to improve session management and interaction * [autofix.ci] apply automated fixes * create mutation to handle session rename * refactor: Rename useUpdateSession to useUpdateSessionName for clarity * [autofix.ci] apply automated fixes * Refactor sessionSelector component for improved session management and interaction * Refactor sessionSelector component to update visible session on session name change * [autofix.ci] apply automated fixes * add message related events back * chore: Add console logs for debugging in buildFlowVertices function * Refactor IOModal component to update tab trigger label from "Memories" to "Chat" * improve edit name feature * Refactor IOModal component button label to "New Chat" * Refactor sessionSelector component to improve session management and interaction * Refactor IOModal component to remove unused code and improve session management * fix typing error * fix run chat input on component level * prevent toogle visibility on session menu * fix bug on rename session while in table view mode * chore: Update setSelectedView prop type in sessionSelector component * add first test version not working yet * fix bug for renaming and deleting session * refactor: Update sessionSelector component to handle session changes * improve test * fix rename session multiple session bugs * change visible session from array to string * chore: Update editMessageField component to include margin-right for text span * [autofix.ci] apply automated fixes * Update down_revision in Alembic migration script * Refactor IOModal component to simplify session visibility handling * Fix comparison operator for filtering error messages in memory.py * Refactor ChatInput to conditionally store and update messages * Refactor JSON formatting for improved readability in starter projects * Add type casting for message_text and import cast from typing module * Refactor input handling to use direct dictionary access for 'session' and 'input_value' keys * Allow `update_message` to accept `str` type for `message_id` parameter * ⬆️ (pyproject.toml): upgrade duckduckgo-search dependency to version 6.3.1 for bug fixes or new features 🔧 (duckduckgo.spec.ts): refactor test to handle multiple possible outcomes when waiting for selectors and improve readability * Refactor test file: generalBugs-shard-0.spec.ts * Refactor test file: freeze.spec.ts * Refactor test files: update element selectors and actions * Refactor test file: chatInputOutput.spec.ts * [autofix.ci] apply automated fixes * Refactor chatMessage component to handle different types of children content on code modal * [autofix.ci] apply automated fixes --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com> Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
lgtm
This PR has been approved by a maintainer
size:XXL
This PR changes 1000+ lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this pull request changes the data source from the playground chat interface, adding the hability to edit messages, and a new streaming structure