[FEATURE] Add AI-based /ask command (complementing #54) #56
|
@ -37,6 +37,7 @@ import { getStrings } from "../plugins/checklang"
|
||||||
![]() I 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 { 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"
|
||||||
![]() 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 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 {
|
||||||
![]() 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) {
|
async function getResponse(prompt: string, ctx: TextContext, replyGenerating: Message) {
|
||||||
const Strings = getStrings(languageCode(ctx))
|
const Strings = getStrings(languageCode(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
![]() 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.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
|
||||||
![]() 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
|
|||||||
|
|
||||||
let fullResponse = ""
|
let fullResponse = ""
|
||||||
let thoughts = ""
|
let thoughts = ""
|
||||||
let thinking = 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
|
|||||||
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)
|
||||||
![]() 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
|
|||||||
// intercept thoughts
|
|
||||||
![]() 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("thinking started")
|
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
![]() 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
|
|||||||
thinking = 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
|
|||||||
thoughts += line
|
|
||||||
![]() 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
|
|||||||
continue
|
|
||||||
![]() 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 (line.includes("\u003c/think\u003e")) {
|
|
||||||
![]() 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
|
|||||||
// thinking finished
|
|
||||||
![]() 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
|
|||||||
thinking = 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
|
|||||||
console.log("thinking finished")
|
|
||||||
![]() 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
|
|||||||
continue
|
|
||||||
![]() 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 {
|
try {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
let data = JSON.parse(line)
|
|
||||||
![]() 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 (data.response && !thinking) {
|
if (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
|
|||||||
fullResponse += data.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
![]() 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) {
|
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
![]() 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
|
|||||||
await rateLimiter.editMessageWithRetry(
|
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
|
|||||||
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
![]() 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.chat.id,
|
|
||||||
![]() 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
|
|||||||
replyGenerating.message_id,
|
|
||||||
![]() 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,
|
|
||||||
![]() 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
|
|||||||
{ parse_mode: 'Markdown' }
|
|
||||||
![]() 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
|
|||||||
lastUpdate = now
|
|
||||||
![]() 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 (data.response && 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
|
|||||||
if (now - lastUpdate >= 1000) {
|
if (now - lastUpdate >= 1000) {
|
||||||
await rateLimiter.editMessageWithRetry(
|
await rateLimiter.editMessageWithRetry(
|
||||||
![]() 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
![]() LLMs essentially stream their output, which is fetched through API (done above with the I used let because as the response comes in, 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>) => {
|
||||||
![]() 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
|
|||||||
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
|
||||||
![]() 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.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
|
|||||||
|
|
||||||
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>) => {
|
||||||
![]() 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
|
|||||||
...({ reply_to_message_id })
|
...({ reply_to_message_id })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const fixedMsg = message.replace(/\/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
|
|||||||
|
if (fixedMsg.length < 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
|
|||||||
|
await ctx.reply(Strings.askNoMessage, {
|
||||||
![]() 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
|
|||||||
|
parse_mode: 'Markdown',
|
||||||
![]() 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
|
|||||||
|
...({ reply_to_message_id })
|
||||||
![]() 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
|
|||||||
|
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
|
|||||||
|
logger.logPrompt(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
|
|||||||
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}`)
|
||||||
![]() 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
|
|||||||
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}`)
|
||||||
![]() 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,
|
error,
|
||||||
{ parse_mode: 'Markdown' }
|
{ 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
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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 ;)