forked from Vishal202-rgb/ResearchAI-MultiAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_trace.cjs
More file actions
29 lines (21 loc) · 1.52 KB
/
Copy pathpatch_trace.cjs
File metadata and controls
29 lines (21 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
let content = fs.readFileSync('server/controllers/researchController.js', 'utf8');
const traceEvidenceTargetFlexible = /const conciseSources = sources\.map[\s\S]*?contradict or[\s\S]*?challenge it\./m;
const traceEvidenceReplacement = `const conciseSources = sources.map((s, i) => \`[Source \${i + 1}] | Title: \${s.title} | URL: \${s.url} | Publisher: \${s.publisher} | Date: \${s.publishedDate} | Snippet: \${s.snippet}\`).join('\\n');
const ragSummaries = ragContext.map(r => \`ID: \${r.id} | Content: \${r.content}\`).join('\\n');
const prompt = \`You are an AI research assistant. Your task is to trace the evidence for this claim: "\${claim}"
The claim likely contains bracketed references like [Source 1], [Source 2], etc.
Match these references explicitly to the provided web sources which are numbered [Source 1], [Source 2], etc.
If the claim specifically cites a source, include it in the supporting evidence and explain why.
Here are the collected web sources:
\${conciseSources}
Here are related RAG document snippets:
\${ragSummaries}
Analyze these sources and document snippets. Determine which ones support the claim and which ones contradict or challenge it.`;
if (content.match(traceEvidenceTargetFlexible)) {
content = content.replace(traceEvidenceTargetFlexible, traceEvidenceReplacement);
fs.writeFileSync('server/controllers/researchController.js', content, 'utf8');
console.log('Patched Trace Evidence successfully.');
} else {
console.error('Failed to match Trace Evidence');
}