Skip to content
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

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

shaohuzhang1
Copy link
Contributor

fix: Error in obtaining variables for character settings

Verified

This commit was signed with the committer’s verified signature.
adamdehaven Adam DeHaven
Copy link

f2c-ci-robot bot commented Dec 30, 2024

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.

Copy link

f2c-ci-robot bot commented Dec 30, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -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:
Copy link
Contributor Author

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:
Copy link
Contributor Author

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:

  1. Consistent Use of content: Since you're already referring to the system.content, it would make sense to consistently use .content throughout.

  2. 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.

@shaohuzhang1 shaohuzhang1 merged commit 5faa28e into main Dec 30, 2024
4 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_ai_chat_system branch December 30, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant