mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
fix: declare zai manifest model catalog
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import manifest from "./openclaw.plugin.json" with { type: "json" };
|
||||
|
||||
export const ZAI_CODING_GLOBAL_BASE_URL = "https://api.z.ai/api/coding/paas/v4";
|
||||
export const ZAI_CODING_CN_BASE_URL = "https://open.bigmodel.cn/api/coding/paas/v4";
|
||||
@@ -7,130 +9,23 @@ export const ZAI_CN_BASE_URL = "https://open.bigmodel.cn/api/paas/v4";
|
||||
export const ZAI_DEFAULT_MODEL_ID = "glm-5.1";
|
||||
export const ZAI_DEFAULT_MODEL_REF = `zai/${ZAI_DEFAULT_MODEL_ID}`;
|
||||
|
||||
type ZaiCatalogEntry = {
|
||||
name: string;
|
||||
reasoning: boolean;
|
||||
input: ModelDefinitionConfig["input"];
|
||||
contextWindow: number;
|
||||
maxTokens: number;
|
||||
cost: ModelDefinitionConfig["cost"];
|
||||
};
|
||||
const ZAI_MANIFEST_CATALOG = manifest.modelCatalog.providers.zai;
|
||||
const ZAI_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
|
||||
providerId: "zai",
|
||||
catalog: ZAI_MANIFEST_CATALOG,
|
||||
});
|
||||
const ZAI_MODEL_CATALOG = new Map(
|
||||
ZAI_MANIFEST_PROVIDER.models.map((model) => [model.id, model] as const),
|
||||
);
|
||||
|
||||
export const ZAI_DEFAULT_COST = {
|
||||
input: 1,
|
||||
output: 3.2,
|
||||
cacheRead: 0.2,
|
||||
cacheWrite: 0,
|
||||
} satisfies ModelDefinitionConfig["cost"];
|
||||
|
||||
const ZAI_MODEL_CATALOG = {
|
||||
"glm-5.1": {
|
||||
name: "GLM-5.1",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 202800,
|
||||
maxTokens: 131100,
|
||||
cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
|
||||
},
|
||||
"glm-5": {
|
||||
name: "GLM-5",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 202800,
|
||||
maxTokens: 131100,
|
||||
cost: ZAI_DEFAULT_COST,
|
||||
},
|
||||
"glm-5-turbo": {
|
||||
name: "GLM-5 Turbo",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 202800,
|
||||
maxTokens: 131100,
|
||||
cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
|
||||
},
|
||||
"glm-5v-turbo": {
|
||||
name: "GLM-5V Turbo",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: 202800,
|
||||
maxTokens: 131100,
|
||||
cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.7": {
|
||||
name: "GLM-4.7",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 204800,
|
||||
maxTokens: 131072,
|
||||
cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.7-flash": {
|
||||
name: "GLM-4.7 Flash",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 200000,
|
||||
maxTokens: 131072,
|
||||
cost: { input: 0.07, output: 0.4, cacheRead: 0, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.7-flashx": {
|
||||
name: "GLM-4.7 FlashX",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 200000,
|
||||
maxTokens: 128000,
|
||||
cost: { input: 0.06, output: 0.4, cacheRead: 0.01, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.6": {
|
||||
name: "GLM-4.6",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 204800,
|
||||
maxTokens: 131072,
|
||||
cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.6v": {
|
||||
name: "GLM-4.6V",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: 128000,
|
||||
maxTokens: 32768,
|
||||
cost: { input: 0.3, output: 0.9, cacheRead: 0, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.5": {
|
||||
name: "GLM-4.5",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 131072,
|
||||
maxTokens: 98304,
|
||||
cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.5-air": {
|
||||
name: "GLM-4.5 Air",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 131072,
|
||||
maxTokens: 98304,
|
||||
cost: { input: 0.2, output: 1.1, cacheRead: 0.03, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.5-flash": {
|
||||
name: "GLM-4.5 Flash",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: 131072,
|
||||
maxTokens: 98304,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
},
|
||||
"glm-4.5v": {
|
||||
name: "GLM-4.5V",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: 64000,
|
||||
maxTokens: 16384,
|
||||
cost: { input: 0.6, output: 1.8, cacheRead: 0, cacheWrite: 0 },
|
||||
},
|
||||
} as const satisfies Record<string, ZaiCatalogEntry>;
|
||||
|
||||
type ZaiCatalogId = keyof typeof ZAI_MODEL_CATALOG;
|
||||
export const ZAI_DEFAULT_COST =
|
||||
ZAI_MODEL_CATALOG.get("glm-5")?.cost ??
|
||||
({
|
||||
input: 1,
|
||||
output: 3.2,
|
||||
cacheRead: 0.2,
|
||||
cacheWrite: 0,
|
||||
} satisfies ModelDefinitionConfig["cost"]);
|
||||
|
||||
export function resolveZaiBaseUrl(endpoint?: string): string {
|
||||
switch (endpoint) {
|
||||
@@ -147,6 +42,10 @@ export function resolveZaiBaseUrl(endpoint?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function buildZaiCatalogModels(): ModelDefinitionConfig[] {
|
||||
return ZAI_MANIFEST_PROVIDER.models.map((model) => ({ ...model, input: [...model.input] }));
|
||||
}
|
||||
|
||||
export function buildZaiModelDefinition(params: {
|
||||
id: string;
|
||||
name?: string;
|
||||
@@ -156,7 +55,7 @@ export function buildZaiModelDefinition(params: {
|
||||
contextWindow?: number;
|
||||
maxTokens?: number;
|
||||
}): ModelDefinitionConfig {
|
||||
const catalog = ZAI_MODEL_CATALOG[params.id as ZaiCatalogId];
|
||||
const catalog = ZAI_MODEL_CATALOG.get(params.id);
|
||||
return {
|
||||
id: params.id,
|
||||
name: params.name ?? catalog?.name ?? `GLM ${params.id}`,
|
||||
|
||||
@@ -4,29 +4,13 @@ import {
|
||||
} from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import {
|
||||
buildZaiModelDefinition,
|
||||
buildZaiCatalogModels,
|
||||
resolveZaiBaseUrl,
|
||||
ZAI_DEFAULT_MODEL_ID,
|
||||
} from "./model-definitions.js";
|
||||
|
||||
export const ZAI_DEFAULT_MODEL_REF = `zai/${ZAI_DEFAULT_MODEL_ID}`;
|
||||
|
||||
const ZAI_DEFAULT_MODELS = [
|
||||
buildZaiModelDefinition({ id: "glm-5.1" }),
|
||||
buildZaiModelDefinition({ id: "glm-5" }),
|
||||
buildZaiModelDefinition({ id: "glm-5-turbo" }),
|
||||
buildZaiModelDefinition({ id: "glm-5v-turbo" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.7" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.7-flash" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.7-flashx" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.6" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.6v" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.5" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.5-air" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.5-flash" }),
|
||||
buildZaiModelDefinition({ id: "glm-4.5v" }),
|
||||
];
|
||||
|
||||
function resolveZaiPresetBaseUrl(cfg: OpenClawConfig, endpoint?: string): string {
|
||||
const existingProvider = cfg.models?.providers?.zai;
|
||||
const existingBaseUrl = normalizeOptionalString(existingProvider?.baseUrl) ?? "";
|
||||
@@ -44,7 +28,7 @@ function applyZaiPreset(
|
||||
providerId: "zai",
|
||||
api: "openai-completions",
|
||||
baseUrl: resolveZaiPresetBaseUrl(cfg, params?.endpoint),
|
||||
catalogModels: ZAI_DEFAULT_MODELS,
|
||||
catalogModels: buildZaiCatalogModels(),
|
||||
aliases: [{ modelRef, alias: "GLM" }],
|
||||
primaryModelRef,
|
||||
});
|
||||
|
||||
@@ -18,6 +18,210 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"setup": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "zai",
|
||||
"authMethods": ["api-key"],
|
||||
"envVars": ["ZAI_API_KEY", "Z_AI_API_KEY"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"modelCatalog": {
|
||||
"providers": {
|
||||
"zai": {
|
||||
"baseUrl": "https://api.z.ai/api/paas/v4",
|
||||
"api": "openai-completions",
|
||||
"models": [
|
||||
{
|
||||
"id": "glm-5.1",
|
||||
"name": "GLM-5.1",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 202800,
|
||||
"maxTokens": 131100,
|
||||
"cost": {
|
||||
"input": 1.2,
|
||||
"output": 4,
|
||||
"cacheRead": 0.24,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-5",
|
||||
"name": "GLM-5",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 202800,
|
||||
"maxTokens": 131100,
|
||||
"cost": {
|
||||
"input": 1,
|
||||
"output": 3.2,
|
||||
"cacheRead": 0.2,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-5-turbo",
|
||||
"name": "GLM-5 Turbo",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 202800,
|
||||
"maxTokens": 131100,
|
||||
"cost": {
|
||||
"input": 1.2,
|
||||
"output": 4,
|
||||
"cacheRead": 0.24,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-5v-turbo",
|
||||
"name": "GLM-5V Turbo",
|
||||
"reasoning": true,
|
||||
"input": ["text", "image"],
|
||||
"contextWindow": 202800,
|
||||
"maxTokens": 131100,
|
||||
"cost": {
|
||||
"input": 1.2,
|
||||
"output": 4,
|
||||
"cacheRead": 0.24,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.7",
|
||||
"name": "GLM-4.7",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 204800,
|
||||
"maxTokens": 131072,
|
||||
"cost": {
|
||||
"input": 0.6,
|
||||
"output": 2.2,
|
||||
"cacheRead": 0.11,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.7-flash",
|
||||
"name": "GLM-4.7 Flash",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 200000,
|
||||
"maxTokens": 131072,
|
||||
"cost": {
|
||||
"input": 0.07,
|
||||
"output": 0.4,
|
||||
"cacheRead": 0,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.7-flashx",
|
||||
"name": "GLM-4.7 FlashX",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 200000,
|
||||
"maxTokens": 128000,
|
||||
"cost": {
|
||||
"input": 0.06,
|
||||
"output": 0.4,
|
||||
"cacheRead": 0.01,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.6",
|
||||
"name": "GLM-4.6",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 204800,
|
||||
"maxTokens": 131072,
|
||||
"cost": {
|
||||
"input": 0.6,
|
||||
"output": 2.2,
|
||||
"cacheRead": 0.11,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.6v",
|
||||
"name": "GLM-4.6V",
|
||||
"reasoning": true,
|
||||
"input": ["text", "image"],
|
||||
"contextWindow": 128000,
|
||||
"maxTokens": 32768,
|
||||
"cost": {
|
||||
"input": 0.3,
|
||||
"output": 0.9,
|
||||
"cacheRead": 0,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.5",
|
||||
"name": "GLM-4.5",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 131072,
|
||||
"maxTokens": 98304,
|
||||
"cost": {
|
||||
"input": 0.6,
|
||||
"output": 2.2,
|
||||
"cacheRead": 0.11,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.5-air",
|
||||
"name": "GLM-4.5 Air",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 131072,
|
||||
"maxTokens": 98304,
|
||||
"cost": {
|
||||
"input": 0.2,
|
||||
"output": 1.1,
|
||||
"cacheRead": 0.03,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.5-flash",
|
||||
"name": "GLM-4.5 Flash",
|
||||
"reasoning": true,
|
||||
"input": ["text"],
|
||||
"contextWindow": 131072,
|
||||
"maxTokens": 98304,
|
||||
"cost": {
|
||||
"input": 0,
|
||||
"output": 0,
|
||||
"cacheRead": 0,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm-4.5v",
|
||||
"name": "GLM-4.5V",
|
||||
"reasoning": true,
|
||||
"input": ["text", "image"],
|
||||
"contextWindow": 64000,
|
||||
"maxTokens": 16384,
|
||||
"cost": {
|
||||
"input": 0.6,
|
||||
"output": 1.8,
|
||||
"cacheRead": 0,
|
||||
"cacheWrite": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"discovery": {
|
||||
"zai": "static"
|
||||
}
|
||||
},
|
||||
"modelPricing": {
|
||||
"providers": {
|
||||
"zai": {
|
||||
@@ -30,9 +234,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"providerAuthEnvVars": {
|
||||
"zai": ["ZAI_API_KEY", "Z_AI_API_KEY"]
|
||||
},
|
||||
"providerAuthChoices": [
|
||||
{
|
||||
"provider": "zai",
|
||||
|
||||
Reference in New Issue
Block a user