mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:20:43 +00:00
fix(providers): isolate model discovery test env guards
This commit is contained in:
5
extensions/chutes/model-discovery-env.ts
Normal file
5
extensions/chutes/model-discovery-env.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export function isChutesModelDiscoveryTestEnvironment(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): boolean {
|
||||
return env.NODE_ENV === "test" || env.VITEST === "true";
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalString,
|
||||
} from "openclaw/plugin-sdk/text-runtime";
|
||||
import { isChutesModelDiscoveryTestEnvironment } from "./model-discovery-env.js";
|
||||
|
||||
const log = createSubsystemLogger("chutes-models");
|
||||
|
||||
@@ -518,7 +519,7 @@ export async function discoverChutesModels(accessToken?: string): Promise<ModelD
|
||||
return cached.models;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === "test" || process.env.VITEST === "true") {
|
||||
if (isChutesModelDiscoveryTestEnvironment()) {
|
||||
return CHUTES_MODEL_CATALOG.map(buildChutesModelDefinition);
|
||||
}
|
||||
|
||||
|
||||
5
extensions/huggingface/model-discovery-env.ts
Normal file
5
extensions/huggingface/model-discovery-env.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export function isHuggingfaceModelDiscoveryTestEnvironment(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): boolean {
|
||||
return env.VITEST === "true" || env.NODE_ENV === "test";
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-types";
|
||||
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { isHuggingfaceModelDiscoveryTestEnvironment } from "./model-discovery-env.js";
|
||||
|
||||
export const HUGGINGFACE_BASE_URL = "https://router.huggingface.co/v1";
|
||||
export const HUGGINGFACE_POLICY_SUFFIXES = ["cheapest", "fastest"] as const;
|
||||
@@ -129,7 +130,7 @@ export async function discoverHuggingfaceModels(
|
||||
apiKey: string,
|
||||
timeoutMs = HUGGINGFACE_DISCOVERY_TIMEOUT_MS,
|
||||
): Promise<ModelDefinitionConfig[]> {
|
||||
if (process.env.VITEST === "true" || process.env.NODE_ENV === "test") {
|
||||
if (isHuggingfaceModelDiscoveryTestEnvironment()) {
|
||||
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user