mirror of
https://github.com/ddaodan/minechatgpt.git
synced 2025-11-02 12:44:13 +08:00
2.5:Folia支持,fix #4
This commit is contained in:
@@ -166,7 +166,8 @@ public class CommandHandler implements CommandExecutor {
|
||||
}
|
||||
if (response.statusCode() == 200) {
|
||||
String responseBody = response.bodyText();
|
||||
JSONObject jsonResponse = new JSONObject(responseBody);
|
||||
String utf8ResponseBody = new String(responseBody.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
JSONObject jsonResponse = new JSONObject(utf8ResponseBody);
|
||||
String answer = jsonResponse.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content");
|
||||
sender.sendMessage(configManager.getChatGPTResponseMessage().replace("%s", answer));
|
||||
if (contextEnabled) {
|
||||
|
||||
@@ -14,9 +14,9 @@ public class ConversationContext {
|
||||
|
||||
public void addMessage(String message) {
|
||||
if (conversationHistory.size() >= maxHistorySize) {
|
||||
conversationHistory.poll(); // Remove the oldest message
|
||||
conversationHistory.poll();
|
||||
}
|
||||
conversationHistory.offer(message); // Add the new message
|
||||
conversationHistory.offer(message);
|
||||
}
|
||||
|
||||
public String getConversationHistory() {
|
||||
|
||||
@@ -25,6 +25,6 @@ permissions:
|
||||
minechatgpt.context:
|
||||
description: Allows toggling context mode
|
||||
default: true
|
||||
chatgpt.clear:
|
||||
minechatgpt.clear:
|
||||
description: Allows clearing conversation history
|
||||
default: true
|
||||
Reference in New Issue
Block a user