-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update AI console function. (#360)
- Loading branch information
Showing
18 changed files
with
257 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
backend/sdk/src/main/java/com/alibaba/higress/sdk/model/ai/AiRouteAuthConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.alibaba.higress.sdk.model.ai; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import com.alibaba.higress.sdk.exception.ValidationException; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AiRouteAuthConfig { | ||
|
||
private Boolean enabled; | ||
private List<String> allowedConsumers; | ||
|
||
public void validate() { | ||
if (Boolean.TRUE.equals(enabled) && CollectionUtils.isEmpty(allowedConsumers)) { | ||
throw new ValidationException("allowedConsumers cannot be empty when auth is enabled."); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
backend/sdk/src/main/java/com/alibaba/higress/sdk/model/ai/AiRouteFallbackConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.alibaba.higress.sdk.model.ai; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import com.alibaba.higress.sdk.exception.ValidationException; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AiRouteFallbackConfig { | ||
|
||
private Boolean enabled; | ||
private List<AiUpstream> upstreams; | ||
private String fallbackStrategy; | ||
|
||
public void validate() { | ||
if (!Boolean.TRUE.equals(enabled)) { | ||
return; | ||
} | ||
if (StringUtils.isNotEmpty(fallbackStrategy)) { | ||
switch (fallbackStrategy) { | ||
case AiRouteFallbackStrategy.RANDOM: | ||
case AiRouteFallbackStrategy.SEQUENCE: | ||
break; | ||
default: | ||
throw new ValidationException("unknown fallback strategy: " + fallbackStrategy); | ||
} | ||
} | ||
if (CollectionUtils.isEmpty(upstreams)) { | ||
throw new ValidationException("upstreams cannot be empty when fallback is enabled."); | ||
} | ||
upstreams.forEach(AiUpstream::validate); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
backend/sdk/src/main/java/com/alibaba/higress/sdk/model/ai/AiRouteFallbackStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.alibaba.higress.sdk.model.ai; | ||
|
||
public final class AiRouteFallbackStrategy { | ||
|
||
private AiRouteFallbackStrategy() { | ||
} | ||
|
||
public static final String RANDOM = "RAND"; | ||
|
||
public static final String SEQUENCE = "SEQ"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.