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 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
- if (role === 'ai' && text.includes('SOURCES:')) {
461
- const parts = text.split('SOURCES:');
462
- cleanText = parts[0];
463
- const rawLinks = parts[1].match(/(https?:\/\/[^\s]+)/g);
 
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