Skip to content

Commit bfeb4a9

Browse files
ivicacclaude
andcommitted
1570 Replace inline Ollama key check with Provider.requiresApiKey()
Introduce Provider.requiresApiKey() (backed by a KEYLESS_PROVIDERS set, mirroring EMBEDDING_PROVIDERS/isEmbeddingSupported) and use it in place of the inline 'provider != OLLAMA' checks in resolveWithApiKey and the chat client resolver, so adding another key-less provider is a one-line change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 39ffa9b commit bfeb4a9

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

  • server
    • ee/libs/platform
    • libs/platform/platform-ai/platform-ai-api/src/main/java/com/bytechef/platform/ai/llm

server/ee/libs/platform/platform-ai/platform-ai-agent/platform-ai-agent-service/src/main/java/com/bytechef/ee/platform/ai/agent/catalog/CatalogChatClientResolverImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public CatalogChatClientResolverImpl(
5757

5858
String apiKey = aiProviderFacade.getApiKey(provider.getKey(), environment);
5959

60-
// Ollama runs locally and needs no API key, so a blank key is valid for it; all other providers require one.
61-
if ((apiKey == null || apiKey.isBlank()) && provider != Provider.OLLAMA) {
60+
if ((apiKey == null || apiKey.isBlank()) && provider.requiresApiKey()) {
6261
return null;
6362
}
6463

server/ee/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/ee/platform/configuration/facade/AiProviderFacadeImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ private AiDefaultModelWithApiKeyDTO resolveWithApiKey(AiDefaultModelDTO defaultM
346346

347347
String apiKey = resolveApiKey(provider, environment);
348348

349-
// Ollama runs locally and needs no API key, so a blank key is valid for it; all other providers require one.
350-
if ((apiKey == null || apiKey.isBlank()) && provider != Provider.OLLAMA) {
349+
if ((apiKey == null || apiKey.isBlank()) && provider.requiresApiKey()) {
351350
return null;
352351
}
353352

server/libs/platform/platform-ai/platform-ai-api/src/main/java/com/bytechef/platform/ai/llm/Provider.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public enum Provider {
6161
PERPLEXITY,
6262
VERTEX_GEMINI);
6363

64+
// Providers that authenticate against a self-hosted server rather than an API key.
65+
public static final Set<Provider> KEYLESS_PROVIDERS = EnumSet.of(OLLAMA);
66+
6467
private final int id;
6568
private final String label;
6669
private final String key;
@@ -77,6 +80,10 @@ public boolean isEmbeddingSupported() {
7780
return EMBEDDING_PROVIDERS.contains(this);
7881
}
7982

83+
public boolean requiresApiKey() {
84+
return !KEYLESS_PROVIDERS.contains(this);
85+
}
86+
8087
public int getId() {
8188
return id;
8289
}

0 commit comments

Comments
 (0)