-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Refactor prompt validation and code processing in Component and PromptComponent classes #2264
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
dosubot
bot
added
the
size:L
This PR changes 100-499 lines, ignoring generated files.
label
Jun 22, 2024
dosubot
bot
added
bug
Something isn't working
javascript
Pull requests that update Javascript code
labels
Jun 22, 2024
ogabrielluiz
changed the title
Refactor prompt validation and code processing in Component and PromptComponent classes"
Refactor prompt validation and code processing in Component and PromptComponent classes
Jun 22, 2024
italojohnny
approved these changes
Jun 22, 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
Refactor the prompt validation process in validate.py to improve code readability and maintainability. The changes include: - Update the import statement for process_prompt_template in api_utils.py. - Remove unused imports from api_utils.py. - Simplify the post_validate_prompt function by removing unnecessary conditional statements. - Replace the validate_prompt function call with process_prompt_template in post_validate_prompt. These changes enhance the efficiency and organization of the prompt validation process.
When updating the Component code in GenericNode, handle any errors that occur. If an error occurs, display an error message with instructions to report the issue on Discord or GitHub. This improves the error handling and user experience when updating the Component code.
Refactor the post_code_validation method in the Component class to improve code readability and maintainability. The changes include: - Rename the parameters to better reflect their purpose. - Update the function documentation to provide a clear explanation of the method's purpose. - Remove unnecessary comments and whitespace. - Improve variable naming for better clarity. These changes enhance the overall quality of the code and make it easier to understand and maintain.
Update the return type of the build_custom_component_template function in utils.py to include the possibility of returning a Component object. This change ensures that the function can handle both CustomComponent and Component objects, improving flexibility and compatibility.
The post_code_validation method in the Component class has been renamed to post_code_processing to better reflect its purpose. This change improves code clarity and maintainability.
Refactor the post_code_processing method in the PromptComponent class to improve code readability and maintainability. The changes include: - Import the process_prompt_template function from langflow.base.prompts.api_utils. - Import the update_template_values function from langflow.template.utils. - Call the process_prompt_template function to update the template value. - Update the frontend_node with any values set in the current_build_config. - Remove unnecessary comments and whitespace. These changes enhance the overall quality of the code and make it easier to understand and maintain.
ogabrielluiz
force-pushed
the
fix_prompt_update
branch
from
June 23, 2024 00:39
888e0b3
to
35b070c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
javascript
Pull requests that update Javascript code
lgtm
This PR has been approved by a maintainer
size:L
This PR changes 100-499 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.
Adds a
post_code_processing
method that runs right after the component code is validated. The previous logic was moved into theComponent
class and classes that override this method should call thesuper()
class almost always.Components can now define post validation logic such as setting values dynamically when updated.
This PR also fixes the PromptComponent not being allowed to update its code.
Additionally, refactor the prompt validation process in the
validate.py
.