v1.2.8 - last endpoint only

This commit is contained in:
ohAlee 2024-02-02 18:10:49 +01:00
parent b408c42ea8
commit 7df2a07c62
3 changed files with 4 additions and 20 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration"> <component name="FrameworkDetectionExcludesConfiguration">

View File

@ -4,7 +4,7 @@ plugins {
} }
group = 'it.ohalee.minecraftgpt' group = 'it.ohalee.minecraftgpt'
version = '1.2.7' version = '1.2.8'
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:service:0.12.0' implementation 'com.theokanning.openai-gpt3-java:service:0.18.2'
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

@ -29,21 +29,7 @@ public class OpenAI {
double topP = section.getDouble("top-p"); double topP = section.getDouble("top-p");
double temperature = section.getDouble("temperature"); double temperature = section.getDouble("temperature");
if (model.startsWith("gpt-4") || model.startsWith("gpt-3.5")) { return service.createChatCompletion(ChatCompletionRequest.builder()
return service.createChatCompletion(ChatCompletionRequest.builder()
.model(model)
.temperature(temperature)
.maxTokens(maxTokens)
.topP(topP)
.frequencyPenalty(frequencyPenalty)
.presencePenalty(presencePenalty)
.stop(Arrays.asList("Human:", "AI:"))
.build())
.getChoices().get(0).getMessage().getContent();
}
return service.createCompletion(CompletionRequest.builder()
.prompt(cached.toString())
.model(model) .model(model)
.temperature(temperature) .temperature(temperature)
.maxTokens(maxTokens) .maxTokens(maxTokens)
@ -52,8 +38,7 @@ public class OpenAI {
.presencePenalty(presencePenalty) .presencePenalty(presencePenalty)
.stop(Arrays.asList("Human:", "AI:")) .stop(Arrays.asList("Human:", "AI:"))
.build()) .build())
.getChoices().get(0).getText(); .getChoices().get(0).getMessage().getContent();
}).exceptionally(throwable -> { }).exceptionally(throwable -> {
if (throwable.getCause() instanceof HttpException e) { if (throwable.getCause() instanceof HttpException e) {
String reason = switch (e.response().code()) { String reason = switch (e.response().code()) {