-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: Error in obtaining variables for character settings #1948
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -111,7 +111,7 @@ def execute(self, model_id, system, prompt, dialogue_number, history_chat_record | |||
question = self.generate_prompt_question(prompt) | |||
self.context['question'] = question.content | |||
system = self.workflow_manage.generate_prompt(system) | |||
self.context['system'] = question.content | |||
self.context['system'] = system | |||
message_list = self.generate_message_list(system, prompt, history_message) | |||
self.context['message_list'] = message_list | |||
if stream: |
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 snippet is generally clean and concise. However, there's one small issue that could be improved:
# Potential issue: In the line where 'self.context['system']' is being overwritten,
# it might be more appropriate to set it based on the current context rather than always overwriting it with `question.content`.
# Optimization suggestion: Consider handling potential exceptions when trying to access or modify context variables.
This comment suggests modifying the last assignment to use the updated system content instead of directly setting self.context['system']
to question.content
, which can prevent unexpected behavior if the context contains other relevant information that needs to be preserved. Additionally, adding error handling for accessing/modifying context variables can make the code more robust.
@@ -93,7 +93,7 @@ def execute(self, model_id, system, prompt, dialogue_number, history_chat_record | |||
question = self.generate_prompt_question(prompt) | |||
self.context['question'] = question.content | |||
system = self.workflow_manage.generate_prompt(system) | |||
self.context['system'] = question.content | |||
self.context['system'] = system | |||
message_list = self.generate_message_list(system, prompt, history_message) | |||
self.context['message_list'] = message_list | |||
if stream: |
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.
There is no apparent issue with this code. However, there are a couple of small improvements that can be made for readability and maintainability:
-
Consistent Use of
content
: Since you're already referring to thesystem.content
, it would make sense to consistently use.content
throughout. -
Use of Variables For Clarity: While current approach works, using variables can enhance clarity:
question = self.generate_prompt_question(prompt) self.context['question'] = question.content # Using 'self.system' to avoid redundancy system_content = self.workflow_manage.generate_prompt(system).content self.context['system'] = system_content message_list = self.generate_message_list(system, prompt, history_message) self.context.update({'message_list': message_list})
These changes improve consistency within your codebase and potentially reduce potential errors or misunderstandings down the line.
fix: Error in obtaining variables for character settings