mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-02 00:42:49 +00:00
The automated rebrand sed script replaced "OpenClaw" with "Hanzo Bot" (with space) instead of "HanzoBot" in 8,315 TypeScript identifier occurrences across 1,632 files. This fixes all broken class names, type names, function names, and variable names. Co-authored-by: Hanzo Dev <[email protected]>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import {
|
|
applyProviderConfigWithDefaultModelsPreset,
|
|
type ModelApi,
|
|
type HanzoBotConfig,
|
|
} from "openclaw/plugin-sdk/provider-onboard";
|
|
import {
|
|
buildQianfanProvider,
|
|
QIANFAN_BASE_URL,
|
|
QIANFAN_DEFAULT_MODEL_ID,
|
|
} from "./provider-catalog.js";
|
|
|
|
export const QIANFAN_DEFAULT_MODEL_REF = `qianfan/${QIANFAN_DEFAULT_MODEL_ID}`;
|
|
|
|
function resolveQianfanPreset(cfg: HanzoBotConfig): {
|
|
api: ModelApi;
|
|
baseUrl: string;
|
|
defaultModels: NonNullable<ReturnType<typeof buildQianfanProvider>["models"]>;
|
|
} {
|
|
const defaultProvider = buildQianfanProvider();
|
|
const existingProvider = cfg.models?.providers?.qianfan as
|
|
| {
|
|
baseUrl?: unknown;
|
|
api?: unknown;
|
|
}
|
|
| undefined;
|
|
const existingBaseUrl =
|
|
typeof existingProvider?.baseUrl === "string" ? existingProvider.baseUrl.trim() : "";
|
|
const api =
|
|
typeof existingProvider?.api === "string"
|
|
? (existingProvider.api as ModelApi)
|
|
: "openai-completions";
|
|
|
|
return {
|
|
api,
|
|
baseUrl: existingBaseUrl || QIANFAN_BASE_URL,
|
|
defaultModels: defaultProvider.models ?? [],
|
|
};
|
|
}
|
|
|
|
function applyQianfanPreset(cfg: HanzoBotConfig, primaryModelRef?: string): HanzoBotConfig {
|
|
const preset = resolveQianfanPreset(cfg);
|
|
return applyProviderConfigWithDefaultModelsPreset(cfg, {
|
|
providerId: "qianfan",
|
|
api: preset.api,
|
|
baseUrl: preset.baseUrl,
|
|
defaultModels: preset.defaultModels,
|
|
defaultModelId: QIANFAN_DEFAULT_MODEL_ID,
|
|
aliases: [{ modelRef: QIANFAN_DEFAULT_MODEL_REF, alias: "QIANFAN" }],
|
|
primaryModelRef,
|
|
});
|
|
}
|
|
|
|
export function applyQianfanProviderConfig(cfg: HanzoBotConfig): HanzoBotConfig {
|
|
return applyQianfanPreset(cfg);
|
|
}
|
|
|
|
export function applyQianfanConfig(cfg: HanzoBotConfig): HanzoBotConfig {
|
|
return applyQianfanPreset(cfg, QIANFAN_DEFAULT_MODEL_REF);
|
|
}
|