import {Message} from "typescript-telegram-bot-api"; import {Command} from "../base/command"; import {Environment} from "../common/environment"; import {logError, replyToMessage} from "../util/utils"; import {Requirements} from "../base/requirements"; import {Requirement} from "../base/requirement"; import {ollama} from "../index"; export class OllamaSetModel extends Command { argsMode = "required" as const; title = "/ollamaSetModel"; description = "Set Ollama model"; requirements = Requirements.Build(Requirement.BOT_CREATOR); async execute(msg: Message, match?: RegExpExecArray | null): Promise { const newModel = match?.[3] || ""; if (!newModel || !newModel.length) return; try { await ollama.show({model: newModel}); Environment.setOllamaModel(newModel || Environment.OLLAMA_MODEL); const text = newModel ? `Выбрана модель "${newModel}"` : `Модель не задана. Будет использоваться стандартная модель "${Environment.OLLAMA_MODEL}".`; await replyToMessage({message: msg, text: text}).catch(logError); } catch (e: any) { logError(e); await replyToMessage({message: msg, text: e.toString()}).catch(logError); } } }