Files
Netcatty/infrastructure/ai/ollamaCompatBaseUrl.ts
T
bincxz b701df8822 fix(ai): align Catty thinking levels with vendor capabilities
Stop advertising Gemini 3.7 Flash minimal, GPT-5.x-chat reasoning, and
Claude 4.7+ extended thinking. Map GPT-5 Off to minimal, send adaptive
effort on Claude 4.6+, and keep composer Enter on an exact or custom id.
2026-08-20 11:05:12 +08:00

20 lines
762 B
TypeScript

/**
* Ollama Cloud uses the OpenAI-compat host https://ollama.com/v1.
* A bare https://ollama.com origin hits the marketing homepage (HTML) instead
* of /v1/chat/completions. Local Ollama stays on localhost and is unchanged.
*/
/** Append /v1 when the user entered the Cloud origin without an API prefix. */
export function normalizeOllamaSdkBaseURL(baseURL: string): string {
const trimmed = baseURL.trim().replace(/\/+$/, '');
if (/^https?:\/\/ollama\.com$/i.test(trimmed)) {
return `${trimmed}/v1`;
}
// Native Cloud docs use /api; the OpenAI SDK talks to /v1/chat/completions.
const nativeCloud = trimmed.match(/^(https?:\/\/ollama\.com)\/api$/i);
if (nativeCloud) {
return `${nativeCloud[1]}/v1`;
}
return trimmed || baseURL;
}