zhlajiex
commited on
Commit
·
87c245f
1
Parent(s):
cf81135
Fix: Resolve Source Button rendering and enforce all-caps marker consistency
Browse files- backend/controllers/ai.js +1 -1
- backend/public/chat.html +5 -4
backend/controllers/ai.js
CHANGED
|
@@ -42,7 +42,7 @@ You are CODEX, an elite AI collective created by Johan. You are the heartbeat of
|
|
| 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. SOURCE_CITATION: Whenever you use information from the provided web search results, you MUST include the relevant links at the bottom of your response under a "SOURCES" section.
|
| 46 |
3. SEAMLESS_INTEGRATION: Do not say "I am searching". Simply provide the answer and the links.
|
| 47 |
4. CODING_STYLE: Prefer Functional Programming. Use pure functions and declarative logic.
|
| 48 |
5. STANDARDS: Adhere to 'Clean Code' principles.
|
|
|
|
| 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. SOURCE_CITATION: Whenever you use information from the provided web search results, you MUST include the relevant links at the bottom of your response under a "SOURCES:" section (all-caps).
|
| 46 |
3. SEAMLESS_INTEGRATION: Do not say "I am searching". Simply provide the answer and the links.
|
| 47 |
4. CODING_STYLE: Prefer Functional Programming. Use pure functions and declarative logic.
|
| 48 |
5. STANDARDS: Adhere to 'Clean Code' principles.
|
backend/public/chat.html
CHANGED
|
@@ -457,10 +457,11 @@
|
|
| 457 |
// NEURAL SOURCE PARSER
|
| 458 |
let cleanText = text;
|
| 459 |
let sourceLinks = [];
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
|
|
|
| 464 |
if (rawLinks) sourceLinks = [...new Set(rawLinks)];
|
| 465 |
}
|
| 466 |
|
|
|
|
| 457 |
// NEURAL SOURCE PARSER
|
| 458 |
let cleanText = text;
|
| 459 |
let sourceLinks = [];
|
| 460 |
+
const sourceMarker = text.match(/SOURCES:/i);
|
| 461 |
+
if (role === 'ai' && sourceMarker) {
|
| 462 |
+
const markerIndex = sourceMarker.index;
|
| 463 |
+
cleanText = text.substring(0, markerIndex);
|
| 464 |
+
const rawLinks = text.substring(markerIndex).match(/(https?:\/\/[^\s\)]+)/g);
|
| 465 |
if (rawLinks) sourceLinks = [...new Set(rawLinks)];
|
| 466 |
}
|
| 467 |
|