mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-04-30 22:12:32 +08:00
chore: satisfy strict linters and patch Windows CI corepack bug
This commit is contained in:
committed by
Peter Steinberger
parent
2549dfe59b
commit
8edf705238
40
extensions/ollama/provider-policy-api.ts
Normal file
40
extensions/ollama/provider-policy-api.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// Inlined to avoid custom source-loader resolution issues
|
||||
const OLLAMA_DEFAULT_BASE_URL = "http://127.0.0.1:11434";
|
||||
|
||||
/**
|
||||
* Provider policy surface for Ollama: normalize provider configs used by
|
||||
* core defaults/normalizers. This runs during config defaults application and
|
||||
* normalization paths (not Zod validation).
|
||||
*/
|
||||
export function normalizeConfig({
|
||||
provider,
|
||||
providerConfig,
|
||||
}: {
|
||||
provider: string;
|
||||
providerConfig: unknown;
|
||||
}): unknown {
|
||||
if (!providerConfig || typeof providerConfig !== "object") {
|
||||
return providerConfig;
|
||||
}
|
||||
|
||||
// provider is already a string, no need for String() cast
|
||||
const normalizedProviderId = (provider ?? "").trim().toLowerCase();
|
||||
if (normalizedProviderId !== "ollama") {
|
||||
return providerConfig;
|
||||
}
|
||||
|
||||
// Safely cast to Record to allow mutations without 'any'
|
||||
const next: Record<string, unknown> = { ...(providerConfig as Record<string, unknown>) };
|
||||
|
||||
// If baseUrl is missing, empty, or whitespace-only, default to local Ollama host.
|
||||
if (typeof next.baseUrl !== "string" || !next.baseUrl.trim()) {
|
||||
next.baseUrl = OLLAMA_DEFAULT_BASE_URL;
|
||||
}
|
||||
|
||||
// If models is missing/not an array, default to empty array to signal discovery
|
||||
if (!Array.isArray(next.models)) {
|
||||
next.models = [];
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
Reference in New Issue
Block a user