Skip to content

fix: OpenAI interface call for session, passing asker does not take effect #2943

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 1 commit into from
Apr 22, 2025

Conversation

shaohuzhang1
Copy link
Contributor

fix: OpenAI interface call for session, passing asker does not take effect

Copy link

f2c-ci-robot bot commented Apr 22, 2025

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 Apr 22, 2025

[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

@@ -232,7 +241,8 @@ def chat(self, instance: Dict, with_valid=True):
application_id = self.data.get('application_id')
client_id = self.data.get('client_id')
client_type = self.data.get('client_type')
chat_id = self.generate_chat(chat_id, application_id, message, client_id)
chat_id = self.generate_chat(chat_id, application_id, message, client_id,
asker=instance.get('form_data', {}).get("asker"))
return ChatMessageSerializer(
data={
'chat_id': chat_id, 'message': message,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The asker parameter was added to the generate_chat method, so you need to handle it accordingly in all parts of the code where this function is called.

  2. In the constructor (__init__) of the class, self.client_id should be set based on self.data['client_id'] or None.

  3. It's unclear whether ChatMessageSerializer requires additional initialization parameters beyond what it takes from the serializer itself (e.g., data). If so, consider adding them here.

  4. Ensure that the input dictionary self.data does not contain null values for required keys like chat_id, application_id, and message. If they aren't optional, handle their absence gracefully.

  5. Consider using type hints throughout the code to improve readability and maintainability. For example, change the line defining self.data: Dict[str, Any] = {} into self.data: Optional[Dict[str, Union[str, int]]] = {} for better understanding about its expected content.

  6. When handling user input via APIs, remember to validate it before processing to prevent attacks such as SQL injection, cross-site scripting (XSS), and other security vulnerabilities.

  7. Review how QuerySet(Chat) interacts with other parts of your API to ensure proper database queries are executed when retrieving Chat objects.

  8. Since this code handles messages and potentially sensitive information, implement appropriate logging around critical operations within try-except blocks to capture errors cleanly for debugging purposes.

@shaohuzhang1 shaohuzhang1 merged commit 072b817 into main Apr 22, 2025
4 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_openai_asker branch April 22, 2025 03:06
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