pi-ocr 1.2.0 → 1.2.1
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/extensions/index.ts +12 -3
- package/extensions/ollama.ts +1 -1
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -43,7 +43,7 @@ import { homedir } from "node:os";
|
|
|
43
43
|
|
|
44
44
|
import type { Backend, Task, OcrConfig } from "./types";
|
|
45
45
|
import { TASKS, BACKENDS } from "./types";
|
|
46
|
-
import { isImage, isPdf,
|
|
46
|
+
import { isImage, isPdf, ollamaOcr, ollamaCheckModel, ollamaPullModel } from "./ollama";
|
|
47
47
|
import { mineruOcr } from "./mineru";
|
|
48
48
|
import { tesseractOcr } from "./tesseract";
|
|
49
49
|
import { pix2textOcr } from "./pix2text";
|
|
@@ -55,7 +55,16 @@ const SETTINGS_PATH = join(homedir(), ".pi", "agent", "settings.json");
|
|
|
55
55
|
function loadOcrConfig(): Partial<OcrConfig> {
|
|
56
56
|
try {
|
|
57
57
|
if (!existsSync(SETTINGS_PATH)) return {};
|
|
58
|
-
|
|
58
|
+
const settings = JSON.parse(readFileSync(SETTINGS_PATH, "utf8"));
|
|
59
|
+
// Migrate from old key (pi-minimodel-ocr) to new key (pi-ocr)
|
|
60
|
+
const old = (settings as any).minimodelOcr;
|
|
61
|
+
const current = (settings as any).piOcr;
|
|
62
|
+
if (old && !current) {
|
|
63
|
+
(settings as any).piOcr = old;
|
|
64
|
+
delete (settings as any).minimodelOcr;
|
|
65
|
+
writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
66
|
+
}
|
|
67
|
+
return (settings as any).piOcr || {};
|
|
59
68
|
} catch { return {}; }
|
|
60
69
|
}
|
|
61
70
|
|
|
@@ -66,7 +75,7 @@ function saveOcrConfig(updates: Partial<OcrConfig>) {
|
|
|
66
75
|
const settings = existsSync(SETTINGS_PATH)
|
|
67
76
|
? JSON.parse(readFileSync(SETTINGS_PATH, "utf8"))
|
|
68
77
|
: {};
|
|
69
|
-
settings.
|
|
78
|
+
settings.piOcr = { ...(settings.piOcr || {}), ...updates };
|
|
70
79
|
writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
71
80
|
} catch { /* best effort */ }
|
|
72
81
|
}
|
package/extensions/ollama.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { readFileSync, existsSync, mkdtempSync, readdirSync, unlinkSync, rmdirSync } from "node:fs";
|
|
9
|
-
import {
|
|
9
|
+
import { extname, join } from "node:path";
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
12
|
import type { Task, OcrResult, OcrProgressCallback } from "./types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ocr",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Pi extension: Zero-setup multi-backend OCR — MinerU (free cloud), Ollama (local GPU, LaTeX formulas), Pix2Text (local Python). Extract text, formulas, and tables from images and PDFs. Default: zero config, works out of the box.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|