mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:24:30 +00:00
refactor(agents): migrate console.warn/error/info to subsystem logger (#22906)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: a806c4cb27
Co-authored-by: Kepler2024 <166882517+Kepler2024@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import type { ModelDefinitionConfig } from "../config/types.models.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
|
||||
const log = createSubsystemLogger("huggingface-models");
|
||||
|
||||
/** Hugging Face Inference Providers (router) — OpenAI-compatible chat completions. */
|
||||
export const HUGGINGFACE_BASE_URL = "https://router.huggingface.co/v1";
|
||||
@@ -168,16 +171,14 @@ export async function discoverHuggingfaceModels(apiKey: string): Promise<ModelDe
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.warn(
|
||||
`[huggingface-models] GET /v1/models failed: HTTP ${response.status}, using static catalog`,
|
||||
);
|
||||
log.warn(`GET /v1/models failed: HTTP ${response.status}, using static catalog`);
|
||||
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
||||
}
|
||||
|
||||
const body = (await response.json()) as OpenAIListModelsResponse;
|
||||
const data = body?.data;
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
console.warn("[huggingface-models] No models in response, using static catalog");
|
||||
log.warn("No models in response, using static catalog");
|
||||
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ export async function discoverHuggingfaceModels(apiKey: string): Promise<ModelDe
|
||||
? models
|
||||
: HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
||||
} catch (error) {
|
||||
console.warn(`[huggingface-models] Discovery failed: ${String(error)}, using static catalog`);
|
||||
log.warn(`Discovery failed: ${String(error)}, using static catalog`);
|
||||
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user