Compare commits
3 commits
84aa5fdf3e
...
f29ec8f5c2
Author | SHA1 | Date | |
---|---|---|---|
f29ec8f5c2 | |||
2abae09fa4 | |||
eaba43c51b |
3 changed files with 10 additions and 17 deletions
|
@ -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}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue