2026-03-16 21:13:56 -07:00
|
|
|
import type {
|
|
|
|
|
ModelDefinitionConfig,
|
|
|
|
|
ModelProviderConfig,
|
|
|
|
|
} from "openclaw/plugin-sdk/provider-models";
|
2026-03-16 18:33:07 -07:00
|
|
|
|
|
|
|
|
export const QWEN_PORTAL_BASE_URL = "https://portal.qwen.ai/v1";
|
|
|
|
|
const QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW = 128000;
|
|
|
|
|
const QWEN_PORTAL_DEFAULT_MAX_TOKENS = 8192;
|
|
|
|
|
const QWEN_PORTAL_DEFAULT_COST = {
|
|
|
|
|
input: 0,
|
|
|
|
|
output: 0,
|
|
|
|
|
cacheRead: 0,
|
|
|
|
|
cacheWrite: 0,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function buildModelDefinition(params: {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
input: ModelDefinitionConfig["input"];
|
|
|
|
|
}): ModelDefinitionConfig {
|
|
|
|
|
return {
|
|
|
|
|
id: params.id,
|
|
|
|
|
name: params.name,
|
|
|
|
|
reasoning: false,
|
|
|
|
|
input: params.input,
|
|
|
|
|
cost: QWEN_PORTAL_DEFAULT_COST,
|
|
|
|
|
contextWindow: QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW,
|
|
|
|
|
maxTokens: QWEN_PORTAL_DEFAULT_MAX_TOKENS,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function buildQwenPortalProvider(): ModelProviderConfig {
|
|
|
|
|
return {
|
|
|
|
|
baseUrl: QWEN_PORTAL_BASE_URL,
|
|
|
|
|
api: "openai-completions",
|
|
|
|
|
models: [
|
|
|
|
|
buildModelDefinition({
|
|
|
|
|
id: "coder-model",
|
|
|
|
|
name: "Qwen Coder",
|
|
|
|
|
input: ["text"],
|
|
|
|
|
}),
|
|
|
|
|
buildModelDefinition({
|
|
|
|
|
id: "vision-model",
|
|
|
|
|
name: "Qwen Vision",
|
|
|
|
|
input: ["text", "image"],
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
}
|