mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-10 03:59:43 +00:00
fix: get/validate credentials outside of EDT (fixes #374)
This commit is contained in:
parent
e23aac95b4
commit
dc8dcb1564
1 changed files with 9 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Stream;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.sse.EventSource;
|
||||
|
|
@ -185,10 +186,16 @@ public final class CompletionRequestService {
|
|||
}
|
||||
|
||||
public static boolean isRequestAllowed() {
|
||||
return isRequestAllowed(GeneralSettings.getSelectedService());
|
||||
try {
|
||||
return ApplicationManager.getApplication()
|
||||
.executeOnPooledThread(() -> isRequestAllowed(GeneralSettings.getSelectedService()))
|
||||
.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRequestAllowed(ServiceType serviceType) {
|
||||
private static boolean isRequestAllowed(ServiceType serviceType) {
|
||||
return switch (serviceType) {
|
||||
case OPENAI -> CredentialsStore.INSTANCE.isCredentialSet(CredentialKey.OPENAI_API_KEY);
|
||||
case AZURE -> CredentialsStore.INSTANCE.isCredentialSet(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue