-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Support session variables #3792
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
The provided code contains several issues and areas for improvement:
Issues:
Global/Chat Variable Handling: The
handlemethod does not differentiate between global and chat variables. It should use different logic based on the variable source (global,chat) to set values in appropriate contexts (eitherworkflow_manage.contextorself.workflow_manage.chat_context).Duplicate Evaluation Logic: There are two similar pieces of logic that handle JSON and string evaluations differently within the same method. This can be simplified.
Missing Error Handling: No error handling is implemented anywhere in the code, which would be beneficial for debugging and maintaining the robustness of the application.
Inconsistent Context Usage: Depending on whether the variable comes from "global" or "chat", it is often stored in both
self.workflow_manage.contextandself.workflow_manage.chat_context. This could lead to confusion or undefined behavior.Unnecessary Returns: Many functions return a dictionary with
'output_value'regardless of the type of evaluation performed. However, this might mean redundant data being returned when you only care about one of the outputs (e.g., the evaluated value vs. the original input).Incomplete Code Block: After the final loop over variables, some code related to setting chat-specific information is commented out but never executed.
Suggested Improvements:
Deduplicate Evaluation Logic:
Context Management:
Ensure that variable assignments are correctly handled according to their types using the
evaluate_variablefunction.Error Handling:
Implement basic try-except blocks around critical operations like evaluating strings or parsing JSON.
Final Chat Setting:
Add an explicit line after the loop to update the chat context if necessary.
Here’s how the improved version might look:
Replace these lines with:
And remove all other uses of
create_update.Reasoning:
values_to_create_and_updates()function creates multiple instances instead of updating existing ones, which can lead to inefficiencies and conflicts.collections.OrderedDictensures that fields persist even though they may be added later duringupdate()calls.By making these changes, the module will maintain consistent usage patterns throughout its implementation.