improve ExampleSource
This commit is contained in:
parent
58da733b29
commit
fb5ffa99a0
1 changed files with 24 additions and 5 deletions
|
@ -75,9 +75,12 @@ class ExampleSource implements ChatSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
String rollResponse(Chat chat) {
|
String rollResponse(Chat chat) {
|
||||||
|
def special = -1
|
||||||
def prompt = chat.messages.getLast().text()
|
def prompt = chat.messages.getLast().text()
|
||||||
int messagesCount = (int) Math.ceil(chat.messages.size() / 2)
|
int messagesCount = (int) Math.ceil(chat.messages.size() / 2)
|
||||||
def counter = lastCounter
|
def counter = lastCounter
|
||||||
|
def response = ""
|
||||||
|
|
||||||
|
|
||||||
if (prompt.toLowerCase().startsWith("my name is")) {
|
if (prompt.toLowerCase().startsWith("my name is")) {
|
||||||
options.setValue("name", prompt.substring(11))
|
options.setValue("name", prompt.substring(11))
|
||||||
|
@ -87,12 +90,28 @@ class ExampleSource implements ChatSource {
|
||||||
counter = 11
|
counter = 11
|
||||||
}
|
}
|
||||||
|
|
||||||
while (counter == lastCounter) {
|
def parseable = prompt.toLowerCase().strip().replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||||
counter = random.nextInt(13)
|
switch (parseable) {
|
||||||
|
case "who am i":
|
||||||
|
case "whats my name":
|
||||||
|
special = 0
|
||||||
|
break
|
||||||
}
|
}
|
||||||
lastCounter = counter
|
|
||||||
|
|
||||||
def response = ""
|
if (special != -1) {
|
||||||
|
counter = -1
|
||||||
|
switch (special) {
|
||||||
|
case 0:
|
||||||
|
response = "Your name is " + options.getStringValue("name") + ". How can I help you, " + options.getStringValue("name") + "?"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// TODO make it unique and better
|
||||||
|
} else {
|
||||||
|
while (counter == lastCounter) {
|
||||||
|
counter = random.nextInt(13)
|
||||||
|
}
|
||||||
|
lastCounter = counter
|
||||||
|
}
|
||||||
|
|
||||||
def words = prompt.split(" ")
|
def words = prompt.split(" ")
|
||||||
def randomWord = words[random.nextInt(words.length)]
|
def randomWord = words[random.nextInt(words.length)]
|
||||||
|
@ -144,8 +163,8 @@ class ExampleSource implements ChatSource {
|
||||||
i2 = random.nextInt(messagesCount)
|
i2 = random.nextInt(messagesCount)
|
||||||
}
|
}
|
||||||
response = "I'm still angry after you said \"%s\" to me. You could have apologized, but you chose to say \"%s\", so I can't assist you.".formatted(chat.messages.get(i * 2).text(), chat.messages.get(i2 * 2).text())
|
response = "I'm still angry after you said \"%s\" to me. You could have apologized, but you chose to say \"%s\", so I can't assist you.".formatted(chat.messages.get(i * 2).text(), chat.messages.get(i2 * 2).text())
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
break
|
||||||
case 13:
|
case 13:
|
||||||
response = "And?"
|
response = "And?"
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue