mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 01:24:31 +00:00
fix(agents): skip Ollama discovery when explicit models configured (#28762)
This commit is contained in:
@@ -1021,21 +1021,33 @@ export async function resolveImplicitProviders(params: {
|
||||
// Ollama provider - auto-discover if running locally, or add if explicitly configured.
|
||||
// Use the user's configured baseUrl (from explicit providers) for model
|
||||
// discovery so that remote / non-default Ollama instances are reachable.
|
||||
// Skip discovery when explicit models are already defined.
|
||||
const ollamaKey =
|
||||
resolveEnvApiKeyVarName("ollama") ??
|
||||
resolveApiKeyFromProfiles({ provider: "ollama", store: authStore });
|
||||
const ollamaBaseUrl = params.explicitProviders?.ollama?.baseUrl;
|
||||
const hasExplicitOllamaConfig = Boolean(params.explicitProviders?.ollama);
|
||||
// Only suppress warnings for implicit local probing when user has not
|
||||
// explicitly configured Ollama.
|
||||
const ollamaProvider = await buildOllamaProvider(ollamaBaseUrl, {
|
||||
quiet: !ollamaKey && !hasExplicitOllamaConfig,
|
||||
});
|
||||
if (ollamaProvider.models.length > 0 || ollamaKey) {
|
||||
const explicitOllama = params.explicitProviders?.ollama;
|
||||
const hasExplicitModels =
|
||||
Array.isArray(explicitOllama?.models) && explicitOllama.models.length > 0;
|
||||
if (hasExplicitModels) {
|
||||
providers.ollama = {
|
||||
...ollamaProvider,
|
||||
...explicitOllama,
|
||||
api: explicitOllama.api ?? "ollama",
|
||||
apiKey: ollamaKey ?? "ollama-local",
|
||||
};
|
||||
} else {
|
||||
const ollamaBaseUrl = explicitOllama?.baseUrl;
|
||||
const hasExplicitOllamaConfig = Boolean(explicitOllama);
|
||||
// Only suppress warnings for implicit local probing when user has not
|
||||
// explicitly configured Ollama.
|
||||
const ollamaProvider = await buildOllamaProvider(ollamaBaseUrl, {
|
||||
quiet: !ollamaKey && !hasExplicitOllamaConfig,
|
||||
});
|
||||
if (ollamaProvider.models.length > 0 || ollamaKey) {
|
||||
providers.ollama = {
|
||||
...ollamaProvider,
|
||||
apiKey: ollamaKey ?? "ollama-local",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// vLLM provider - OpenAI-compatible local server (opt-in via env/profile).
|
||||
|
||||
Reference in New Issue
Block a user