Merge 73af69bd21 into 09be5d45d5
This commit is contained in:
commit
a188d9762a
@ -5,11 +5,12 @@ import { join } from "node:path";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
|
|
||||||
describe("Ollama provider", () => {
|
describe("Ollama provider", () => {
|
||||||
it("should not include ollama when no API key is configured", async () => {
|
it("should not include ollama in test environment (no local discovery)", async () => {
|
||||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||||
const providers = await resolveImplicitProviders({ agentDir });
|
const providers = await resolveImplicitProviders({ agentDir });
|
||||||
|
|
||||||
// Ollama requires explicit configuration via OLLAMA_API_KEY env var or profile
|
// In test environments, Ollama discovery is skipped and no API key is configured,
|
||||||
|
// so the provider should not be included
|
||||||
expect(providers?.ollama).toBeUndefined();
|
expect(providers?.ollama).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -446,12 +446,18 @@ export async function resolveImplicitProviders(params: {
|
|||||||
providers.xiaomi = { ...buildXiaomiProvider(), apiKey: xiaomiKey };
|
providers.xiaomi = { ...buildXiaomiProvider(), apiKey: xiaomiKey };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ollama provider - only add if explicitly configured
|
// Ollama provider - auto-discover local models, no API key needed
|
||||||
const ollamaKey =
|
const ollamaKey =
|
||||||
resolveEnvApiKeyVarName("ollama") ??
|
resolveEnvApiKeyVarName("ollama") ??
|
||||||
resolveApiKeyFromProfiles({ provider: "ollama", store: authStore });
|
resolveApiKeyFromProfiles({ provider: "ollama", store: authStore });
|
||||||
if (ollamaKey) {
|
const ollamaProvider = await buildOllamaProvider();
|
||||||
providers.ollama = { ...(await buildOllamaProvider()), apiKey: ollamaKey };
|
// Add provider if models are discovered OR if explicitly configured with API key
|
||||||
|
if (ollamaProvider.models.length > 0 || ollamaKey) {
|
||||||
|
providers.ollama = {
|
||||||
|
...ollamaProvider,
|
||||||
|
// Use configured key if available, otherwise use placeholder for local auth
|
||||||
|
apiKey: ollamaKey ?? "local",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return providers;
|
return providers;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user