mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(llama-cpp): keep lifecycle helpers private
This commit is contained in:
@@ -54,16 +54,15 @@ vi.mock("node-llama-cpp", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
import {
|
||||
createLlamaCppInferenceRuntime,
|
||||
llamaCppInferenceTestApi,
|
||||
type LlamaCppInferenceRuntime,
|
||||
} from "./inference-provider.js";
|
||||
import { createLlamaCppInferenceRuntime } from "./inference-provider.js";
|
||||
|
||||
if (!llamaCppInferenceTestApi) {
|
||||
throw new Error("expected llama.cpp inference test API");
|
||||
}
|
||||
const { mapContextToLlamaChatHistory, mapToolsToLlamaFunctions } = llamaCppInferenceTestApi;
|
||||
const { mapContextToLlamaChatHistory, mapToolsToLlamaFunctions } = (
|
||||
globalThis as Record<PropertyKey, unknown>
|
||||
)[Symbol.for("openclaw.llamaCppInferenceTestApi")] as {
|
||||
mapContextToLlamaChatHistory: (context: Context) => unknown[];
|
||||
mapToolsToLlamaFunctions: (context: Context) => Record<string, unknown> | undefined;
|
||||
};
|
||||
type LlamaCppInferenceRuntime = ReturnType<typeof createLlamaCppInferenceRuntime>;
|
||||
let inferenceRuntime: LlamaCppInferenceRuntime;
|
||||
|
||||
const model: Model = {
|
||||
|
||||
@@ -49,7 +49,7 @@ type LlamaCppInferenceRuntimeState = {
|
||||
disposePromise?: Promise<void>;
|
||||
};
|
||||
|
||||
export type LlamaCppInferenceRuntime = {
|
||||
type LlamaCppInferenceRuntime = {
|
||||
createStreamFn: (params: { providerConfig?: ModelProviderConfig }) => StreamFn;
|
||||
dispose: () => Promise<void>;
|
||||
};
|
||||
@@ -681,10 +681,9 @@ export function createLlamaCppInferenceRuntime(): LlamaCppInferenceRuntime {
|
||||
};
|
||||
}
|
||||
|
||||
export const llamaCppInferenceTestApi =
|
||||
process.env.VITEST || process.env.NODE_ENV === "test"
|
||||
? {
|
||||
mapContextToLlamaChatHistory,
|
||||
mapToolsToLlamaFunctions,
|
||||
}
|
||||
: undefined;
|
||||
if (process.env.VITEST || process.env.NODE_ENV === "test") {
|
||||
(globalThis as Record<PropertyKey, unknown>)[Symbol.for("openclaw.llamaCppInferenceTestApi")] = {
|
||||
mapContextToLlamaChatHistory,
|
||||
mapToolsToLlamaFunctions,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user