@lzhzzzzwill/cofos 1.1.13 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cofos.js +20 -16
- package/package.json +1 -1
package/bin/cofos.js
CHANGED
|
@@ -45,37 +45,43 @@ function row(left, right, lw, rw) { return "│ " + cell(left, lw) + " │ " + c
|
|
|
45
45
|
function full(t, w) { return "│ " + cell(t, w - 2) + " │"; }
|
|
46
46
|
function empty(w) { return full("", w); }
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function logoLines(width) {
|
|
49
|
+
if (width >= ART_W) return ART.map((line) => C + B + line + R);
|
|
50
|
+
return [C + B + "COFOS" + R];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function render({ modelPath, cacheDir, pdfDir }) {
|
|
49
54
|
console.clear();
|
|
50
55
|
const w = fw();
|
|
51
56
|
const minSplit = 96;
|
|
52
57
|
const cwd = process.cwd();
|
|
53
|
-
const rag = "RAG: KG + BM25 +
|
|
54
|
-
const leftTitle = C + B + "COFOS" + R;
|
|
58
|
+
const rag = pdfDir ? "RAG: KG + BM25 + local PDFs" : "RAG: KG + BM25";
|
|
55
59
|
const left = [
|
|
56
|
-
|
|
57
|
-
G + "9B scientific RAG CLI" + R,
|
|
60
|
+
...logoLines(Math.floor((w - 5) * 0.48)),
|
|
58
61
|
"",
|
|
59
|
-
|
|
62
|
+
G + "Scientific RAG CLI" + R,
|
|
63
|
+
W + "Model" + R + " " + modelPath,
|
|
60
64
|
W + "Params" + R + " 9B",
|
|
61
|
-
W + "Path" + R + "
|
|
65
|
+
W + "Path" + R + " " + cwd,
|
|
66
|
+
W + "Cache" + R + " " + cacheDir,
|
|
62
67
|
];
|
|
63
68
|
const right = [
|
|
64
69
|
W + B + "What COFOS Does" + R,
|
|
65
|
-
"
|
|
70
|
+
"COFOS answers scientific questions about covalent organic frameworks,",
|
|
71
|
+
"photocatalysis, reactive oxygen species, and oxygen-reduction products.",
|
|
66
72
|
rag,
|
|
67
73
|
"",
|
|
68
74
|
W + B + "Suggested Commands" + R,
|
|
69
|
-
"/help
|
|
70
|
-
"/topk 5
|
|
71
|
-
"/rag off
|
|
72
|
-
"cofos --pdf-dir ./new_pdfs
|
|
75
|
+
"/help show commands and PDF-RAG usage",
|
|
76
|
+
"/topk 5 change retrieval depth",
|
|
77
|
+
"/rag off answer without retrieval",
|
|
78
|
+
"cofos --pdf-dir ./new_pdfs add local papers",
|
|
73
79
|
];
|
|
74
80
|
|
|
75
81
|
const lines = [top(w)];
|
|
76
82
|
if (w >= minSplit) {
|
|
77
83
|
const inner = w - 5;
|
|
78
|
-
const lw = Math.max(
|
|
84
|
+
const lw = Math.max(46, Math.floor(inner * 0.48));
|
|
79
85
|
const rw = inner - lw;
|
|
80
86
|
const n = Math.max(left.length, right.length);
|
|
81
87
|
for (let i = 0; i < n; i++) lines.push(row(left[i] || "", right[i] || "", lw, rw));
|
|
@@ -84,8 +90,6 @@ function render() {
|
|
|
84
90
|
lines.push(sep(w));
|
|
85
91
|
for (const item of right) lines.push(full(item, w));
|
|
86
92
|
}
|
|
87
|
-
lines.push(empty(w));
|
|
88
|
-
lines.push(full(G + "Type / for commands · /exit · /topk 5 · /rag off · \\ for multiline" + R, w));
|
|
89
93
|
lines.push(bot(w));
|
|
90
94
|
console.log(lines.join("\n"));
|
|
91
95
|
}
|
|
@@ -205,7 +209,7 @@ function main() {
|
|
|
205
209
|
if (pdfDir) backendArgs.push("--pdf-dir", pdfDir);
|
|
206
210
|
if (rebuildPdfIndex) backendArgs.push("--rebuild-pdf-index");
|
|
207
211
|
|
|
208
|
-
render();
|
|
212
|
+
render({ modelPath, cacheDir, pdfDir });
|
|
209
213
|
|
|
210
214
|
const py = findPy();
|
|
211
215
|
if (!py) die("Python not found. Install Python 3.9+ and re-run.");
|