mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-12 22:06:05 +00:00
* feat(models): add chat model registration with hot reload * docs(changelog): add models entry for pr 70211 * fix(models): harden add flow follow-ups * fix models add review follow-ups * harden models add config writes * tighten plugin boundary invariant * move models add adapters behind sdk facades * avoid ollama-specific core facade
106 lines
2.4 KiB
TypeScript
106 lines
2.4 KiB
TypeScript
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
|
|
import { buildCommandsPaginationKeyboard } from "openclaw/plugin-sdk/telegram-command-ui";
|
|
import {
|
|
buildBrowseProvidersButton,
|
|
buildModelsKeyboard,
|
|
buildProviderKeyboard,
|
|
type ProviderInfo,
|
|
} from "./model-buttons.js";
|
|
|
|
export { buildCommandsPaginationKeyboard };
|
|
|
|
export function buildTelegramModelsMenuButtons(params: { providers: ProviderInfo[] }) {
|
|
return [
|
|
[{ text: "Add model", callback_data: "/models add" }],
|
|
...buildProviderKeyboard(params.providers),
|
|
];
|
|
}
|
|
|
|
export function buildTelegramModelsMenuChannelData(params: {
|
|
providers: ProviderInfo[];
|
|
}): ReplyPayload["channelData"] | null {
|
|
if (params.providers.length === 0) {
|
|
return null;
|
|
}
|
|
return {
|
|
telegram: {
|
|
buttons: buildTelegramModelsMenuButtons(params),
|
|
},
|
|
};
|
|
}
|
|
|
|
export function buildTelegramCommandsListChannelData(params: {
|
|
currentPage: number;
|
|
totalPages: number;
|
|
agentId?: string;
|
|
}): ReplyPayload["channelData"] | null {
|
|
if (params.totalPages <= 1) {
|
|
return null;
|
|
}
|
|
return {
|
|
telegram: {
|
|
buttons: buildCommandsPaginationKeyboard(
|
|
params.currentPage,
|
|
params.totalPages,
|
|
params.agentId,
|
|
),
|
|
},
|
|
};
|
|
}
|
|
|
|
export function buildTelegramModelsProviderChannelData(params: {
|
|
providers: ProviderInfo[];
|
|
}): ReplyPayload["channelData"] | null {
|
|
if (params.providers.length === 0) {
|
|
return null;
|
|
}
|
|
return {
|
|
telegram: {
|
|
buttons: buildProviderKeyboard(params.providers),
|
|
},
|
|
};
|
|
}
|
|
|
|
export function buildTelegramModelsAddProviderChannelData(params: {
|
|
providers: Array<{ id: string }>;
|
|
}): ReplyPayload["channelData"] | null {
|
|
if (params.providers.length === 0) {
|
|
return null;
|
|
}
|
|
const buttons = params.providers.map((provider) => [
|
|
{
|
|
text: provider.id,
|
|
callback_data: `/models add ${provider.id}`,
|
|
},
|
|
]);
|
|
return {
|
|
telegram: {
|
|
buttons,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function buildTelegramModelsListChannelData(params: {
|
|
provider: string;
|
|
models: readonly string[];
|
|
currentModel?: string;
|
|
currentPage: number;
|
|
totalPages: number;
|
|
pageSize?: number;
|
|
modelNames?: ReadonlyMap<string, string>;
|
|
}): ReplyPayload["channelData"] | null {
|
|
return {
|
|
telegram: {
|
|
buttons: buildModelsKeyboard(params),
|
|
},
|
|
};
|
|
}
|
|
|
|
export function buildTelegramModelBrowseChannelData(): ReplyPayload["channelData"] {
|
|
return {
|
|
telegram: {
|
|
buttons: buildBrowseProvidersButton(),
|
|
},
|
|
};
|
|
}
|