fix: expose implemented async relay executors
This commit is contained in:
1 parent
d8e05beb13
commit
ea9069e332
2 files changed
+34
-5
No files matched your search
@@ -517,11 +517,15 @@ public class CatalogService {
|
|||||||
model.put("status", resultSet.getString("status"));
|
model.put("status", resultSet.getString("status"));
|
||||||
String providerCode = resultSet.getString("provider_code");
|
String providerCode = resultSet.getString("provider_code");
|
||||||
String providerProtocol = resultSet.getString("provider_protocol");
|
String providerProtocol = resultSet.getString("provider_protocol");
|
||||||
// Only adapters that are implemented and verified are published as
|
// Keep the catalog state aligned with the real async adapters. The
|
||||||
// executable. Relay catalog rows stay visibly pending until their
|
// OpenAI-compatible adapter handles image, video and speech tasks for
|
||||||
// provider endpoint has been configured and tested; protocol alone is
|
// relay providers; it does not claim support for arbitrary async
|
||||||
// not proof that an image/video/audio task API exists.
|
// model types. Provider-specific adapters cover Tripo 3D and
|
||||||
boolean asyncExecutor = List.of("provider-mock", "provider-vast", "provider-bytedance").contains(resultSet.getString("provider_id"));
|
// Seedance. This prevents a relay route from being shown as
|
||||||
|
// "异步执行器待接入" when the execution path is already implemented,
|
||||||
|
// while unsupported task types remain visibly pending.
|
||||||
|
boolean asyncExecutor = asyncExecutorReady(
|
||||||
|
resultSet.getString("provider_id"), providerProtocol, resultSet.getString("model_type"));
|
||||||
model.put("executionReady", !"async".equals(resultSet.getString("call_mode")) || asyncExecutor);
|
model.put("executionReady", !"async".equals(resultSet.getString("call_mode")) || asyncExecutor);
|
||||||
model.put("billingReady", billingReady(pricing, resultSet.getString("call_mode"), resultSet.getString("provider_id")));
|
model.put("billingReady", billingReady(pricing, resultSet.getString("call_mode"), resultSet.getString("provider_id")));
|
||||||
// Keep the internal route UUID for permission storage and expose a
|
// Keep the internal route UUID for permission storage and expose a
|
||||||
@@ -542,6 +546,12 @@ public class CatalogService {
|
|||||||
return amount != null;
|
return amount != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean asyncExecutorReady(String providerId, String providerProtocol, String modelType) {
|
||||||
|
if (List.of("provider-mock", "provider-vast", "provider-bytedance").contains(providerId)) return true;
|
||||||
|
if (!"openai-compatible".equalsIgnoreCase(providerProtocol)) return false;
|
||||||
|
return List.of("image", "video", "audio").contains(String.valueOf(modelType).toLowerCase(java.util.Locale.ROOT));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean billingReady(Map<String,Object> pricing, String mode, String providerId) {
|
private boolean billingReady(Map<String,Object> pricing, String mode, String providerId) {
|
||||||
if ("provider-mock".equals(providerId)) return true;
|
if ("provider-mock".equals(providerId)) return true;
|
||||||
if (pricing == null) return false;
|
if (pricing == null) return false;
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.moyi.controlplane.catalog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class CatalogServiceTest {
|
||||||
|
@Test
|
||||||
|
void asyncReadinessMatchesImplementedAdapters() {
|
||||||
|
assertTrue(CatalogService.asyncExecutorReady("provider-vast", "http", "3d"));
|
||||||
|
assertTrue(CatalogService.asyncExecutorReady("provider-bytedance", "http", "video"));
|
||||||
|
assertTrue(CatalogService.asyncExecutorReady("relay-provider", "openai-compatible", "image"));
|
||||||
|
assertTrue(CatalogService.asyncExecutorReady("relay-provider", "OPENAI-COMPATIBLE", "video"));
|
||||||
|
assertTrue(CatalogService.asyncExecutorReady("relay-provider", "openai-compatible", "audio"));
|
||||||
|
assertFalse(CatalogService.asyncExecutorReady("relay-provider", "openai-compatible", "3d"));
|
||||||
|
assertFalse(CatalogService.asyncExecutorReady("relay-provider", "http", "video"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user