feat(ollama): add tool calling support

Add Ollama tool integration for web search, weather, datetime, filesystem operations, and shell evaluation. Implement multi-round tool call handling, streaming updates, thinking cleanup, and safer path validation for file tools.

Also add related environment configuration, command execution helper, MarkdownV2 cancel handling fixes, and remove unused TryAgain callback command.
This commit is contained in:
2026-05-03 15:16:14 +03:00
parent 86b26813e2
commit 2fc60806ff
7 changed files with 2046 additions and 129 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ export class Cancel extends CallbackCommand {
}
static withData(data?: string): Cancel {
return new Cancel("", data);
return new Cancel(undefined, data);
}
async execute(): Promise<void> {
+3 -3
View File
@@ -1,7 +1,7 @@
import {CallbackCommand} from "../base/callback-command";
import {CallbackQuery} from "typescript-telegram-bot-api";
import {abortOllamaRequest, bot, getOllamaRequest} from "../index";
import {logError} from "../util/utils";
import {escapeMarkdownV2Text, logError} from "../util/utils";
import {MessageStore} from "../common/message-store";
import {StoredMessage} from "../model/stored-message";
import {Requirements} from "../base/requirements";
@@ -59,8 +59,8 @@ export class OllamaCancel extends CallbackCommand {
await bot.editMessageText({
chat_id: chatId,
message_id: messageId,
text: newText,
parse_mode: "Markdown",
text: escapeMarkdownV2Text(newText),
parse_mode: "MarkdownV2",
reply_markup: {inline_keyboard: []},
});
-21
View File
@@ -1,21 +0,0 @@
import {CallbackCommand} from "../base/callback-command";
export class TryAgain extends CallbackCommand {
data = "";
text = "🔁 Повторить";
constructor(text?: string, data?: string) {
super();
this.text = text ?? this.text;
this.data = data ?? this.data;
}
static withData(data?: string): TryAgain {
return new TryAgain("", data);
}
async execute(): Promise<void> {
return Promise.resolve();
}
}