mirror of https://github.com/openclaw/openclaw.git
test(openai): fix ModelRegistry constructor typing
This commit is contained in:
parent
1816d6a4ed
commit
bb912daaed
|
|
@ -43,6 +43,9 @@ const LIVE_VISION_MODEL = process.env.OPENCLAW_LIVE_OPENAI_VISION_MODEL?.trim()
|
|||
const liveEnabled = OPENAI_API_KEY.trim().length > 0 && process.env.OPENCLAW_LIVE_TEST === "1";
|
||||
const describeLive = liveEnabled ? describe : describe.skip;
|
||||
const EMPTY_AUTH_STORE = { version: 1, profiles: {} } as const;
|
||||
const ModelRegistryCtor = ModelRegistry as unknown as {
|
||||
new (authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry;
|
||||
};
|
||||
|
||||
function resolveTemplateModelId(modelId: string) {
|
||||
switch (modelId) {
|
||||
|
|
@ -58,7 +61,7 @@ function resolveTemplateModelId(modelId: string) {
|
|||
}
|
||||
|
||||
function createTemplateModelRegistry(modelId: string): ModelRegistry {
|
||||
const registry = ModelRegistry.inMemory(AuthStorage.inMemory());
|
||||
const registry = new ModelRegistryCtor(AuthStorage.inMemory());
|
||||
const template = getModel("openai", resolveTemplateModelId(modelId));
|
||||
registry.registerProvider("openai", {
|
||||
apiKey: "test",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ const LIVE_MODEL_ID =
|
|||
process.env.OPENCLAW_LIVE_OPENROUTER_PLUGIN_MODEL?.trim() || "openai/gpt-5.4-nano";
|
||||
const liveEnabled = OPENROUTER_API_KEY.trim().length > 0 && process.env.OPENCLAW_LIVE_TEST === "1";
|
||||
const describeLive = liveEnabled ? describe : describe.skip;
|
||||
const ModelRegistryCtor = ModelRegistry as unknown as {
|
||||
new (authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry;
|
||||
};
|
||||
|
||||
const registerOpenRouterPlugin = () =>
|
||||
registerProviderPlugin({
|
||||
|
|
@ -41,7 +44,7 @@ describeLive("openrouter plugin live", () => {
|
|||
const resolved = provider.resolveDynamicModel?.({
|
||||
provider: "openrouter",
|
||||
modelId: LIVE_MODEL_ID,
|
||||
modelRegistry: ModelRegistry.inMemory(AuthStorage.inMemory()),
|
||||
modelRegistry: new ModelRegistryCtor(AuthStorage.inMemory()),
|
||||
});
|
||||
if (!resolved) {
|
||||
throw new Error(`openrouter provider did not resolve ${LIVE_MODEL_ID}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue