Commit 1e55dcba by Jonathan Thomas

Improved error handling to prevent broken "..." pending chat status. (HTTP and…

Improved error handling to prevent broken "..." pending chat status. (HTTP and message processing is more protected). Removed randomized error messages from chat history (so it doesn't break the chat history when an error is shown)
parent a5fb3933
Pipeline #13344 passed with stages
in 2 minutes 28 seconds
......@@ -11,11 +11,13 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Changed
- Broadcasting and receiving chat messages now ignores if the UUID is valid (to keep data synced)
- Improved error handling to prevent broken "..." pending chat status. (HTTP and message processing is more protected)
### Fixed
- Bees no longer forget their chat data when entering/leaving hives (writeNbt & readNbt modified)
- Vexes no longer take damage when chat data exists
- Wandering Trader no longer despawns if it has chat data
- Removed randomized error messages from chat history (so it doesn't break the chat history when an error is shown)
## [1.3.0] - 2025-01-14
......
......@@ -196,6 +196,7 @@ public class ChatGPTRequest {
lastErrorMessage = cleanError;
} catch (Exception e) {
LOGGER.error("Failed to read error response", e);
lastErrorMessage = "Failed to read error response: " + e.getMessage();
}
return null;
} else {
......@@ -214,12 +215,16 @@ public class ChatGPTRequest {
if (chatGPTResponse != null && chatGPTResponse.choices != null && !chatGPTResponse.choices.isEmpty()) {
String content = chatGPTResponse.choices.get(0).message.content;
return content;
} else {
lastErrorMessage = "Failed to parse response from LLM";
return null;
}
}
} catch (IOException e) {
LOGGER.error("Failed to fetch message from ChatGPT", e);
} catch (Exception e) {
LOGGER.error("Failed to request message from LLM", e);
lastErrorMessage = "Failed to request message from LLM: " + e.getMessage();
return null;
}
return null; // If there was an error or no response, return null
});
}
}
......
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