update error logging
cutting all kind of prefixes for prompt making
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@ export class Ae extends ChatCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(`${text}
|
||||
logError(`${text}
|
||||
* Stacktrace: ${e.stack}`);
|
||||
|
||||
await oldSendMessage(msg, text).catch(logError);
|
||||
|
||||
+10
-11
@@ -1,19 +1,18 @@
|
||||
import {ChatCommand} from "../base/chat-command";
|
||||
import {Message} from "typescript-telegram-bot-api";
|
||||
import {
|
||||
collectReplyChainText,
|
||||
escapeMarkdownV2Text,
|
||||
extractText,
|
||||
logError,
|
||||
oldReplyToMessage,
|
||||
startIntervalEditor
|
||||
} from "../util/utils";
|
||||
import {Environment} from "../common/environment";
|
||||
import {bot, googleAi} from "../index";
|
||||
import {MessageStore} from "../common/message-store";
|
||||
import {Requirements} from "../base/requirements";
|
||||
import {Requirement} from "../base/requirement";
|
||||
import {ApiError} from "@google/genai";
|
||||
import {
|
||||
collectReplyChainText,
|
||||
escapeMarkdownV2Text,
|
||||
logError,
|
||||
oldReplyToMessage,
|
||||
startIntervalEditor
|
||||
} from "../util/utils";
|
||||
|
||||
export class GeminiChat extends ChatCommand {
|
||||
command = "gemini";
|
||||
@@ -34,13 +33,13 @@ export class GeminiChat extends ChatCommand {
|
||||
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
const messageParts = await collectReplyChainText(msg, "/gemini");
|
||||
const messageParts = await collectReplyChainText(msg);
|
||||
console.log("MESSAGE PARTS", messageParts);
|
||||
|
||||
const chatMessages = messageParts.map(part => {
|
||||
return {
|
||||
role: part.bot ? "assistant" : "user",
|
||||
content: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + extractText(part.content, "/gemini")
|
||||
content: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + part.content
|
||||
};
|
||||
});
|
||||
chatMessages.reverse();
|
||||
@@ -134,7 +133,7 @@ export class GeminiChat extends ChatCommand {
|
||||
await oldReplyToMessage(waitMessage, `⏱️ ${diff}s`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
logError(error);
|
||||
|
||||
if (error instanceof ApiError) {
|
||||
if (error.status === 429) {
|
||||
|
||||
@@ -29,7 +29,7 @@ export class GeminiListModels extends ChatCommand {
|
||||
parse_mode: "HTML"
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
await replyToMessage({message: msg, text: "Не получилось загрузить список моделей"}).catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import {Message} from "typescript-telegram-bot-api";
|
||||
import {
|
||||
collectReplyChainText,
|
||||
escapeMarkdownV2Text,
|
||||
extractText,
|
||||
logError,
|
||||
oldReplyToMessage,
|
||||
startIntervalEditor
|
||||
@@ -34,14 +33,14 @@ export class MistralChat extends ChatCommand {
|
||||
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
const messageParts = await collectReplyChainText(msg, "/mistral");
|
||||
const messageParts = await collectReplyChainText(msg);
|
||||
console.log("MESSAGE PARTS", messageParts);
|
||||
|
||||
const chatMessages = messageParts.map(part => {
|
||||
const content = [];
|
||||
content.push({
|
||||
type: "text",
|
||||
text: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + extractText(part.content, Environment.BOT_PREFIX),
|
||||
text: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + part.content,
|
||||
});
|
||||
|
||||
if (part.images && part.images.length > 0) {
|
||||
@@ -143,7 +142,7 @@ export class MistralChat extends ChatCommand {
|
||||
await oldReplyToMessage(waitMessage, `⏱️ ${diff}s`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
logError(error);
|
||||
await oldReplyToMessage(waitMessage, `Произошла ошибка!\n${error.toString()}`).catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class MistralListModels extends ChatCommand {
|
||||
parse_mode: "HTML"
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
await oldReplyToMessage(msg, "Не получилось загрузить список моделей").catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import {abortOllamaRequest, bot, getOllamaRequest, ollama, ollamaRequests} from
|
||||
import {
|
||||
collectReplyChainText,
|
||||
escapeMarkdownV2Text,
|
||||
extractText,
|
||||
logError,
|
||||
oldReplyToMessage,
|
||||
startIntervalEditor
|
||||
@@ -37,7 +36,7 @@ export class OllamaChat extends ChatCommand {
|
||||
const chatMessages = messageParts.map(part => {
|
||||
return {
|
||||
role: part.bot ? "assistant" : "user",
|
||||
content: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + extractText(part.content, Environment.BOT_PREFIX),
|
||||
content: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + part.content,
|
||||
images: part.images
|
||||
};
|
||||
});
|
||||
@@ -198,7 +197,7 @@ export class OllamaChat extends ChatCommand {
|
||||
reply_markup: {inline_keyboard: []}
|
||||
}).catch(logError);
|
||||
|
||||
console.error(error);
|
||||
logError(error);
|
||||
await oldReplyToMessage(waitMessage, `Произошла ошибка!\n${error.toString()}`).catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class OllamaListModels extends ChatCommand {
|
||||
parse_mode: "HTML"
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
await oldReplyToMessage(msg, "Не получилось загрузить список моделей").catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ export class OllamaPrompt extends ChatCommand {
|
||||
reply_markup: {inline_keyboard: []}
|
||||
}).catch(logError);
|
||||
|
||||
console.error(error);
|
||||
logError(error);
|
||||
await oldReplyToMessage(waitMessage, `Произошла ошибка!\n${error.toString()}`).catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {Requirement} from "../base/requirement";
|
||||
import {Message} from "typescript-telegram-bot-api";
|
||||
import {bot, ollama} from "../index";
|
||||
import {WebSearchResponse} from "../model/web-search-response";
|
||||
import {editMessageText} from "../util/utils";
|
||||
import {editMessageText, logError} from "../util/utils";
|
||||
import {Environment} from "../common/environment";
|
||||
|
||||
export class OllamaSearch extends ChatCommand {
|
||||
@@ -42,7 +42,7 @@ export class OllamaSearch extends ChatCommand {
|
||||
|
||||
await editMessageText(chatId, wait.message_id, message);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
logError(error);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ try {
|
||||
GlobalFonts.registerFromPath("./assets/JetBrainsMono-Italic.ttf", "JetBrainsMonoItalic");
|
||||
GlobalFonts.registerFromPath("./assets/JetBrainsMono-Regular.ttf", "JetBrainsMonoRegular");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
}
|
||||
|
||||
export class Quote extends ChatCommand {
|
||||
@@ -75,7 +75,7 @@ export class Quote extends ChatCommand {
|
||||
},
|
||||
}).catch(logError);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
await oldSendMessage(msg, "Не смог собрать цитату 😢").catch(logError);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user