Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/commands/ai/askai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -172,6 +180,7 @@ async function executeAiRequest(
const modelId = isVisionRequest
? VISION_MODEL_ID
: (modelConfig.id as string);

const provider = isVisionRequest
? groq
: modelConfig.provider === "groq"
Expand All @@ -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:`,
Expand Down
5 changes: 4 additions & 1 deletion src/prompts/base.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { INFO } from "./info.ts";
import { PERSONA } from "./persona.ts";
import { TOOLS } from "./tools.ts";

Expand All @@ -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 <search> or <react>.",
'Tools: Use silently when valuable; do not announce tool use. Provide a short conversational reply alongside results. NEVER include tags like <search> or <react> 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");
8 changes: 8 additions & 0 deletions src/prompts/info.ts
Original file line number Diff line number Diff line change
@@ -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.",
];
7 changes: 1 addition & 6 deletions src/prompts/persona.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
2 changes: 1 addition & 1 deletion src/prompts/tools.ts
Original file line number Diff line number Diff line change
@@ -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.",
];
2 changes: 1 addition & 1 deletion src/utils/pretty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/visuals/statsCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/visuals/usageCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading