Commit b7bdb13e by Jonathan Thomas

Fixed chats broken when OS locale is non-English language

parent b99db363
Pipeline #12206 passed with stage
in 1 minute 49 seconds
......@@ -15,6 +15,9 @@ All notable changes to **CreatureChat** are documented in this file. The format
- Updated `/creaturechat help` output
- Updated `README.md` with new command documentation
### Fixed
- Chats broken when OS locale is non-English language (i.e. `assistant to ass\u0131stant`)
## [1.0.3] - 2024-05-10
### Changed
......
......@@ -13,10 +13,7 @@ import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
......@@ -138,7 +135,7 @@ public class ChatGPTRequest {
// Iterate backwards through the message history
for (int i = messageHistory.size() - 1; i >= 0; i--) {
ChatDataManager.ChatMessage chatMessage = messageHistory.get(i);
String senderName = chatMessage.sender.toString().toLowerCase();
String senderName = chatMessage.sender.toString().toLowerCase(Locale.ENGLISH);
String messageText = replacePlaceholders(chatMessage.message, context);
int messageTokens = estimateTokenSize(senderName + ": " + messageText);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment