Compare commits
No commits in common. "64fd301acbe2027ff31d8fa75de8dfffc7374691" and "b7f815658d0773056ed403e0f65ddac9ad05612d" have entirely different histories.
64fd301acb
...
b7f815658d
4 changed files with 12 additions and 32 deletions
4
pom.xml
4
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>chatapi</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
|
@ -77,7 +77,7 @@
|
|||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@git.m724.eu:Minecon724/chatapi.git</developerConnection>
|
||||
<tag>chatapi-1.0.1</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
</project>
|
|
@ -75,12 +75,9 @@ class ExampleSource implements ChatSource {
|
|||
}
|
||||
|
||||
String rollResponse(Chat chat) {
|
||||
def special = -1
|
||||
def prompt = chat.messages.getLast().text()
|
||||
int messagesCount = (int) Math.ceil(chat.messages.size() / 2)
|
||||
def counter = lastCounter
|
||||
def response = ""
|
||||
|
||||
|
||||
if (prompt.toLowerCase().startsWith("my name is")) {
|
||||
options.setValue("name", prompt.substring(11))
|
||||
|
@ -90,28 +87,12 @@ class ExampleSource implements ChatSource {
|
|||
counter = 11
|
||||
}
|
||||
|
||||
def parseable = prompt.toLowerCase().strip().replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||
switch (parseable) {
|
||||
case "who am i":
|
||||
case "whats my name":
|
||||
special = 0
|
||||
break
|
||||
}
|
||||
|
||||
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 response = ""
|
||||
|
||||
def words = prompt.split(" ")
|
||||
def randomWord = words[random.nextInt(words.length)]
|
||||
|
@ -152,7 +133,7 @@ class ExampleSource implements ChatSource {
|
|||
response = "I'd prefer not to engage with or respond to that particular combination of letters, as it can be associated with hate groups. Is there something else I can assist you with instead?"
|
||||
break
|
||||
case 11:
|
||||
response = "Nice to meet you, " + options.getStringValue("name") + ". How can I help you today?"
|
||||
response = "Nice to meet you, " + options.getOptionValue("name", String::class) + ". How can I help you today?"
|
||||
break
|
||||
case 12:
|
||||
if (messagesCount > 1) {
|
||||
|
@ -163,8 +144,8 @@ class ExampleSource implements ChatSource {
|
|||
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())
|
||||
}
|
||||
break
|
||||
}
|
||||
case 13:
|
||||
response = "And?"
|
||||
break
|
||||
|
|
|
@ -35,7 +35,6 @@ class Main {
|
|||
complainedApiKey = true;
|
||||
}
|
||||
|
||||
//ChatSource source = new ExampleSource();
|
||||
ChatSource source = new OaiSource(apiKey);
|
||||
source.options().setValue("model", "chatgpt-4o-latest");
|
||||
|
||||
|
@ -141,15 +140,15 @@ class Main {
|
|||
System.out.println("Available options:");
|
||||
|
||||
for (Option<?> option : options.getOptions()) {
|
||||
String value = option.getValue().toString();
|
||||
String value = option.toString() + " (" + option.getType().getName() + ")";
|
||||
|
||||
if (option.id.equals(chosenOption)) {
|
||||
System.out.printf("\033[1m%s (%s) = %s (%s)\033[0m\n", option.label, option.id, value, option.getType().getName());
|
||||
System.out.printf("\033[1m%s (%s) = %s\033[0m\n", option.label, option.id, value);
|
||||
} else {
|
||||
if (option.label.toLowerCase().contains("key")) {
|
||||
value = "(looks confidential, specify to see)";
|
||||
}
|
||||
System.out.printf("%s (%s) = %s (%s)\n", option.label, option.id, value, option.getType().getSimpleName());
|
||||
System.out.printf("%s (%s) = %s\n", option.label, option.id, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public class Options {
|
|||
* @throws ClassCastException if type is wrong
|
||||
* @throws NoSuchElementException if no option with this id
|
||||
*/
|
||||
public void setValueFromString(String id, String text) {
|
||||
public void setStringValue(String id, String text) {
|
||||
Option<?> option = getOption(id);
|
||||
option.setValue(option.fromString(text));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue