Files
openclaw/extensions/ollama/src/stream-api.ts
Vincent Koc 2fc2fc930b improve(ollama): reduce inactive startup cost (#119745)
* improve(ollama): defer optional runtime imports

Punchcard-Session: coral-workshop-workshop-3f

* improve(ollama): isolate lazy runtime modules

* improve(ollama): preserve lazy runtime boundaries
2026-08-06 07:40:22 +08:00

32 lines
1.5 KiB
TypeScript

import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
export {
createConfiguredOllamaCompatStreamWrapper,
isOllamaCompatProvider,
resolveOllamaCompatNumCtxEnabled,
shouldInjectOllamaCompatNumCtx,
wrapOllamaCompatNumCtx,
} from "./stream-compat.js";
type OllamaStreamRuntime = typeof import("./stream.runtime.js");
const loadOllamaStreamRuntime = createLazyRuntimeModule(() => import("./stream.runtime.js"));
const ollamaStreamRuntime = await loadOllamaStreamRuntime();
export const OLLAMA_NATIVE_BASE_URL: OllamaStreamRuntime["OLLAMA_NATIVE_BASE_URL"] =
ollamaStreamRuntime.OLLAMA_NATIVE_BASE_URL;
export const resolveOllamaBaseUrlForRun: OllamaStreamRuntime["resolveOllamaBaseUrlForRun"] =
ollamaStreamRuntime.resolveOllamaBaseUrlForRun;
export const buildOllamaChatRequest: OllamaStreamRuntime["buildOllamaChatRequest"] =
ollamaStreamRuntime.buildOllamaChatRequest;
export const convertToOllamaMessages: OllamaStreamRuntime["convertToOllamaMessages"] =
ollamaStreamRuntime.convertToOllamaMessages;
export const buildAssistantMessage: OllamaStreamRuntime["buildAssistantMessage"] =
ollamaStreamRuntime.buildAssistantMessage;
export const parseNdjsonStream: OllamaStreamRuntime["parseNdjsonStream"] =
ollamaStreamRuntime.parseNdjsonStream;
export const createOllamaStreamFn: OllamaStreamRuntime["createOllamaStreamFn"] =
ollamaStreamRuntime.createOllamaStreamFn;
export const createConfiguredOllamaStreamFn: OllamaStreamRuntime["createConfiguredOllamaStreamFn"] =
ollamaStreamRuntime.createConfiguredOllamaStreamFn;