Complete functionality
This commit is contained in:
parent
675418f411
commit
9b5fa56215
5 changed files with 75 additions and 119 deletions
|
|
@ -30,6 +30,10 @@ public class SecureChatCompletion {
|
|||
this(baseUrl, false, apiKey, true, null, Constants.DEFAULT_MAX_RETRIES);
|
||||
}
|
||||
|
||||
public SecureChatCompletion(String baseUrl, String apiKey, boolean allowHttp) {
|
||||
this(baseUrl, allowHttp, apiKey, true, null, Constants.DEFAULT_MAX_RETRIES);
|
||||
}
|
||||
|
||||
public SecureChatCompletion(String baseUrl) {
|
||||
this(baseUrl, false, null, true, null, Constants.DEFAULT_MAX_RETRIES);
|
||||
}
|
||||
|
|
@ -132,20 +136,10 @@ public class SecureChatCompletion {
|
|||
throw new RuntimeException("Request interrupted", e);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
switch (cause) {
|
||||
case SecurityError securityError -> throw new RuntimeException(cause);
|
||||
case InvalidRequestError invalidRequestError -> throw new RuntimeException(cause);
|
||||
case AuthenticationError authenticationError -> throw new RuntimeException(cause);
|
||||
case ForbiddenError forbiddenError -> throw new RuntimeException(cause);
|
||||
case RateLimitError rateLimitError -> throw new RuntimeException(cause);
|
||||
case ServerError serverError -> throw new RuntimeException(cause);
|
||||
case ServiceUnavailableError serviceUnavailableError -> throw new RuntimeException(cause);
|
||||
case APIError apiError -> throw new RuntimeException(cause);
|
||||
case APIConnectionError apiConnectionError -> throw new RuntimeException(cause);
|
||||
case SecureCompletionClient.ValueError valueError -> throw new IllegalArgumentException(cause);
|
||||
default ->
|
||||
throw new RuntimeException("Request failed: " + cause.getMessage(), cause);
|
||||
if (cause instanceof SecureCompletionClient.ValueError) {
|
||||
throw new IllegalArgumentException(cause);
|
||||
}
|
||||
throw new RuntimeException(cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue