Updated gpt library

This commit is contained in:
ohAlee 2023-04-22 15:43:55 +02:00
parent 0fc08ced02
commit c083650047
2 changed files with 5 additions and 4 deletions

View File

@ -4,7 +4,7 @@ plugins {
} }
group = 'it.ohalee.minecraftgpt' group = 'it.ohalee.minecraftgpt'
version = '1.2.4' version = '1.2.5'
sourceCompatibility = 1.17 sourceCompatibility = 1.17
targetCompatibility = 1.17 targetCompatibility = 1.17
@ -25,7 +25,7 @@ dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
implementation 'com.theokanning.openai-gpt3-java:client:0.8.1' implementation 'com.theokanning.openai-gpt3-java:service:0.12.0'
compileOnly 'org.checkerframework:checker-qual:3.21.2' compileOnly 'org.checkerframework:checker-qual:3.21.2'
compileOnly 'org.jetbrains:annotations:23.0.0' compileOnly 'org.jetbrains:annotations:23.0.0'

View File

@ -1,10 +1,11 @@
package it.ohalee.minecraftgpt; package it.ohalee.minecraftgpt;
import com.theokanning.openai.OpenAiService;
import com.theokanning.openai.completion.CompletionRequest; import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.service.OpenAiService;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import retrofit2.HttpException; import retrofit2.HttpException;
import java.time.Duration;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -13,7 +14,7 @@ public class OpenAI {
private static OpenAiService service; private static OpenAiService service;
public static CompletableFuture<Void> init(String key) { public static CompletableFuture<Void> init(String key) {
return CompletableFuture.runAsync(() -> service = new OpenAiService(key, 5)); return CompletableFuture.runAsync(() -> service = new OpenAiService(key, Duration.ofSeconds(5)));
} }
public static CompletableFuture<String> getResponse(ConfigurationSection section, StringBuilder cached, String message) { public static CompletableFuture<String> getResponse(ConfigurationSection section, StringBuilder cached, String message) {