shitton of the ai changes
This commit is contained in:
@@ -1,34 +1,13 @@
|
||||
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";
|
||||
import {AiProvider} from "../model/ai-provider";
|
||||
import {ProviderSetModelCommand} from "./provider-model-command";
|
||||
|
||||
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<void> {
|
||||
const newModel = match?.[3];
|
||||
|
||||
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) {
|
||||
logError(e);
|
||||
await replyToMessage({message: msg, text: e.toString()}).catch(logError);
|
||||
}
|
||||
export class OllamaSetModel extends ProviderSetModelCommand {
|
||||
constructor() {
|
||||
super({
|
||||
provider: AiProvider.OLLAMA,
|
||||
title: Environment.commandTitles.ollamaSetModel,
|
||||
description: Environment.commandDescriptions.ollamaSetModel,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user