Commit da0dafaf by Jonathan Thomas

- Added a long list of random "no response" phrases. Sometimes the LLM just…

- Added a long list of random "no response" phrases. Sometimes the LLM just outputs a behavior and no text.
- Added the actual output with behaviors to chat history (for better context)
- Fixed a bug which was broadcasting the new generated message at the wrong time.
parent 9b5f8870
Pipeline #11940 passed with stage
in 20 seconds
......@@ -231,13 +231,21 @@ public class ChatDataManager {
}
}
// Add ASSISTANT message
this.addMessage(result.getCleanedMessage(), ChatSender.ASSISTANT);
// Add ASSISTANT message to history
this.addMessage(result.getOriginalMessage(), ChatSender.ASSISTANT);
// Get cleaned message (i.e. no <BEHAVIOR> strings)
String cleanedMessage = result.getCleanedMessage();
if (cleanedMessage.isEmpty()) {
cleanedMessage = result.getRandomNoResponseMessage();
}
// Update the current message to a 'cleaned version'
this.currentMessage = cleanedMessage;
}
});
// Broadcast to all players
ModInit.BroadcastPacketMessage(this);
});
}
// Add a message to the history and update the current message
......
......@@ -36,6 +36,6 @@ public class MessageParser {
matcher.appendTail(cleanedMessage);
LOGGER.info("Cleaned message: {}", cleanedMessage.toString());
return new ParsedMessage(cleanedMessage.toString().trim(), behaviors);
return new ParsedMessage(cleanedMessage.toString().trim(), input.trim(), behaviors);
}
}
package com.owlmaddie.message;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* The {@code ParsedMessage} class represents a list of behaviors and a cleaned message.
*/
public class ParsedMessage {
private String cleanedMessage;
private String originalMessage;
private List<Behavior> behaviors;
private List<String> noResponseMessages = Arrays.asList(
"<no response>",
"<silence>",
"<stares>",
"<blinks>",
"<looks away>",
"<sighs>",
"<shrugs>",
"<taps foot>",
"<yawns>",
"<examines nails>",
"<whistles softly>",
"<shifts uncomfortably>",
"<glances around>",
"<pretends not to hear>",
"<hums quietly>",
"<fiddles with something>",
"<gazes into the distance>",
"<smirks>",
"<raises an eyebrow>",
"<clears throat>",
"<peers over your shoulder>",
"<fakes a smile>",
"<checks the time>",
"<doodles in the air>",
"<mutters under breath>",
"<adjusts an imaginary tie>",
"<counts imaginary stars>",
"<plays with a nonexistent pet>"
);
public ParsedMessage(String cleanedMessage, List<Behavior> behaviors) {
public ParsedMessage(String cleanedMessage, String originalMessage, List<Behavior> behaviors) {
this.cleanedMessage = cleanedMessage;
this.originalMessage = originalMessage;
this.behaviors = behaviors;
}
// Getters
// Get cleaned message (no behaviors)
public String getCleanedMessage() {
return cleanedMessage;
return cleanedMessage.trim();
}
// Get random no response message
public String getRandomNoResponseMessage() {
Random random = new Random();
int index = random.nextInt(noResponseMessages.size());
return noResponseMessages.get(index).trim();
}
// Get original message
public String getOriginalMessage() {
return originalMessage.trim();
}
public List<Behavior> getBehaviors() {
......
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