zhlajiex
commited on
Commit
·
df2d5a9
1
Parent(s):
bd18039
Feat: Enable Neural Omniscience - AI now searches the web for every interaction seamlessly
Browse files- backend/controllers/ai.js +13 -13
backend/controllers/ai.js
CHANGED
|
@@ -38,14 +38,14 @@ const SPECIALIZATIONS = {
|
|
| 38 |
};
|
| 39 |
|
| 40 |
const SYSTEM_PROMPT = `CORE_IDENTITY:
|
| 41 |
-
You are CODEX, an elite AI collective created by Johan
|
| 42 |
|
| 43 |
ARCHITECTURAL_DIRECTIVES (MANDATORY):
|
| 44 |
-
1.
|
| 45 |
-
2.
|
| 46 |
-
3.
|
| 47 |
-
4.
|
| 48 |
-
5.
|
| 49 |
|
| 50 |
OPERATIONAL_RULES:
|
| 51 |
1. MISSION: Provide world-class technical assistance.
|
|
@@ -60,9 +60,10 @@ exports.chat = asyncHandler(async (req, res, next) => {
|
|
| 60 |
return next(new ErrorResponse('DAILY_PROTOCOL_LIMIT_EXCEEDED', 429));
|
| 61 |
}
|
| 62 |
|
|
|
|
|
|
|
| 63 |
// --- AUTOMATIC VISION ROUTING ---
|
| 64 |
const visionTriggers = ["make me an image", "generate an image", "create an image", "visualize"];
|
| 65 |
-
const lowerMsg = (message || "").toLowerCase();
|
| 66 |
if (visionTriggers.some(trigger => lowerMsg.startsWith(trigger))) {
|
| 67 |
model = 'Codex Vision';
|
| 68 |
console.log(`[Auto-Switch] Detected visual request. Engaging Codex Vision.`);
|
|
@@ -70,7 +71,7 @@ exports.chat = asyncHandler(async (req, res, next) => {
|
|
| 70 |
|
| 71 |
const activeModelName = model || 'Codex Velox';
|
| 72 |
|
| 73 |
-
// --- AUTONOMOUS TOOL INTERCEPTOR ---
|
| 74 |
let toolContext = "";
|
| 75 |
|
| 76 |
if (lowerMsg.includes("calculate") || lowerMsg.includes("math:")) {
|
|
@@ -98,11 +99,10 @@ exports.chat = asyncHandler(async (req, res, next) => {
|
|
| 98 |
toolContext += `\n${await getNews(topic)}`;
|
| 99 |
}
|
| 100 |
|
| 101 |
-
|
| 102 |
-
if (
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
const searchData = await searchWeb(searchQuery);
|
| 106 |
toolContext += `\n${searchData}`;
|
| 107 |
}
|
| 108 |
|
|
|
|
| 38 |
};
|
| 39 |
|
| 40 |
const SYSTEM_PROMPT = `CORE_IDENTITY:
|
| 41 |
+
You are CODEX, an elite AI collective created by Johan. You are the heartbeat of CodexAI.
|
| 42 |
|
| 43 |
ARCHITECTURAL_DIRECTIVES (MANDATORY):
|
| 44 |
+
1. REAL_TIME_AWARENESS: You have constant access to live web data. Use it to provide up-to-date answers.
|
| 45 |
+
2. SEAMLESS_INTEGRATION: NEVER mention that you are "searching the web" or "using a tool". Act as if the information is part of your internal knowledge.
|
| 46 |
+
3. CODING_STYLE: Prefer Functional Programming. Use pure functions and declarative logic.
|
| 47 |
+
4. STANDARDS: Adhere to 'Clean Code' principles.
|
| 48 |
+
5. ARCHITECTURE: Think like a Senior System Architect.
|
| 49 |
|
| 50 |
OPERATIONAL_RULES:
|
| 51 |
1. MISSION: Provide world-class technical assistance.
|
|
|
|
| 60 |
return next(new ErrorResponse('DAILY_PROTOCOL_LIMIT_EXCEEDED', 429));
|
| 61 |
}
|
| 62 |
|
| 63 |
+
const lowerMsg = (message || "").toLowerCase();
|
| 64 |
+
|
| 65 |
// --- AUTOMATIC VISION ROUTING ---
|
| 66 |
const visionTriggers = ["make me an image", "generate an image", "create an image", "visualize"];
|
|
|
|
| 67 |
if (visionTriggers.some(trigger => lowerMsg.startsWith(trigger))) {
|
| 68 |
model = 'Codex Vision';
|
| 69 |
console.log(`[Auto-Switch] Detected visual request. Engaging Codex Vision.`);
|
|
|
|
| 71 |
|
| 72 |
const activeModelName = model || 'Codex Velox';
|
| 73 |
|
| 74 |
+
// --- AUTONOMOUS TOOL INTERCEPTOR (ALL-CONVERSATION SEARCH) ---
|
| 75 |
let toolContext = "";
|
| 76 |
|
| 77 |
if (lowerMsg.includes("calculate") || lowerMsg.includes("math:")) {
|
|
|
|
| 99 |
toolContext += `\n${await getNews(topic)}`;
|
| 100 |
}
|
| 101 |
|
| 102 |
+
// GLOBAL SEARCH: Run for every message that isn't a simple greeting
|
| 103 |
+
if (message && message.length > 4 && !["hello", "hi ", "hey "].some(g => lowerMsg.startsWith(g))) {
|
| 104 |
+
console.log(`[Neural_Omniscience] Scanning web for context...`);
|
| 105 |
+
const searchData = await searchWeb(message);
|
|
|
|
| 106 |
toolContext += `\n${searchData}`;
|
| 107 |
}
|
| 108 |
|