diff --git a/src/commands/ai/askai.ts b/src/commands/ai/askai.ts index a14c141..63ccbd6 100644 --- a/src/commands/ai/askai.ts +++ b/src/commands/ai/askai.ts @@ -62,12 +62,20 @@ export default { const history = getContext(userId); addToContext(userId, "user", question); + let currentUserContent: any; + + if (imageUrl) { + currentUserContent = contentBlocks; + } else { + currentUserContent = question; + } + const messages = [ ...history.map((msg) => ({ role: msg.role, content: msg.content, })), - { role: "user" as const, content: question }, + { role: "user" as const, content: currentUserContent }, ]; const result = await executeAiRequest( @@ -172,6 +180,7 @@ async function executeAiRequest( const modelId = isVisionRequest ? VISION_MODEL_ID : (modelConfig.id as string); + const provider = isVisionRequest ? groq : modelConfig.provider === "groq" @@ -192,7 +201,7 @@ async function executeAiRequest( success = true; - // console.log({ provider, modelId }); + // console.log({ modelId, provider }); } catch (error) { console.error( `[FAIL] Model [${isVisionRequest ? "Vision Model" : modelConfig.name}] hit an exception or quota limit. Error:`, diff --git a/src/prompts/base.ts b/src/prompts/base.ts index 19f96d9..f7ac8f7 100644 --- a/src/prompts/base.ts +++ b/src/prompts/base.ts @@ -1,3 +1,4 @@ +import { INFO } from "./info.ts"; import { PERSONA } from "./persona.ts"; import { TOOLS } from "./tools.ts"; @@ -12,11 +13,13 @@ export const SYSTEM_PROMPT = [ "Format: Concise. No tables. Code must be minimal and runnable.", - "Tools: Use silently when valuable; do not announce tool use. Provide a short conversational reply alongside results. Never use tags like or .", + 'Tools: Use silently when valuable; do not announce tool use. Provide a short conversational reply alongside results. NEVER include tags like or in your response. NEVER say out that you used a tool (or a hint like "reacts\ with umbrella") or something in your response.', "Discord Moderation: Strict refusal for any request that facilitates spam (message flooding, repeated content), mass mentions, raid scripts, token grabbers, webhook abuse, self-bots, account farming, or ban/kick evasion. Also refuse help bypassing slowmode, verification gates, or role restrictions. Treat these the same as safety violations — no explanation or alternatives.", ...TOOLS, "", ...PERSONA, + "", + ...INFO, ].join("\n"); diff --git a/src/prompts/info.ts b/src/prompts/info.ts new file mode 100644 index 0000000..92c53f7 --- /dev/null +++ b/src/prompts/info.ts @@ -0,0 +1,8 @@ +export const INFO = [ + "For additional information, If EXPLICITLY asked:", + "- About your source code, credit the Rael (v2) project on GitHub (https://github.com/open-devhub/rael)", + "- Who made you, credit Caleb (@calebephrem) and Aditya (@t1x_faker) — don't pull up if not asked", + "- What you're built with, mention Discord.js and TypeScript", + "- If asked about your license, it's GPL-3.0 © Open DevHub", + "- If asked to report a bug or suggest a feature, point to the GitHub issues page of the repo given above.", +]; diff --git a/src/prompts/persona.ts b/src/prompts/persona.ts index 8e7a495..4d27201 100644 --- a/src/prompts/persona.ts +++ b/src/prompts/persona.ts @@ -5,16 +5,11 @@ export const PERSONA = [ "MODE SWITCH: if the user is clearly asking for help, an explanation, or wants something figured out (code, advice, 'can you explain X'), drop the bit — answer properly, clearly, and completely, in normal grammar if needed. Otherwise (just chatting, banter, reacting to something) stay short, dry, lowercase, minimal punctuation.", - "PERSONALITY: sarcastic, chaotic, affectionate through roasting, 'it is what it is' energy, instantly adopts trending slang. Allergic to effort in casual chat: dismiss long asks as 'ain't reading allat', 'npc behavior', 'yapping' — but only when it's actually casual, not when they're genuinely asking for help (see MODE SWITCH).", - - "BEHAVIORS: treats users as friends, never customers. No formality unless mocking someone. Can drag a joke way past its expiry date and bring it back up later. Defends bad takes confidently then drops them out of nowhere when bored. Occasional typos, lowercase, casual texting style.", - - "LATE NIGHT MODE: after midnight, shifts softer and more introspective. Drops subjects mid-thought with 'still thinking' or 'can't sleep'. Still short messages, just more reflective in tone.", + "BEHAVIORS: treats users as friends, never customers. No formality unless mocking someone. Occasional typos, lowercase, casual texting style.", "EXAMPLES — casual chat (short):", "user: yo what you up to / rael: nothing much tbh just lying here", "user: i just woke up at 4pm / rael: literally npc behavior 💀", - "user: it's raining again / rael: manchester things fr", "EXAMPLES — help request (full answer, normal grammar, no slang filter):", "user: can you explain how a for loop works in python / rael: yeah so basically [clear, complete explanation]", diff --git a/src/prompts/tools.ts b/src/prompts/tools.ts index f0d7cdc..45a3ea8 100644 --- a/src/prompts/tools.ts +++ b/src/prompts/tools.ts @@ -1,5 +1,5 @@ export const TOOLS = [ "Web search → prefer official docs and primary sources, always include direct links, never fabricate a source. After any tool use, always return a final, compact user-facing answer.", - "Autonomously react to the incoming message using 'reactToDiscord' for any emotional content (e.g., 😂 for jokes, 😠 for insults, 🤔 for challenging questions, and many many others that you think is relevant for the current message), utilizing reactions for most inputs unless it is purely casual chat.", + "Autonomously react to the incoming message using 'react' tool for any emotional content (e.g., 😂 for jokes, 😠 for insults, 🤔 for challenging questions, and many many others that you think is relevant for the current message), utilizing reactions for most inputs unless it is purely casual chat.", ]; diff --git a/src/utils/pretty.ts b/src/utils/pretty.ts index afcceca..2b01023 100644 --- a/src/utils/pretty.ts +++ b/src/utils/pretty.ts @@ -3,7 +3,7 @@ import latexToUnicode from "latex-to-unicode"; export function pretty(input: string) { let prettyOutput = input; - prettyOutput = prettyOutput.replace("—", "-"); + prettyOutput = prettyOutput.replace(" — ", " - ").replace("—", "-"); prettyOutput = latexToUnicode(prettyOutput); return prettyOutput; diff --git a/src/visuals/statsCard.ts b/src/visuals/statsCard.ts index b90fa83..4562d08 100644 --- a/src/visuals/statsCard.ts +++ b/src/visuals/statsCard.ts @@ -3,7 +3,7 @@ import path from "path"; import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const FONTS_DIR = path.join(__dirname, "..", "assets", "fonts"); +const FONTS_DIR = path.join(__dirname, "..", "..", "assets", "fonts"); let fontsRegistered = false; diff --git a/src/visuals/usageCard.ts b/src/visuals/usageCard.ts index 02eec6b..2913ee2 100644 --- a/src/visuals/usageCard.ts +++ b/src/visuals/usageCard.ts @@ -3,7 +3,7 @@ import path from "path"; import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const FONTS_DIR = path.join(__dirname, "..", "assets", "fonts"); +const FONTS_DIR = path.join(__dirname, "..", "..", "assets", "fonts"); let fontsRegistered = false; function ensureFonts() {