[FEATURE] Add AI-based /ask command (complementing #54) #56
|
@ -6,7 +6,9 @@ botSource = "https://github.com/ABOCN/TelegramBot"
|
|||
botToken = ""
|
||||
|
||||
# ai features
|
||||
ollamaEnabled = false
|
||||
# ollamaApi = "http://ollama:11434"
|
||||
# handlerTimeout = "600_000" # set higher if you expect to download larger models
|
||||
|
||||
# misc (botAdmins isnt a array here!)
|
||||
maxRetries = 9999
|
||||
|
|
13
README.md
|
@ -10,12 +10,6 @@ Kowalski is a a simple Telegram bot made in Node.js.
|
|||
|
||||
- You can find Kowalski at [@KowalskiNodeBot](https://t.me/KowalskiNodeBot) on Telegram.
|
||||
|
||||
## Translations
|
||||
|
||||
<a href="https://weblate.librecloud.cc/engage/kowalski/">
|
||||
<img src="https://weblate.librecloud.cc/widget/kowalski/multi-auto.svg" alt="Translation status" />
|
||||
</a>
|
||||
|
||||
## Self-host requirements
|
||||
|
||||
> [!IMPORTANT]
|
||||
|
@ -26,7 +20,10 @@ Kowalski is a a simple Telegram bot made in Node.js.
|
|||
- FFmpeg (only for the `/yt` command)
|
||||
- Docker and Docker Compose (only required for Docker setup)
|
||||
|
||||
_AI features require a higher-end system with a CPU/GPU_
|
||||
### AI Requirements
|
||||
|
||||
- High-end CPU *or* GPU (~ 6GB vRAM)
|
||||
- If using CPU, enough RAM to load the models (~6GB w/ defaults)
|
||||
|
||||
## Running locally (non-Docker setup)
|
||||
|
||||
|
@ -109,7 +106,9 @@ If you prefer to use Docker directly, you can use these instructions instead.
|
|||
- **botPrivacy**: Put the link to your bot privacy policy.
|
||||
- **maxRetries**: Maximum number of retries for a failing command on Kowalski. Default is 5. If the limit is hit, the bot will crash past this number.
|
||||
- **botToken**: Put your bot token that you created at [@BotFather](https://t.me/botfather).
|
||||
- **ollamaEnabled** (optional): Enables/disables AI features
|
||||
- **ollamaApi** (optional): Ollama API endpoint for various AI features, will be disabled if not set
|
||||
- **handlerTimeout** (default: `600_000`): How long handlers will wait before timing out. Set this high if using large AI models.
|
||||
- **botAdmins**: Put the ID of the people responsible for managing the bot. They can use some administrative + exclusive commands on any group.
|
||||
- **lastKey**: Last.fm API key, for use on `lastfm.js` functions, like see who is listening to what song and etc.
|
||||
- **weatherKey**: Weather.com API key, used for the `/weather` command.
|
||||
|
|
13
src/bot.ts
|
@ -4,6 +4,7 @@ import fs from 'fs';
|
|||
import { isOnSpamWatch } from './spamwatch/spamwatch';
|
||||
import '@dotenvx/dotenvx';
|
||||
import './plugins/ytDlpWrapper';
|
||||
import { preChecks } from './commands/ai';
|
||||
|
||||
// Ensures bot token is set, and not default value
|
||||
if (!process.env.botToken || process.env.botToken === 'InsertYourBotTokenHere') {
|
||||
|
@ -11,7 +12,17 @@ if (!process.env.botToken || process.env.botToken === 'InsertYourBotTokenHere')
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
const bot = new Telegraf(process.env.botToken);
|
||||
// Detect AI and run pre-checks
|
||||
if (process.env.ollamaEnabled === "true") {
|
||||
if (!(await preChecks())) {
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const bot = new Telegraf(
|
||||
process.env.botToken,
|
||||
{ handlerTimeout: Number(process.env.handlerTimeout) || 600_000 }
|
||||
);
|
||||
const maxRetries = process.env.maxRetries || 5;
|
||||
let restartCount = 0;
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ import { rateLimiter } from "../utils/rate-limiter"
|
|||
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
import { logger } from "../utils/log"
|
||||
|
||||
const spamwatchMiddleware = spamwatchMiddlewareModule(isOnSpamWatch)
|
||||
//const model = "qwen3:0.6b"
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const model = "deepseek-r1:1.5b"
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
export const flash_model = "gemma3:4b"
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
export const thinking_model = "deepseek-r1:1.5b"
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
type TextContext = Context & { message: Message.TextMessage }
|
||||
|
||||
|
@ -54,7 +54,22 @@ export function sanitizeForJson(text: string): string {
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
.replace(/\t/g, '\\t')
|
||||
}
|
||||
|
||||
async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Message) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
export async function preChecks() {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const envs = [
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
"ollamaApi",
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
]
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
for (const env of envs) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (!process.env[env]) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error(`[✨ AI | !] ❌ ${env} not set!`)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return false
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log("[✨ AI] Pre-checks passed\n")
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return true
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Message, model: string) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const Strings = getStrings(languageCode(ctx))
|
||||
|
||||
if (!ctx.chat) return {
|
||||
|
@ -81,16 +96,43 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (!line.trim()) continue
|
||||
let ln = JSON.parse(line)
|
||||
|
||||
if (ln.response.includes("<think>")) { logger.logThinking(true) } else if (ln.response.includes("</think>")) { logger.logThinking(false) }
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (model === thinking_model && ln.response.includes('<think>')) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const thinkMatch = ln.response.match(/<think>([\s\S]*?)<\/think>/)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (thinkMatch) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const innerContent = thinkMatch[1]
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (innerContent.trim().length > 0) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
logger.logThinking(ctx.chat.id, replyGenerating.message_id, true)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
} else {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
logger.logThinking(ctx.chat.id, replyGenerating.message_id, true)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
} else if (model === thinking_model && ln.response.includes('</think>')) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
logger.logThinking(ctx.chat.id, replyGenerating.message_id, false)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
try {
|
||||
const now = Date.now()
|
||||
|
||||
if (ln.response) {
|
||||
const patchedThoughts = ln.response.replace("<think>", "`Thinking...`").replace("</think>", "`Finished thinking`")
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
thoughts += patchedThoughts
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
fullResponse += patchedThoughts
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (model === thinking_model) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
let patchedThoughts = ln.response
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
// TODO: hide blank thinking chunks
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const thinkTagRx = /<think>([\s\S]*?)<\/think>/g
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
patchedThoughts = patchedThoughts.replace(thinkTagRx, (match, p1) => {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (p1.trim().length > 0) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log(p1)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return '`Thinking...`' + p1 + '`Finished thinking`'
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
} else {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return ''
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
})
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
patchedThoughts = patchedThoughts.replace(/<think>/g, '`Thinking...`')
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
patchedThoughts = patchedThoughts.replace(/<\/think>/g, '`Finished thinking`')
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
thoughts += patchedThoughts
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
fullResponse += patchedThoughts
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
} else {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
fullResponse += ln.response
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (now - lastUpdate >= 1000) {
|
||||
await rateLimiter.editMessageWithRetry(
|
||||
ctx,
|
||||
|
@ -103,7 +145,7 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error parsing chunk:", e)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error("[✨ AI | !] Error parsing chunk:", e)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +161,7 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (error.response.data.error.includes(`model '${model}' not found`) || error.status === 404) {
|
||||
shouldPullModel = true
|
||||
} else {
|
||||
console.error("[!] 1", error.response.data.error)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error("[✨ AI | !] Error zone 1:", error.response.data.error)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return {
|
||||
"success": false,
|
||||
"error": error.response.data.error,
|
||||
|
@ -130,23 +172,25 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
|
||||
if (shouldPullModel) {
|
||||
ctx.telegram.editMessageText(ctx.chat.id, replyGenerating.message_id, undefined, `🔄 Pulling ${model} from ollama...`)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log(`[i] Pulling ${model} from ollama...`)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
ctx.telegram.editMessageText(ctx.chat.id, replyGenerating.message_id, undefined, `🔄 Pulling ${model} from ollama...\n\nThis may take a few minutes...`)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log(`[✨ AI | i] Pulling ${model} from ollama...`)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
let pullModelStream: any
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
const pullModelStream = await axios.post(`${process.env.ollamaApi}/api/pull`, {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
model: model,
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
stream: false,
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
})
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (pullModelStream.data.status !== ("success")) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error("[!] Something went wrong:", pullModelStream.data)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
try {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
pullModelStream = await axios.post(`${process.env.ollamaApi}/api/pull`, {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
model: model,
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
stream: false,
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
timeout: process.env.ollamaApiTimeout || 10000,
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
})
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
} catch (e: any) {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error("[✨ AI | !] Something went wrong:", e.response.data.error)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return {
|
||||
"success": false,
|
||||
"error": `❌ Something went wrong while pulling ${model}, please try your command again!`,
|
||||
}
|
||||
}
|
||||
|
||||
console.log("[i] Model pulled successfully")
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log(`[✨ AI | i] ${model} pulled successfully`)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return {
|
||||
"success": true,
|
||||
"response": `✅ Pulled ${model} successfully, please retry the command.`,
|
||||
|
@ -154,7 +198,7 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
|
||||
if (error.response) {
|
||||
console.error("[!] 2", error.response)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error("[✨ AI | !] Error zone 2:", error.response)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return {
|
||||
"success": false,
|
||||
"error": error.response,
|
||||
|
@ -162,7 +206,7 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
|
||||
if (error.statusText) {
|
||||
console.error("[!] 3", error.statusText)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.error("[✨ AI | !] Error zone 3:", error.statusText)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
return {
|
||||
"success": false,
|
||||
"error": error.statusText,
|
||||
|
@ -177,15 +221,24 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
|
||||
export default (bot: Telegraf<Context>) => {
|
||||
bot.command("ask", spamwatchMiddleware, async (ctx) => {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const botName = bot.botInfo?.first_name && bot.botInfo?.last_name ? `${bot.botInfo.first_name} ${bot.botInfo.last_name}` : "Kowalski"
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
bot.command(["ask", "think"], spamwatchMiddleware, async (ctx) => {
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (!ctx.message || !('text' in ctx.message)) return;
|
||||
const isAsk = ctx.message.text.startsWith("/ask")
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const model = isAsk ? flash_model : thinking_model
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log(model)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
console.log(ctx.message.text)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const textCtx = ctx as TextContext;
|
||||
const reply_to_message_id = replyToMessageId(textCtx)
|
||||
const Strings = getStrings(languageCode(textCtx))
|
||||
const message = textCtx.message.text
|
||||
const author = ("@" + ctx.from?.username) || ctx.from?.first_name
|
||||
|
||||
logger.logCmdStart(author)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
logger.logCmdStart(
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
author,
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
model === flash_model ? "ask" : "think"
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
if (!process.env.ollamaApi) {
|
||||
await ctx.reply(Strings.aiDisabled, {
|
||||
|
@ -212,12 +265,14 @@ export default (bot: Telegraf<Context>) => {
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
logger.logPrompt(fixedMsg)
|
||||
|
||||
const prompt = sanitizeForJson(
|
||||
`You are a helpful assistant named Kowalski, who has been given a message from a user.
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
`You are a helpful assistant called ${botName}.
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
Current Date/Time (UTC): ${new Date().toLocaleString()}
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
The message is:
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
---
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
|
||||
Respond to the user's message:
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
${fixedMsg}`)
|
||||
const aiResponse = await getResponse(prompt, textCtx, replyGenerating)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
const aiResponse = await getResponse(prompt, textCtx, replyGenerating, model)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
if (!aiResponse) return
|
||||
|
||||
if (aiResponse.success && aiResponse.response) {
|
||||
|
@ -239,7 +294,6 @@ ${fixedMsg}`)
|
|||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
error,
|
||||
{ parse_mode: 'Markdown' }
|
||||
)
|
||||
console.error("[!] Error sending response:", aiResponse.error)
|
||||
![]() Don't use axios like this, check https://axios-http.com/docs/instance Don't use axios like this, check https://axios-http.com/docs/instance
![]() Why are you printing p1? Why are you printing p1?
![]() There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;) There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)
![]() I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read I like this idea! I will look into cleaning it up, and maybe break some things into functions so the code is easier to read
|
||||
}
|
||||
})
|
||||
}
|
|
@ -28,6 +28,8 @@
|
|||
//
|
||||
// For more information, please refer to <https://unlicense.org/>
|
||||
|
||||
import { flash_model, thinking_model } from "../commands/ai"
|
||||
|
||||
class Logger {
|
||||
private static instance: Logger
|
||||
private thinking: boolean = false
|
||||
|
@ -41,40 +43,40 @@ class Logger {
|
|||
return Logger.instance
|
||||
}
|
||||
|
||||
logCmdStart(user: string): void {
|
||||
console.log(`[START] Received /ask from ${user}`)
|
||||
logCmdStart(user: string, type: "ask" | "think"): void {
|
||||
console.log(`\n[✨ AI | START] Received /${type} for model ${type === "ask" ? flash_model : thinking_model} from ${user}`)
|
||||
}
|
||||
|
||||
logThinking(thinking: boolean): void {
|
||||
logThinking(chatId: number, messageId: number, thinking: boolean): void {
|
||||
if (thinking) {
|
||||
console.log("[THINKING] Started")
|
||||
console.log(`[✨ AI | THINKING | ${chatId}:${messageId}] Model started thinking`)
|
||||
} else {
|
||||
console.log("[THINKING] Ended")
|
||||
console.log(`[✨ AI | THINKING | ${chatId}:${messageId}] Model stopped thinking`)
|
||||
}
|
||||
}
|
||||
|
||||
logChunk(chatId: number, messageId: number, text: string, isOverflow: boolean = false): void {
|
||||
const prefix = isOverflow ? "[OVERFLOW]" : "[CHUNK]"
|
||||
console.log(`${prefix} [${chatId}:${messageId}] ${text.length} chars`)
|
||||
const prefix = isOverflow ? "[✨ AI | OVERFLOW]" : "[✨ AI | CHUNK]"
|
||||
console.log(`${prefix} [${chatId}:${messageId}] ${text.length} chars pushed to Telegram`)
|
||||
}
|
||||
|
||||
logPrompt(prompt: string): void {
|
||||
console.log(`[PROMPT] ${prompt.length} chars: ${prompt.substring(0, 50)}${prompt.length > 50 ? "..." : ""}`)
|
||||
console.log(`[✨ AI | PROMPT] ${prompt.length} chars: ${prompt.substring(0, 50)}${prompt.length > 50 ? "..." : ""}`)
|
||||
}
|
||||
|
||||
logError(error: any): void {
|
||||
if (error.response?.error_code === 429) {
|
||||
const retryAfter = error.response.parameters?.retry_after || 1
|
||||
console.error(`[RATE_LIMIT] Too Many Requests - retry after ${retryAfter}s`)
|
||||
console.error(`[✨ AI | RATE_LIMIT] Too Many Requests - retry after ${retryAfter}s`)
|
||||
} else if (error.response?.error_code === 400 && error.response?.description?.includes("can't parse entities")) {
|
||||
console.error("[PARSE_ERROR] Markdown parsing failed, retrying with plain text")
|
||||
console.error("[✨ AI | PARSE_ERROR] Markdown parsing failed, retrying with plain text")
|
||||
} else {
|
||||
const errorDetails = {
|
||||
code: error.response?.error_code,
|
||||
description: error.response?.description,
|
||||
method: error.on?.method
|
||||
}
|
||||
console.error("[ERROR]", JSON.stringify(errorDetails, null, 2))
|
||||
console.error("[✨ AI | ERROR]", JSON.stringify(errorDetails, null, 2))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,9 +138,9 @@ class RateLimiter {
|
|||
![]() pls, avoid to set any as a type pls, avoid to set any as a type
![]() pls, avoid to set any as a type pls, avoid to set any as a type
|
||||
const overflowMessageId = this.overflowMessages.get(messageKey)
|
||||
|
||||
if (overflowMessageId) {
|
||||
logger.logChunk(chatId, overflowMessageId, chunk, true)
|
||||
![]() pls, avoid to set any as a type pls, avoid to set any as a type
|
||||
try {
|
||||
await ctx.telegram.editMessageText(chatId, overflowMessageId, undefined, chunk, options)
|
||||
logger.logChunk(chatId, overflowMessageId, chunk, true)
|
||||
![]() pls, avoid to set any as a type pls, avoid to set any as a type
|
||||
} catch (error: any) {
|
||||
if (!error.response?.description?.includes("message is not modified")) {
|
||||
throw error
|
||||
|
|
|||
![]() pls, avoid to set any as a type pls, avoid to set any as a type
![]() pls, avoid to set any as a type pls, avoid to set any as a type
|
Don't use axios like this, check https://axios-http.com/docs/instance
Why are you printing p1?
There are too many ifs and elses, not only in this file but others too. Maybe we could separate them soon. let's try to do this in the future ;)