Compare commits

..

3 commits

Author SHA1 Message Date
f29ec8f5c2 bot: Reduce ChatGPTResponse object
All checks were successful
ci/woodpecker/push/java/1 Pipeline was successful
ci/woodpecker/push/java/2 Pipeline was successful
ci/woodpecker/push/java/3 Pipeline was successful
ci/woodpecker/push/java/4 Pipeline was successful
ci/woodpecker/push/java/5 Pipeline was successful
ci/woodpecker/push/nodejs Pipeline was successful
ci/woodpecker/push/oci-image-cache-build Pipeline was successful
ci/woodpecker/push/oci-image-build/1 Pipeline was successful
ci/woodpecker/push/oci-image-build/2 Pipeline was successful
ci/woodpecker/push/oci-image-build/3 Pipeline was successful
ci/woodpecker/push/oci-image-build/4 Pipeline was successful
ci/woodpecker/push/oci-image-build/5 Pipeline was successful
2024-03-02 16:09:53 +01:00
2abae09fa4 ci: Fix cache image tag 2024-03-02 16:00:09 +01:00
eaba43c51b monolith: Make App class final
Like the other modules :)
2024-03-02 15:58:16 +01:00
3 changed files with 10 additions and 17 deletions

View file

@ -22,6 +22,6 @@ steps:
dockerfile: Dockerfile
target: setup-image
repo: rg.fr-par.scw.cloud/hamburghammer/dchat/setup-image
tag: ${CI_PIPELINE_PARENT}
tag: ${CI_PIPELINE_NUMBER}
pull_image: false
platforms: ${PLATFORM}

View file

@ -6,24 +6,17 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public record ChatGPTResponse(String id,
String object,
long created,
String model,
Usage usage,
List<Choice> choices,
@JsonProperty("system_fingerprint") String systemFingerprint) {
public record ChatGPTResponse(Usage usage,
List<Choice> choices) {
@JsonIgnoreProperties(ignoreUnknown = true)
public record Usage(@JsonProperty("prompt_tokens") int promptTokens,
@JsonProperty("completion_tokens") int completionTokens,
@JsonProperty("total_tokens") int totalTokens) {
}
@JsonIgnoreProperties(ignoreUnknown = true)
public record Choice(Message message, @JsonProperty("finish_reason") String finishReason, int index) {
public record Choice(Message message) {
@JsonIgnoreProperties(ignoreUnknown = true)
public record Message(String role, String content) {
}
}
}

View file

@ -18,10 +18,10 @@ import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
public class App {
public final class App {
private static final Logger logger = LoggerFactory.getLogger(App.class);
public static void main(String[] args) {
public static void main(final String[] args) {
final String discordApiKey = System.getenv("DISCORD_API_KEY");
if (discordApiKey == null) {
logger.error("Missing environment variables: DISCORD_API_KEY");
@ -63,12 +63,12 @@ public class App {
}
}
private static void run(Runnable... apps) throws InterruptedException {
List<Callable<Void>> callableApps = Arrays.stream(apps).sequential().map(runnable -> (Callable<Void>) () -> {
private static void run(final Runnable... apps) throws InterruptedException {
final List<Callable<Void>> callableApps = Arrays.stream(apps).sequential().map(runnable -> (Callable<Void>) () -> {
runnable.run();
return null;
}).toList();
try (var executorService = Executors.newFixedThreadPool(apps.length)) {
try (final var executorService = Executors.newFixedThreadPool(apps.length)) {
executorService.invokeAll(callableApps);
}
}