-
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: add new playground events #4280
Merged
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
- Introduce `PlaygroundEvent` base class and specific event types: `MessageEvent`, `ErrorEvent`, `WarningEvent`, `InfoEvent`, and `TokenEvent`. - Implement `ContentBlock` class for flexible content handling. - Add factory functions to create different event types. - Utilize Pydantic for data validation and serialization.
- Introduce `_session_id` attribute in the graph base class. - Implement getter and setter for `session_id` property. - Update chat API to set `session_id` from inputs if available.
- Integrate `create_event_by_type` to generate playground events. - Add try-except block to handle `TypeError` during event creation and log the error using `loguru`. - Raise any other exceptions encountered during event creation.
- Introduced `send_message` method to handle message sending with optional formatting and content blocks. - Implemented `_store_message`, `_send_message_event`, and `_should_stream_message` for message storage and event management. - Added `_update_stored_message` and `_stream_message` to support message streaming and updating. - Included `_handle_async_iterator` and `_process_chunk` for processing message chunks from iterators.
- Introduced `PlaygroundEvent` type to manage different event types such as message, error, warning, info, and token. - Implemented `handlePlaygroundEvent` function to process and update chat history based on event type. - Enhanced file parsing logic to handle empty strings and parsing errors. - Added default values for `background_color` and `text_color` in chat messages.
- Enable new IO modal in feature flags - Update imports and remove unused code in newChatMessage component - Add error icon and error message in ChatMessage component - Update lockChat icon position in newChatView component - Import OctagonAlert icon in styleUtils
Cristhianzl
approved these changes
Nov 4, 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
Cristhianzl
reviewed
Nov 4, 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
.../IOModal/components/chatView/chatInput/components/buttonSendWrapper/newButtonSendWrapper.tsx
Show resolved
Hide resolved
.../IOModal/components/chatView/chatMessage/components/editMessageField/newEditMessageField.tsx
Show resolved
Hide resolved
…ponent.spec.ts, sliderComponent.spec.ts, tableInputComponent.spec.ts, stop-button-playground.spec.ts, generalBugs-shard-7.spec.ts): enable tests that were previously skipped to ensure proper functionality and coverage. Remove outdated comments and update test descriptions for clarity.
diogocabral
pushed a commit
to headlinevc/langflow
that referenced
this pull request
Nov 26, 2024
* 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 * Add new schema for playground events with various event types - Introduce `PlaygroundEvent` base class and specific event types: `MessageEvent`, `ErrorEvent`, `WarningEvent`, `InfoEvent`, and `TokenEvent`. - Implement `ContentBlock` class for flexible content handling. - Add factory functions to create different event types. - Utilize Pydantic for data validation and serialization. * Add PlaygroundEvent to LoggableType in log schema * Add timestamp validation utility to schema utils and refactor Message class to use it * Add custom serialization for datetime and Decimal in data schema * Add session_id handling to graph and chat API - Introduce `_session_id` attribute in the graph base class. - Implement getter and setter for `session_id` property. - Update chat API to set `session_id` from inputs if available. * Add error handling for event creation in EventManager - Integrate `create_event_by_type` to generate playground events. - Add try-except block to handle `TypeError` during event creation and log the error using `loguru`. - Raise any other exceptions encountered during event creation. * Enhance session ID handling in vertex base logic * Add message handling and streaming capabilities to custom component - Introduced `send_message` method to handle message sending with optional formatting and content blocks. - Implemented `_store_message`, `_send_message_event`, and `_should_stream_message` for message storage and event management. - Added `_update_stored_message` and `_stream_message` to support message streaming and updating. - Included `_handle_async_iterator` and `_process_chunk` for processing message chunks from iterators. * Add new schema types and properties for chat and messages components * Add customizable chat message styles and icons in IOModal component * Add support for handling Playground events in chat view - Introduced `PlaygroundEvent` type to manage different event types such as message, error, warning, info, and token. - Implemented `handlePlaygroundEvent` function to process and update chat history based on event type. - Enhanced file parsing logic to handle empty strings and parsing errors. - Added default values for `background_color` and `text_color` in chat messages. * revert changes made to bypass ruff-check * revert changes made to bypass ruff-check * Refactor file parsing logic in ChatView component * fix ui problem * Refactor feature flags and chat view components - Enable new IO modal in feature flags - Update imports and remove unused code in newChatMessage component - Add error icon and error message in ChatMessage component - Update lockChat icon position in newChatView component - Import OctagonAlert icon in styleUtils * Refactor IOModal newModal component styles * Refactor styles in EditMessageField and ChatMessage components * Refactor styles in EditMessageField component * Refactor styles in ChatMessage component to fix UI problem * Refactor styles in UploadFileButton component and add image attachment tooltip * Refactor styles in ChatCodeTabComponent to update language text color * fix padding in other field views * Refactor styles in ChatComponent and add tooltip to the playground * Refactor styles in constants.ts to remove unused input and output types * Refactor session selector styles * Refactor chatView component styles * update colors to use variables * Refactor code tab component and update code styling * Refactor buttonSendWrapper component styles * update colors to use variables * update colors to use variables * Refactor chatComponent and chatInput styles * update colors to use variables * chore: add new attributes to model definition * chore: generate database migration * chore: add MetaData and ContentBlock models and update Message schema * chore: add error handling to build_results and adjust message event handling * chore: deserialize meta_data and content_blocks fields in add_messagetables * raw * Refactor message and chat types to include category, meta_data, and content_blocks * raw * Refactor error handling in component.py and newChatMessage.tsx * add source to bot messages * raw * Refactor chatMessage component to include meta_data icon and source * improve icon, background color, text color handling in chat message * add edit flag correctly * use svg icon logo instead of chain emoji * add text effect * update error colors * fix error aligment * add text shimmer effect * improve is running style * Add support for importing SVG files in Vite environment * Add chatLogoIcon component with Chain logo * Refactor chat message component to use chatLogoIcon component * Refactor chatView component to use chatLogoIcon component * remove from empty chat * update text sizes and style * remove icon in message logs * fix stop button color * update background color and sender name size * prevent list index out of range error * Fix onBlur event in EditMessageField component * improve edit message field * improve edit background behaviour * Update chat input styling for better user experience * Refactor ChatCodeTabComponent to remove redundant "Copy" text in button * Refactor code to use CSS variables for background color in code blocks * Refactor ChatCodeTabComponent to update code block styling * Refactor code to update code block styling and improve chat input styling * prevent Flow Running after error rendering * Refactor code to add IOModalOpen state and setter function * Refactor code to add IOModalOpen state and setter function * Refactor code to remove console.log statement * update icon and padding * Refactor code to retrieve connected model name in ChatComponent * run formatter * fix stop button glitch * update max width * Refactor GithubStarButton component to handle null value for stars * Refactor tailwind.config.mjs to add utility classes for fading text truncation * improve faded truncate function * Refactor ChatView component to handle null value for chat history category * [autofix.ci] apply automated fixes * Refactor DialogContent component to improve close button styling * Refactor IOModal component to improve sidebar behavior and styling * Refactor ChatView component to remove unused code and improve performance * Refactor session selector component to add tooltip for options * [autofix.ci] apply automated fixes * update several icon sizes and hover states * [autofix.ci] apply automated fixes * Refactor IOModal component to improve sidebar behavior and styling * Refactor IOModal component to handle sidebar behavior on window resize * [autofix.ci] apply automated fixes * fix error related to content blocks being null * [autofix.ci] apply automated fixes * add component id as sender to the message * add component id as source to the message * Add fitViewNode function to FlowStoreType * enable closing chat on error message * Add ClickableLinks component for rendering clickable URLs in chat messages * add error message transition * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * use IsPlayground flag * Remove console.log statement in setIOModalOpen function * update max-w * prevent breaking the buttons on small screen * [autofix.ci] apply automated fixes * remove underline when component is not clicable * Refactor IOModal component to remove unnecessary props and update usage - Remove the "isPlayground" prop from the IOModal component in cardComponent and storeCardComponent - Update the usage of the IOModal component in chatComponent and newModal to use the "canvasOpen" prop instead of "isPlayground" * fix html missing closing tag error * [autofix.ci] apply automated fixes * Refactor PlaygroundPage component to improve flow initialization and data fetching * [autofix.ci] apply automated fixes * Refactor cardComponent and storeCardComponent to comment out playground buttons * Refactor message model to replace 'meta_data' with 'properties' and update related schema and components * Add new schema for content types with Pydantic models * Add ContentBlock schema with support for multiple content types * Refactor: Import ContentBlock from langflow.schema.content_block instead of defining locally * Add SendMessageFunctionType protocol to log schema for message handling * Refactor chat message model to replace 'meta_data' with 'properties' and update related components * Add ContentBlock import and enhance send_message method in component.py - Import ContentBlock from langflow.schema.content_block. - Replace 'meta_data' with 'properties' in message construction. - Update send_message method to handle optional Message and text parameters. * Add async on_chain_start method to callback for logging chain start events * Refactor add_messagetables function to replace 'meta_data' with 'properties' in message processing * Fix typo in 'traceback' property name in ErrorDetails interface * Add condition to check chat history length before rendering chat lock * Refactor error content structure and enhance message event handling * Add `update_messages` function to handle message updates in memory module * Add check for 'id' attribute in stored_message for message validation * Add new content types and TypeAlias for schema in content_types.py * Add custom serialization for UUID and BaseModel types in data schema * Refactor `ContentType` to use `ContentTypes` union and update `content` field in `ContentBlock` model * Update model to use specific types for properties and content_blocks fields * Change return type of 'serialize_params' method to string * Add sender fields and properties handling to PlaygroundEvent and create_message function * Refactor chat message component to use 'properties' instead of 'meta_data' for chat attributes * Refactor message handling to improve error categorization and session management * Enhance ContentBlock initialization to update model fields with defaults * Add new content types and update ContentBlock interface in chat types - Introduced BaseContent interface and various content types: ErrorContent, TextContent, MediaContent, JSONContent, CodeContent, ToolStartContent, ToolEndContent, and ToolErrorContent. - Created a union type ContentType for all content types. - Updated ContentBlock interface to include new content structure and additional fields. * Refactor error handling in chat messages to use `ErrorContent` type * Add ErrorMessage class for handling error-specific messages in schema * Add type annotations for cache and logs in custom_component.py * Refactor error handling in custom component to use `send_error` method * Add customizable properties for chat components - Introduced new properties: `background_color`, `chat_icon`, and `text_color` to chat components across various starter projects. - These properties allow for customization of the chat message appearance, including icon and text styling. - Updated the `ChatInput` and `ChatOutput` components to handle these new properties and include them in the message response. * Add 'category' field to MessageEvent and update create_message function * Remove unused message handling methods from ChatComponent * Refactor message event handling in chat module * Add 'category' field to Message creation and pass 'id_' in _send_message_event * Add 'category' field with Literal type to Message schema and default handling in chat IO * Refactor message event handling in chat module * Refactor buttonSendWrapper component to add data-testid attribute * Refactor ChatComponent to replace 'store_message' with 'send_message' method * refactor: streamline message handling in Component Update message processing to utilize new methods for improved clarity and efficiency. Enhance event data management to ensure accuracy and consistency in message updates. * feat: Update input handling and output storage for chat components Enhance chat input and output components to improve message handling, including updates to storage and display properties. This facilitates better user experience and message management in various agent projects. * Ensure 'id' field is set in message data dictionary if not present * refactor: Simplify property retrieval from source component in ChatComponent * refactor: Replace property retrieval logic with a dedicated method in ChatOutput * Refactor `TokenEvent` class and add `timestamp` field with default factory * refactor: Simplify message processing by removing unused parameters in async handling * Refactor message text update logic in messagesStore * Refactor border styling in ChatInput component * refactor: Consolidate properties handling in PlaygroundEvent and create_message function * refactor: Update timestamp formatting to include timezone information across multiple models * refactor: Add StreamingError exception for better error handling in streaming components * refactor: Add source_display_name attribute to Properties model for enhanced data representation * refactor: Enhance ChatComponent to return source display name and update properties handling in ChatOutput * refactor: Improve error handling in Component class and enhance create_error function with timestamp support * feat: enhance ChatOutput component for improved message handling Update the message_response method to include source display name and improve message storage functionality across various project templates. This enhances clarity and ensures consistent behavior of chat components. * feat: add delete_message function to remove messages by ID from the monitor service * Add error handling for message streaming and implement message deletion on failure * feat: Enhance message streaming and event handling Improve the streaming process to send message events only for non-streaming messages and ensure the initial message is sent correctly when processing chunks, enhancing the overall message handling flow. * improve UI * Refactor buttonSendWrapper component to add data-testid attribute and update tests * fix edited tag * add tooltip to add button * fix bug after merge * update examples * updateinput without chat * fix some frontend tests * fix test * update test * Update fileUploadComponent.spec.ts to fix test and update input without chat * refactor event creation functions and enhance ErrorEvent structure * refactor ErrorMessage to use Source for sender and component details * refactor Properties to use Source model for source details and add validation * refactor ChatMessage component for improved readability and structure * refactor ChatMessageType to use PropertiesType for improved structure and clarity * Add Source ID to message properties and update exception handling - Updated `message_response` method to include `source_id` in the `Properties` object for better traceability. - Modified `StreamingError` to use `Source` object instead of `component_name` for more detailed error context. - Adjusted `get_properties_from_source_component` to return `source_id` along with other properties. * Add 'Source' property to error handling in custom_component module - Introduced 'Source' property to enhance error message details. - Updated error handling to include 'source' instead of 'display_name'. - Modified exception raising to use 'source' for better traceability. * Enhance event ID generation with event type prefix in `send_event` method * Refactor ChatOutput class to use Properties and Source schemas for message properties * update style in tailwind and add fallback for nullable values * fix playground test * Update message handling in Component class to send modified message copy on first chunk * Add flow_id and session_id to ErrorEvent creation function * Update content_blocks initialization and add flow_id parameter to ErrorMessage * feat: include vertex ID in class instantiation Pass the vertex ID to the custom component during instantiation to facilitate event tracking or management capabilities. * fix: update message streaming logic to handle None messages and refactor _stream_message parameters * feat: include flow_id in ChatOutput initialization Add flow_id to the ChatOutput class to improve the tracking of conversational flows, enhancing the context management within the chat system. * fix: update chat message source display to use 'source' instead of 'display_name' * feat: add flow_id to message initialization in ChatOutput class * fix: handle JSON parsing with type checks for message properties Refine JSON loading to ensure proper type handling for message properties and content blocks, enhancing stability and preventing potential errors with non-string inputs. * refactor: update logging structure and message handling Improve the output logs to support logging multiple entries and ensure robust message streaming with type checking. Adjust error handling parameters for consistency. * feat: restrict event types in registration and sending Enhance event management by explicitly defining allowed event types, improving code clarity and reducing potential errors. This ensures only valid event types are registered and sent, leading to more robust event handling. * Update `logs` attribute to store lists of `Log` objects in `Vertex` class * feat: introduce TypedDicts for ContentBlock and Properties, update default values in Message model * fix: restrict event types in send_event method to improve data validation * Set default values for 'id', 'display_name', and 'source' fields in Source schema * [autofix.ci] apply automated fixes * fix: update query to use equality check for error messages * make lint * update simple agent test * test: enhance EventManager tests for event_id validation * feat: add background, chat icon, and text color properties to component toolkit * fix: update LogComponent name to display_name for consistency * remove playground from new cards on main page --------- 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>
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 extend the messages funcionalities and create new types of events in the playground