[FEATURE] Add AI-based /ask command (complementing #54) #56

Merged
lucmsilva651 merged 14 commits from ai-features into main 2025-06-28 19:22:15 +00:00
2 changed files with 43 additions and 48 deletions
Showing only changes of commit 32a17bc757 - Show all commits

View file

@ -37,6 +37,7 @@ import { getStrings } from "../plugins/checklang"
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 { languageCode } from "../utils/language-code" import { languageCode } from "../utils/language-code"
import axios from "axios" import axios from "axios"
import { rateLimiter } from "../utils/rate-limiter" import { rateLimiter } from "../utils/rate-limiter"
import { logger } from "../utils/log"
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 spamwatchMiddleware = spamwatchMiddlewareModule(isOnSpamWatch) const spamwatchMiddleware = spamwatchMiddlewareModule(isOnSpamWatch)
//const model = "qwen3:0.6b" //const model = "qwen3:0.6b"
@ -55,7 +56,7 @@ export function sanitizeForJson(text: string): string {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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) { async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Message) {
const Strings = getStrings(languageCode(ctx)) const Strings = getStrings(languageCode(ctx))
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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.chat) return { if (!ctx.chat) return {
"success": false, "success": false,
"error": Strings.unexpectedErr.replace("{error}", "No chat found"), "error": Strings.unexpectedErr.replace("{error}", "No chat found"),
@ -72,43 +73,24 @@ async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Me
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 fullResponse = "" let fullResponse = ""
let thoughts = "" let thoughts = ""
let thinking = false
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 lastUpdate = Date.now() let lastUpdate = Date.now()
for await (const chunk of aiResponse.data) { for await (const chunk of aiResponse.data) {
const lines = chunk.toString().split('\n') const lines = chunk.toString().split('\n')
for (const line of lines) { for (const line of lines) {
if (!line.trim()) continue if (!line.trim()) continue
if (line.includes("\u003cthink\u003e")) { let ln = JSON.parse(line)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
// intercept thoughts
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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("thinking started") if (ln.response.includes("<think>")) { logger.logThinking(true) } else if (ln.response.includes("</think>")) { logger.logThinking(false) }
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
thinking = true
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 += line
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
continue
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 (line.includes("\u003c/think\u003e")) {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
// thinking finished
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
thinking = false
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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("thinking finished")
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
continue
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
}
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 { try {
const now = Date.now() const now = Date.now()
let data = JSON.parse(line)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 (data.response && !thinking) { if (ln.response) {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 += data.response const patchedThoughts = ln.response.replace("<think>", "`Thinking...`").replace("</think>", "`Finished thinking`")
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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) { thoughts += patchedThoughts
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
await rateLimiter.editMessageWithRetry( fullResponse += patchedThoughts
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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,
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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.chat.id,
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
replyGenerating.message_id,
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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,
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
{ parse_mode: 'Markdown' }
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
lastUpdate = now
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
}
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 (data.response && thinking) {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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) { if (now - lastUpdate >= 1000) {
await rateLimiter.editMessageWithRetry( await rateLimiter.editMessageWithRetry(
GiovaniFZ commented 2025-06-06 17:02:36 +00:00 (Migrated from github.com)

I'm not sure about what it does, but always prefer to use const whenever it's possible

I'm not sure about what it does, but always prefer to use const whenever it's possible
ihatenodejs commented 2025-06-28 16:11:54 +00:00 (Migrated from github.com)

LLMs essentially stream their output, which is fetched through API (done above with the axios.post()).

I used let because as the response comes in, fullResponse contains the latest complete response (it's live updating) which gets edited on Telegram. Hope this clears it up!

LLMs essentially stream their output, which is fetched through API (done above with the `axios.post()`). I used let because as the response comes in, `fullResponse` contains the latest complete response (it's live updating) which gets edited on Telegram. Hope this clears it up!
ctx, ctx,
@ -201,6 +183,9 @@ export default (bot: Telegraf<Context>) => {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 reply_to_message_id = replyToMessageId(textCtx) const reply_to_message_id = replyToMessageId(textCtx)
const Strings = getStrings(languageCode(textCtx)) const Strings = getStrings(languageCode(textCtx))
const message = textCtx.message.text const message = textCtx.message.text
const author = ("@" + ctx.from?.username) || ctx.from?.first_name
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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(author)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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) { if (!process.env.ollamaApi) {
await ctx.reply(Strings.aiDisabled, { await ctx.reply(Strings.aiDisabled, {
@ -215,12 +200,23 @@ export default (bot: Telegraf<Context>) => {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
...({ reply_to_message_id }) ...({ reply_to_message_id })
}) })
const fixedMsg = message.replace(/\/ask /, "")
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 (fixedMsg.length < 1) {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
await ctx.reply(Strings.askNoMessage, {
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
parse_mode: 'Markdown',
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
...({ reply_to_message_id })
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
})
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
}
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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 prompt = sanitizeForJson( const prompt = sanitizeForJson(
`You are a helpful assistant named Kowalski, who has been given a message from a user. `You are a helpful assistant named Kowalski, who has been given a message from a user.
The message is: The message is:
${message}`) ${fixedMsg}`)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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) const aiResponse = await getResponse(prompt, textCtx, replyGenerating)
if (!aiResponse) return if (!aiResponse) return
@ -243,6 +239,7 @@ ${message}`)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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, error,
{ parse_mode: 'Markdown' } { parse_mode: 'Markdown' }
) )
console.error("[!] Error sending response:", aiResponse.error)
GiovaniFZ commented 2025-06-28 13:52:15 +00:00 (Migrated from github.com)

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
GiovaniFZ commented 2025-06-28 13:53:07 +00:00 (Migrated from github.com)

Why are you printing p1?

Why are you printing p1?
GiovaniFZ commented 2025-06-28 13:56:48 +00:00 (Migrated from github.com)

There are too many ifs and 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 ;)
ihatenodejs commented 2025-06-28 16:13:06 +00:00 (Migrated from github.com)

I 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
} }
}) })
} }

View file

@ -41,27 +41,25 @@ class Logger {
return Logger.instance return Logger.instance
} }
logCmdStart(user: string): void {
console.log(`[START] Received /ask from ${user}`)
}
logThinking(thinking: boolean): void {
if (thinking) {
console.log("[THINKING] Started")
} else {
console.log("[THINKING] Ended")
}
}
logChunk(chatId: number, messageId: number, text: string, isOverflow: boolean = false): void { logChunk(chatId: number, messageId: number, text: string, isOverflow: boolean = false): void {
const prefix = isOverflow ? '[OVERFLOW]' : '[CHUNK]' const prefix = isOverflow ? "[OVERFLOW]" : "[CHUNK]"
console.log(`${prefix} [${chatId}:${messageId}] ${text.length} chars: ${text.substring(0, 50)}${text.length > 50 ? '...' : ''}`) console.log(`${prefix} [${chatId}:${messageId}] ${text.length} chars`)
} }
logPrompt(prompt: string): void { logPrompt(prompt: string): void {
console.log(`[PROMPT] ${prompt.length} chars: ${prompt.substring(0, 50)}${prompt.length > 50 ? '...' : ''}`) console.log(`[PROMPT] ${prompt.length} chars: ${prompt.substring(0, 50)}${prompt.length > 50 ? "..." : ""}`)
}
logThinkingStart(): void {
if (!this.thinking) {
console.log('[THINKING] started')
this.thinking = true
}
}
logThinkingEnd(): void {
if (this.thinking) {
console.log('[THINKING] ended')
this.thinking = false
}
} }
logError(error: any): void { logError(error: any): void {
@ -69,14 +67,14 @@ class Logger {
const retryAfter = error.response.parameters?.retry_after || 1 const retryAfter = error.response.parameters?.retry_after || 1
console.error(`[RATE_LIMIT] Too Many Requests - retry after ${retryAfter}s`) console.error(`[RATE_LIMIT] Too Many Requests - retry after ${retryAfter}s`)
} else if (error.response?.error_code === 400 && error.response?.description?.includes("can't parse entities")) { } 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("[PARSE_ERROR] Markdown parsing failed, retrying with plain text")
} else { } else {
const errorDetails = { const errorDetails = {
code: error.response?.error_code, code: error.response?.error_code,
description: error.response?.description, description: error.response?.description,
method: error.on?.method method: error.on?.method
} }
console.error('[ERROR]', JSON.stringify(errorDetails, null, 2)) console.error("[ERROR]", JSON.stringify(errorDetails, null, 2))
} }
} }
} }