Skip to content

Commit

Permalink
Merge pull request #16 from RappyLabyAddons/feat/improveErrorHandling
Browse files Browse the repository at this point in the history
Improve error handling
  • Loading branch information
RappyTV authored Jan 3, 2024
2 parents cf31eaa + 1c689ca commit 5b204c6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ labyMod {
author = "RappyTV"
description = "Communicate with ChatGPT right in your Chat. Powered by OpenAI."
minecraftVersion = "*"
version = System.getenv().getOrDefault("VERSION", "1.1.1")
version = System.getenv().getOrDefault("VERSION", "1.1.2")
}

minecraft {
Expand All @@ -34,7 +34,9 @@ labyMod {
"1.19.2",
"1.19.3",
"1.19.4",
"1.20.1"
"1.20.1",
"1.20.2",
"1.20.4"
) { version, provider ->
configureRun(provider, version)
}
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/com/rappytv/labygpt/api/GPTRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ public CompletableFuture<Void> sendRequestAsync(String query, String key, String
}

future.complete(null);
}).exceptionally((e) -> {
future.completeExceptionally(e);
error = e.getMessage();
return null;
});
} catch (Exception e) {
e.printStackTrace();
future.completeExceptionally(e);
error = e.getMessage();
}

return future;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public boolean execute(String prefix, String[] arguments) {
displayMessage(Component.empty().append(GPTAddon.prefix)
.append(Component.text(request.getOutput(), NamedTextColor.WHITE)));
}
}).exceptionally((e) -> {
displayMessage(Component.empty().append(GPTAddon.prefix)
.append(Component.text(e.getMessage(), NamedTextColor.RED)));
return null;
});

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget;
import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownSetting;
import net.labymod.api.configuration.loader.Config;
import net.labymod.api.configuration.loader.annotation.Exclude;
import net.labymod.api.configuration.loader.annotation.SpriteSlot;
import net.labymod.api.configuration.loader.property.ConfigProperty;
import net.labymod.api.configuration.settings.annotation.SettingListener;
Expand All @@ -14,6 +15,7 @@

public class GPTSubConfig extends Config {

@Exclude
private final String[] models = new String[]{"GPT-3.5-Turbo", "GPT-3.5-Turbo-16k", "GPT-4", "GPT-4-32k"};

@DropdownSetting
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rootProject.name = "LabyGPT"

pluginManagement {
val labyGradlePluginVersion = "0.3.28"
val labyGradlePluginVersion = "0.3.43"
plugins {
id("net.labymod.gradle") version (labyGradlePluginVersion)
}
Expand Down

0 comments on commit 5b204c6

Please sign in to comment.