Skip to content

Commit

Permalink
fix: Fix some issues in AI console (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
CH3CHO authored Jan 6, 2025
1 parent 73f0a62 commit d234655
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ public class AiProxyConfig {
public static final String FAILOVER_HEALTH_CHECK_INTERVAL = "healthCheckInterval";
public static final String FAILOVER_HEALTH_CHECK_TIMEOUT = "healthCheckTimeout";
public static final String FAILOVER_HEALTH_CHECK_MODEL = "healthCheckModel";

public static final String RETRY_ON_FAILURE = "retryOnFailure";
public static final String RETRY_ENABLED = "enabled";
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public class KeyAuthConfig {
public static final String IN_QUERY = "in_query";

public static final String ALLOW = "allow";
public static final String GLOBAL_AUTH = "global_auth";
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import static com.alibaba.higress.sdk.constant.plugin.config.AiProxyConfig.PROVIDER_API_TOKENS;
import static com.alibaba.higress.sdk.constant.plugin.config.AiProxyConfig.PROVIDER_ID;
import static com.alibaba.higress.sdk.constant.plugin.config.AiProxyConfig.PROVIDER_TYPE;
import static com.alibaba.higress.sdk.constant.plugin.config.AiProxyConfig.RETRY_ENABLED;
import static com.alibaba.higress.sdk.constant.plugin.config.AiProxyConfig.RETRY_ON_FAILURE;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -109,10 +111,13 @@ public void saveConfig(LlmProvider provider, Map<String, Object> configurations)
TokenFailoverConfig failoverConfig = provider.getTokenFailoverConfig();
if (failoverConfig == null) {
configurations.remove(FAILOVER);
configurations.remove(RETRY_ON_FAILURE);
} else {
Map<String, Object> failoverMap = new HashMap<>();
saveTokenFailoverConfig(failoverConfig, failoverMap);
configurations.put(FAILOVER, failoverMap);
Map<String, Object> retryOnFailureMap = Map.of(RETRY_ENABLED, failoverConfig.getEnabled());
configurations.put(RETRY_ON_FAILURE, retryOnFailureMap);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.ALLOW;
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.CONSUMERS;
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.CONSUMER_CREDENTIAL;
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.GLOBAL_AUTH;
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.IN_HEADER;
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.IN_QUERY;
import static com.alibaba.higress.sdk.constant.plugin.config.KeyAuthConfig.KEYS;
Expand Down Expand Up @@ -185,6 +186,7 @@ public boolean saveConsumer(WasmPluginInstance instance, Consumer consumer) {
consumerConfig.put(CONSUMER_CREDENTIAL, credential);

configurations.put(CONSUMERS, consumers);
configurations.put(GLOBAL_AUTH, false);
return true;
}

Expand Down
Loading

0 comments on commit d234655

Please sign in to comment.