Skip to content

Conversation

@Trioc
Copy link
Contributor

@Trioc Trioc commented Dec 9, 2025

Summary

This pull request fixes an encoding issue in the AI component where Chinese responses
returned from the OpenAI API were displayed as "??????????" in the WISE dialog.

Root Cause

The OpenAI HTTP response was being read using the default character set, which resulted
in the response being interpreted as ISO-8859-1. Since Chinese characters cannot be
represented in ISO-8859-1, the UI displayed garbled text ("???????").

Fix Implemented

  • Updated ChatGptController.java to explicitly read the HTTP response stream using
    ISO-8859-1 when parsing the OpenAI response.
  • This ensures that the returned JSON string remains intact, and the Chinese content is
    correctly handled by the downstream components in WISE.

Why ISO-8859-1?

  • OpenAI’s API sometimes returns response headers indicating ISO-8859-1.
  • Using ISO-8859-1 prevents character loss during the initial read operation because
    it maps bytes directly (1:1), allowing the actual UTF-8 content inside the JSON to be
    preserved for correct later parsing.

Impact

  • Chinese character responses are now displayed correctly in the WISE AI dialog.
  • No behavior changes for English or other ASCII-only responses.
  • The fix is isolated to the AI component and does not affect other subsystems.

Testing

  • Verified locally in our WISE deployment that Chinese responses from OpenAI are now
    displayed correctly in the dialog.
  • Confirmed no regression for English responses.

@hirokiterashima hirokiterashima self-assigned this Dec 11, 2025
@hirokiterashima hirokiterashima self-requested a review December 11, 2025 20:46
Copy link
Member

@hirokiterashima hirokiterashima left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this PR. Fix works as described. Can you clean up ChatGptcontroller.java (I added suggestions inline), and remove wise_api_local_changes.patch file?

@Trioc
Copy link
Contributor Author

Trioc commented Dec 22, 2025

Thanks for the review! I’ve removed the debug print, cleaned up the unused imports, and deleted the local patch file as suggested. The PR has been updated.

@hirokiterashima hirokiterashima changed the title Fix Chinese encoding issue in ChatGptController fix(ChatGptController): Chinese encoding issue Dec 23, 2025
@hirokiterashima hirokiterashima added the bug Something isn't working label Dec 23, 2025
@hirokiterashima hirokiterashima merged commit 2cb07de into WISE-Community:develop Dec 23, 2025
1 check passed
@hirokiterashima
Copy link
Member

🎉 This PR is included in version 1.13.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants