pyocr-toolkit 0.3.0__py3-none-any.whl
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.
- pyocr_toolkit/__init__.py +3 -0
- pyocr_toolkit/__main__.py +3 -0
- pyocr_toolkit/api.py +603 -0
- pyocr_toolkit/cli.py +315 -0
- pyocr_toolkit/compare.py +142 -0
- pyocr_toolkit/config.py +86 -0
- pyocr_toolkit/credentials.py +108 -0
- pyocr_toolkit/documents.py +326 -0
- pyocr_toolkit/env.example +48 -0
- pyocr_toolkit/jobs.py +205 -0
- pyocr_toolkit/llm/__init__.py +44 -0
- pyocr_toolkit/llm/anthropic_provider.py +188 -0
- pyocr_toolkit/llm/base.py +126 -0
- pyocr_toolkit/llm/catalog.py +337 -0
- pyocr_toolkit/llm/gemini_provider.py +98 -0
- pyocr_toolkit/llm/openai_provider.py +183 -0
- pyocr_toolkit/llm/prompts.py +61 -0
- pyocr_toolkit/search.py +88 -0
- pyocr_toolkit/service.py +269 -0
- pyocr_toolkit/static/common.js +538 -0
- pyocr_toolkit/static/compare.js +157 -0
- pyocr_toolkit/static/document.js +89 -0
- pyocr_toolkit/static/jobs.js +13 -0
- pyocr_toolkit/static/library.js +28 -0
- pyocr_toolkit/static/models.js +98 -0
- pyocr_toolkit/static/providers.js +44 -0
- pyocr_toolkit/static/reader.js +78 -0
- pyocr_toolkit/static/search.js +34 -0
- pyocr_toolkit/static/styles.css +819 -0
- pyocr_toolkit/static/workspace.js +420 -0
- pyocr_toolkit/static/workspaces.js +81 -0
- pyocr_toolkit/templates/_doc_card.html +30 -0
- pyocr_toolkit/templates/_doctabs.html +14 -0
- pyocr_toolkit/templates/_icons.html +55 -0
- pyocr_toolkit/templates/_llm_picker.html +12 -0
- pyocr_toolkit/templates/base.html +97 -0
- pyocr_toolkit/templates/compare.html +84 -0
- pyocr_toolkit/templates/document.html +80 -0
- pyocr_toolkit/templates/error.html +11 -0
- pyocr_toolkit/templates/help.html +244 -0
- pyocr_toolkit/templates/home.html +90 -0
- pyocr_toolkit/templates/jobs.html +15 -0
- pyocr_toolkit/templates/library.html +44 -0
- pyocr_toolkit/templates/models.html +67 -0
- pyocr_toolkit/templates/providers.html +104 -0
- pyocr_toolkit/templates/reader.html +28 -0
- pyocr_toolkit/templates/search.html +22 -0
- pyocr_toolkit/templates/workspace.html +109 -0
- pyocr_toolkit/templates/workspace_detail.html +42 -0
- pyocr_toolkit/templates/workspaces.html +42 -0
- pyocr_toolkit/web.py +186 -0
- pyocr_toolkit/workspaces.py +330 -0
- pyocr_toolkit-0.3.0.dist-info/METADATA +483 -0
- pyocr_toolkit-0.3.0.dist-info/RECORD +57 -0
- pyocr_toolkit-0.3.0.dist-info/WHEEL +4 -0
- pyocr_toolkit-0.3.0.dist-info/entry_points.txt +3 -0
- pyocr_toolkit-0.3.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Home{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
<section class="hero">
|
|
6
|
+
<div>
|
|
7
|
+
<h1>See exactly what your text extraction produces.</h1>
|
|
8
|
+
<p class="lead">Put a document's <b>embedded text</b>, <b>Tesseract OCR</b> and <b>LLM transcriptions</b>
|
|
9
|
+
side by side, measure how far apart they are, and export clean text for your GenAI pipeline.</p>
|
|
10
|
+
</div>
|
|
11
|
+
<label class="dropzone" id="home-drop">
|
|
12
|
+
<input class="upload-input" type="file" hidden multiple
|
|
13
|
+
accept=".zip,.pdf,.xps,.oxps,.epub,.cbz,.fb2,.mobi,.svg,.png,.jpg,.jpeg,.jp2,.jpx,.bmp,.gif,.tif,.tiff,.pnm,.pgm,.pbm,.ppm,.psd,.webp">
|
|
14
|
+
<div class="dz-icon"><span class="emoji" aria-hidden="true">📤</span></div>
|
|
15
|
+
<b>Drop files here or click to upload</b>
|
|
16
|
+
<span class="small">PDF, XPS, EPUB, PNG, JPEG, TIFF, WebP or a .zip of them · several files become a workspace · up to {{ request.app.state.settings.max_upload_mb }} MB</span>
|
|
17
|
+
</label>
|
|
18
|
+
</section>
|
|
19
|
+
|
|
20
|
+
<section class="status-row">
|
|
21
|
+
<a class="card stat" href="/documents">
|
|
22
|
+
<span class="stat-icon"><span class="emoji" aria-hidden="true">📚</span></span>
|
|
23
|
+
<div><div class="v">{{ total_docs }}</div><div class="k">document{{ 's' if total_docs != 1 }} in library</div></div>
|
|
24
|
+
</a>
|
|
25
|
+
<a class="card stat" href="/providers">
|
|
26
|
+
<span class="stat-icon"><span class="emoji" aria-hidden="true">🤖</span></span>
|
|
27
|
+
<div><div class="v {{ 'good' if configured else 'warn' }}">{{ configured|length }} / {{ providers|length }}</div>
|
|
28
|
+
<div class="k">LLM providers configured</div></div>
|
|
29
|
+
</a>
|
|
30
|
+
<a class="card stat" href="/providers">
|
|
31
|
+
<span class="stat-icon"><span class="emoji" aria-hidden="true">🔠</span></span>
|
|
32
|
+
<div><div class="v {{ 'good' if tesseract else 'bad' }}">{{ 'Ready' if tesseract else 'Missing' }}</div>
|
|
33
|
+
<div class="k">Tesseract OCR</div></div>
|
|
34
|
+
</a>
|
|
35
|
+
</section>
|
|
36
|
+
{% if not configured %}
|
|
37
|
+
<div class="callout warn">{{ icon('info') }}<div>No LLM provider is configured yet. Native text and OCR work right away;
|
|
38
|
+
to compare against an LLM, <a href="/providers">add an API key</a>.</div></div>
|
|
39
|
+
{% endif %}
|
|
40
|
+
|
|
41
|
+
<section>
|
|
42
|
+
<h2 class="h-icon">{{ icon('info') }}How it works</h2>
|
|
43
|
+
<ol class="steps">
|
|
44
|
+
<li><span class="step-icon"><span class="emoji" aria-hidden="true">📤</span></span><b>Upload</b><span>Any PDF or image. Pages without a real text layer are flagged as scans.</span></li>
|
|
45
|
+
<li><span class="step-icon"><span class="emoji" aria-hidden="true">✨</span></span><b>Extract</b><span>Run Tesseract or an LLM on a page, a range or the whole document.</span></li>
|
|
46
|
+
<li><span class="step-icon"><span class="emoji" aria-hidden="true">🔍</span></span><b>Inspect & compare</b><span>Page image next to each text, word-level diffs and error rates.</span></li>
|
|
47
|
+
<li><span class="step-icon"><span class="emoji" aria-hidden="true">📦</span></span><b>Export</b><span>TXT, Markdown, JSON or JSONL, ready for RAG and ingestion.</span></li>
|
|
48
|
+
</ol>
|
|
49
|
+
</section>
|
|
50
|
+
|
|
51
|
+
{% if recent_ws %}
|
|
52
|
+
<section>
|
|
53
|
+
<div class="section-head"><h2>Workspaces</h2><a href="/workspaces" class="small">View all →</a></div>
|
|
54
|
+
<div class="doc-cards">
|
|
55
|
+
{% for w in recent_ws %}
|
|
56
|
+
<a class="card doc-card" href="/workspaces/{{ w.id }}">
|
|
57
|
+
{% if w.docs %}<img loading="lazy" src="/api/documents/{{ w.docs[0].id }}/pages/0/image?dpi=40" alt="">{% else %}<span class="ws-thumbs-empty">{{ icon('folders') }}</span>{% endif %}
|
|
58
|
+
<div>
|
|
59
|
+
<b title="{{ w.name }}">{{ w.name }}</b>
|
|
60
|
+
<div class="small">{{ w.docs|length }} document{{ 's' if w.docs|length != 1 }} · {{ w.page_count }} page{{ 's' if w.page_count != 1 }}</div>
|
|
61
|
+
</div>
|
|
62
|
+
</a>
|
|
63
|
+
{% endfor %}
|
|
64
|
+
</div>
|
|
65
|
+
</section>
|
|
66
|
+
{% endif %}
|
|
67
|
+
|
|
68
|
+
<section>
|
|
69
|
+
<div class="section-head"><h2 class="h-icon">{{ icon('clock') }}Recent documents</h2>{% if recent %}<a href="/documents" class="small">View all {{ icon('arrow-right') }}</a>{% endif %}</div>
|
|
70
|
+
{% if recent %}
|
|
71
|
+
<div class="doc-cards">
|
|
72
|
+
{% for d in recent %}
|
|
73
|
+
<a class="card doc-card" href="/documents/{{ d.id }}">
|
|
74
|
+
<img loading="lazy" src="/api/documents/{{ d.id }}/pages/0/image?dpi=40" alt="">
|
|
75
|
+
<div>
|
|
76
|
+
<b title="{{ d.filename }}">{{ d.filename }}</b>
|
|
77
|
+
<div class="small">{{ d.page_count }} page{{ 's' if d.page_count != 1 }} · {{ d.created_at|datetime }}</div>
|
|
78
|
+
<div class="badges">
|
|
79
|
+
<span class="badge {{ 'ok' if d.ocr_pages == d.page_count }}">OCR {{ d.ocr_pages }}/{{ d.page_count }}</span>
|
|
80
|
+
<span class="badge {{ 'ok' if d.llm_pages == d.page_count }}">LLM {{ d.llm_pages }}/{{ d.page_count }}</span>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</a>
|
|
84
|
+
{% endfor %}
|
|
85
|
+
</div>
|
|
86
|
+
{% else %}
|
|
87
|
+
<p class="muted small">Nothing uploaded yet. Drop a file above to get started.</p>
|
|
88
|
+
{% endif %}
|
|
89
|
+
</section>
|
|
90
|
+
{% endblock %}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Jobs{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
<div class="page-head"><div>
|
|
6
|
+
<h1>Extraction jobs</h1>
|
|
7
|
+
<p>Background extractions started from a document's <i>Overview</i> page. The list
|
|
8
|
+
is kept in memory and resets when the server restarts; the extracted text is stored on disk and is never lost.</p>
|
|
9
|
+
</div></div>
|
|
10
|
+
<div id="all-jobs" class="job-list" data-names='{{ names|tojson }}'>
|
|
11
|
+
{% if not jobs %}<div class="empty"><div class="empty-icon"><span class="emoji" aria-hidden="true">⏳</span></div><h2>No jobs yet</h2>
|
|
12
|
+
<p>Start one from a document's <b>Overview</b> page.</p></div>{% endif %}
|
|
13
|
+
</div>
|
|
14
|
+
{% endblock %}
|
|
15
|
+
{% block scripts %}<script src="/static/jobs.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Library{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
{% set status_cls = {'complete': 'ok', 'scanned': 'scan', 'partial': 'run'} %}
|
|
6
|
+
{% set total_pages = docs|sum(attribute='page_count') %}
|
|
7
|
+
{% set total_missing = docs|sum(attribute='missing_pages') %}
|
|
8
|
+
<div class="page-head">
|
|
9
|
+
<div>
|
|
10
|
+
<h1>Library</h1>
|
|
11
|
+
<p>{{ docs|length }} document{{ 's' if docs|length != 1 }} · {{ total_pages }} page{{ 's' if total_pages != 1 }}
|
|
12
|
+
{% if docs %} · {% if total_missing %}<b class="warn">{{ total_missing }} page{{ 's' if total_missing != 1 }} still without text</b>{% else %}every page has text{% endif %}{% endif %}</p>
|
|
13
|
+
</div>
|
|
14
|
+
{% if docs %}<div class="lib-filters">
|
|
15
|
+
{% if spaces %}<select id="lib-ws" aria-label="Filter by workspace">
|
|
16
|
+
<option value="">All workspaces</option>
|
|
17
|
+
{% for w in spaces %}<option value="{{ w.id }}">{{ w.name }}</option>{% endfor %}
|
|
18
|
+
</select>{% endif %}
|
|
19
|
+
<input type="search" id="lib-filter" placeholder="Filter by file name…" aria-label="Filter by file name">
|
|
20
|
+
</div>{% endif %}
|
|
21
|
+
</div>
|
|
22
|
+
{% if docs %}
|
|
23
|
+
<div class="chips lib-chips" role="radiogroup" aria-label="Filter by status">
|
|
24
|
+
{% for key, label in [('all', 'All'), ('partial', 'Needs text'), ('scanned', 'Scanned'), ('complete', 'All pages have text')] %}
|
|
25
|
+
<label><input type="radio" name="lib-status" value="{{ key }}" {{ 'checked' if key == 'all' }}>
|
|
26
|
+
{{ label }} <span class="count">{{ docs|length if key == 'all' else docs|selectattr('status', 'equalto', key)|list|length }}</span></label>
|
|
27
|
+
{% endfor %}
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<div class="lib-grid" id="lib-grid">
|
|
31
|
+
{% for d in docs %}
|
|
32
|
+
{% include "_doc_card.html" %}
|
|
33
|
+
{% endfor %}
|
|
34
|
+
</div>
|
|
35
|
+
<p class="small muted" id="lib-none" hidden>No documents match this filter.</p>
|
|
36
|
+
{% else %}
|
|
37
|
+
<div class="empty">
|
|
38
|
+
<div class="empty-icon"><span class="emoji" aria-hidden="true">📭</span></div>
|
|
39
|
+
<h2>No documents yet</h2>
|
|
40
|
+
<p>Use <b>Upload</b> in the top bar or drop files anywhere on this page.</p>
|
|
41
|
+
</div>
|
|
42
|
+
{% endif %}
|
|
43
|
+
{% endblock %}
|
|
44
|
+
{% block scripts %}<script src="/static/library.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% block title %}Models{% endblock %}
|
|
3
|
+
{% block content %}
|
|
4
|
+
<div class="page-head"><div>
|
|
5
|
+
<h1>Models</h1>
|
|
6
|
+
<p>Search vision models and see how well each one suits <b>verbatim page transcription</b>. This list only
|
|
7
|
+
suggests models: you can still type any model or deployment name in the model box.</p>
|
|
8
|
+
</div></div>
|
|
9
|
+
|
|
10
|
+
<section class="card">
|
|
11
|
+
<div class="model-filters">
|
|
12
|
+
<input type="search" id="m-q" value="{{ q }}" placeholder="Search models: name, vendor, “handwriting”, “cheap”…"
|
|
13
|
+
aria-label="Search models" class="grow" autofocus>
|
|
14
|
+
<select id="m-provider" aria-label="Provider">
|
|
15
|
+
<option value="">All providers</option>
|
|
16
|
+
{% for p in providers %}<option value="{{ p.id }}" {{ 'selected' if p.id == provider }}>{{ p.label }}</option>{% endfor %}
|
|
17
|
+
</select>
|
|
18
|
+
<select id="m-rating" aria-label="Rating">
|
|
19
|
+
<option value="">Any rating</option>
|
|
20
|
+
{% for k, v in ratings.items() if k != 'unrated' %}<option value="{{ k }}">{{ v[0] }}</option>{% endfor %}
|
|
21
|
+
</select>
|
|
22
|
+
<label class="small nowrap"><input type="checkbox" id="m-deprecated"> show deprecated</label>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="table-wrap">
|
|
25
|
+
<table class="table compact models-table">
|
|
26
|
+
<thead><tr><th>Model</th><th>For OCR</th><th>Price (in / out per 1M tokens)</th><th>Why</th><th></th></tr></thead>
|
|
27
|
+
<tbody id="m-results"><tr><td colspan="5" class="muted">Loading…</td></tr></tbody>
|
|
28
|
+
</table>
|
|
29
|
+
</div>
|
|
30
|
+
<p class="small muted" id="m-count"></p>
|
|
31
|
+
</section>
|
|
32
|
+
|
|
33
|
+
<section class="card">
|
|
34
|
+
<div class="section-head">
|
|
35
|
+
<h2>Models your key can use</h2>
|
|
36
|
+
<div class="row">
|
|
37
|
+
<select id="live-provider" aria-label="Provider to list">
|
|
38
|
+
{% for p in providers if p.can_list_models %}<option value="{{ p.id }}" {{ 'selected' if p.id == provider }}>{{ p.label }}{{ '' if p.configured else ' (not configured)' }}</option>{% endfor %}
|
|
39
|
+
</select>
|
|
40
|
+
<button class="btn small" id="live-load">List models</button>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<p class="small muted">Asks the provider's API which models your credentials can use, then rates each one.
|
|
44
|
+
Azure deployments can't be listed this way: type the deployment name on the
|
|
45
|
+
<a href="/providers">Providers</a> page instead.</p>
|
|
46
|
+
<input type="search" id="live-q" placeholder="Filter this list…" aria-label="Filter listed models" hidden>
|
|
47
|
+
<div id="live-results"></div>
|
|
48
|
+
</section>
|
|
49
|
+
|
|
50
|
+
<section class="card">
|
|
51
|
+
<h2>How the ratings work</h2>
|
|
52
|
+
<ul class="small">
|
|
53
|
+
<li><span class="badge excellent">Excellent for OCR</span> near the top of public OCR benchmarks, or the vendor's top vision
|
|
54
|
+
tier. Use for handwriting, tables, poor scans.</li>
|
|
55
|
+
<li><span class="badge ok">Good for OCR</span> reliable on most printed documents; good value for bulk jobs.</li>
|
|
56
|
+
<li><span class="badge fair">Fair: clean print only</span> cheap or old models; expect skipped or "fixed" text on hard pages.</li>
|
|
57
|
+
<li><span class="badge bad">Not suitable</span> can't read images (embeddings, audio, image generators, text-only).</li>
|
|
58
|
+
<li><span class="badge">Not rated</span> a name that isn't in the catalog (custom, fine-tuned, local). It may work fine:
|
|
59
|
+
run <i>Test connection</i>, then Compare it against another source.</li>
|
|
60
|
+
</ul>
|
|
61
|
+
<p class="small">“benchmark” means the rating rests on a published OCR result; “vendor” means it's estimated from the
|
|
62
|
+
vendor's docs and model tier. Benchmarks disagree and go stale, so measure on your own pages with the Compare tab.
|
|
63
|
+
Catalog compiled {{ updated }} from:
|
|
64
|
+
{% for label, url in sources %}<a href="{{ url }}" target="_blank" rel="noopener">{{ label }}</a>{{ ', ' if not loop.last }}{% endfor %}.</p>
|
|
65
|
+
</section>
|
|
66
|
+
{% endblock %}
|
|
67
|
+
{% block scripts %}<script src="/static/models.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Providers{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
<div class="page-head"><div>
|
|
6
|
+
<h1>Providers & setup</h1>
|
|
7
|
+
<p>Credentials come from environment variables (or a <code>.env</code> file next to where you run
|
|
8
|
+
<code>pyocr serve</code>). They never leave the server; restart it after changing them.</p>
|
|
9
|
+
</div></div>
|
|
10
|
+
|
|
11
|
+
<section class="card">
|
|
12
|
+
<div class="section-head"><h2 class="h-icon">{{ icon('cpu') }}Tesseract OCR</h2>
|
|
13
|
+
<span class="badge {{ 'ok' if tesseract else 'scan' }}">{{ icon('check' if tesseract else 'alert') }}{{ 'installed' if tesseract else 'not installed' }}</span></div>
|
|
14
|
+
{% if tesseract %}
|
|
15
|
+
<p class="small">{{ tesseract_version }} at <code>{{ tesseract }}</code>. Using language
|
|
16
|
+
<code>{{ settings.tesseract_language }}</code> at {{ settings.ocr_dpi }} DPI.
|
|
17
|
+
Installed languages: {% for l in tesseract_langs %}<code>{{ l }}</code> {% endfor %}</p>
|
|
18
|
+
<p class="small">Set <code>TESSERACT_LANGUAGE=eng+deu</code> (for example) to OCR multi-language documents.</p>
|
|
19
|
+
{% else %}
|
|
20
|
+
<p>Install it to enable the OCR tab:</p>
|
|
21
|
+
<pre class="code">sudo apt-get install tesseract-ocr tesseract-ocr-eng # Debian / Ubuntu
|
|
22
|
+
brew install tesseract # macOS
|
|
23
|
+
choco install tesseract # Windows (or the UB Mannheim installer)</pre>
|
|
24
|
+
<p class="small">Or run the Docker image, which already includes it.</p>
|
|
25
|
+
{% endif %}
|
|
26
|
+
</section>
|
|
27
|
+
|
|
28
|
+
<div class="section-head" style="margin-top:32px">
|
|
29
|
+
<h2 class="h-icon">{{ icon('sparkles') }}LLM providers</h2>
|
|
30
|
+
<a class="btn small" href="/models">{{ icon('grid') }}Browse & search models</a>
|
|
31
|
+
</div>
|
|
32
|
+
<p class="small muted">Set credentials here or in environment variables / <code>.env</code>. Values saved here are
|
|
33
|
+
stored on this machine in <code>{{ credentials_path }}</code> (owner-only), override the environment, and take
|
|
34
|
+
effect immediately. Keys are never sent back to the browser.</p>
|
|
35
|
+
<div class="provider-grid">
|
|
36
|
+
{% for p in providers %}
|
|
37
|
+
{% set st = cred_status[p.id] %}
|
|
38
|
+
<section class="card provider" data-provider-id="{{ p.id }}"{% if p.configured %} data-provider-ready{% endif %}>
|
|
39
|
+
<div class="section-head">
|
|
40
|
+
<h3>{{ p.label }}</h3>
|
|
41
|
+
<span class="badge {{ 'ok' if p.configured else 'scan' }}">{{ icon('check' if p.configured else 'alert') }}{{ 'ready' if p.configured else 'not configured' }}</span>
|
|
42
|
+
</div>
|
|
43
|
+
<table class="table compact env">
|
|
44
|
+
{% for e in st %}
|
|
45
|
+
<tr>
|
|
46
|
+
<td><code>{{ e.name }}</code>{% if e.required %} <span class="badge">required</span>{% endif %}</td>
|
|
47
|
+
<td class="nowrap">{% if e.state == 'set' %}<span class="good">{{ icon('check') }}set</span>{% if e.saved %} <span class="badge" title="saved on this page; overrides the environment">saved here</span>{% endif %}{% elif e.state == 'default' %}<span class="muted" title="not set; using the built-in default">default: {{ e.default }}</span>{% else %}<span class="{{ 'bad' if e.required else 'muted' }}">{{ 'missing' if e.required else '–' }}</span>{% endif %}</td>
|
|
48
|
+
<td class="small">{{ e.description }}</td>
|
|
49
|
+
</tr>
|
|
50
|
+
{% endfor %}
|
|
51
|
+
</table>
|
|
52
|
+
<details class="cred-edit">
|
|
53
|
+
<summary>{{ 'Edit settings' if p.configured else 'Set up in the browser' }}</summary>
|
|
54
|
+
<form data-cred-form autocomplete="off">
|
|
55
|
+
{% for e in st if e.editable %}
|
|
56
|
+
<div class="cred-field">
|
|
57
|
+
<label for="cred-{{ p.id }}-{{ e.name }}"><code>{{ e.name }}</code>{% if e.required %} <span class="badge">required</span>{% endif %}</label>
|
|
58
|
+
{% if e.secret %}
|
|
59
|
+
<input type="password" id="cred-{{ p.id }}-{{ e.name }}" name="{{ e.name }}" autocomplete="new-password" spellcheck="false"
|
|
60
|
+
placeholder="{{ '•••••••• set – type to replace' if e.state == 'set' else 'paste key' }}">
|
|
61
|
+
{% else %}
|
|
62
|
+
<input type="text" id="cred-{{ p.id }}-{{ e.name }}" name="{{ e.name }}" spellcheck="false"
|
|
63
|
+
{% if e.name.endswith('_MODEL') or e.name.endswith('_DEPLOYMENT') %}list="models-{{ p.id }}"{% endif %}
|
|
64
|
+
placeholder="{{ e.value if e.value else (e.description) }}">
|
|
65
|
+
{% endif %}
|
|
66
|
+
{% if e.saved %}<label class="small cred-reset"><input type="checkbox" data-clear="{{ e.name }}"> forget saved value{% if e.from_env %} (use environment){% endif %}</label>{% endif %}
|
|
67
|
+
</div>
|
|
68
|
+
{% endfor %}
|
|
69
|
+
<div class="row">
|
|
70
|
+
<button class="btn small primary" type="submit">Save</button>
|
|
71
|
+
<span class="small muted">Blank fields keep their current value.</span>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="small" data-cred-result></div>
|
|
74
|
+
</form>
|
|
75
|
+
</details>
|
|
76
|
+
<datalist id="models-{{ p.id }}">{% for m in p.describe().model_options %}<option value="{{ m.name }}" label="{{ m.rating_label }}{{ ' · ' ~ m.label if m.label is defined }}">{% endfor %}</datalist>
|
|
77
|
+
<div class="row">
|
|
78
|
+
<input data-test-model value="{{ p.default_model or '' }}" placeholder="{{ p.model_hint }}" class="grow"
|
|
79
|
+
list="models-{{ p.id }}" autocomplete="off" aria-label="Model to test">
|
|
80
|
+
<button class="btn small" data-test {{ 'disabled' if not p.configured }}>{{ icon('plug') }}Test connection</button>
|
|
81
|
+
<a class="small" href="/models?provider={{ p.id }}">Models {{ icon('external') }}</a>
|
|
82
|
+
{% if p.docs_url %}<a class="small" href="{{ p.docs_url }}" target="_blank" rel="noopener">Get credentials {{ icon('external') }}</a>{% endif %}
|
|
83
|
+
</div>
|
|
84
|
+
<div class="small model-verdict" data-model-verdict></div>
|
|
85
|
+
<div class="small" data-test-result></div>
|
|
86
|
+
</section>
|
|
87
|
+
{% endfor %}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<section class="card">
|
|
91
|
+
<h2 class="h-icon">{{ icon('settings') }}Rendering settings in effect</h2>
|
|
92
|
+
<table class="table compact">
|
|
93
|
+
<tr><td><code>DATA_DIR</code></td><td>{{ settings.data_dir }}</td><td class="small">where uploads and results are stored</td></tr>
|
|
94
|
+
<tr><td><code>PREVIEW_DPI</code></td><td>{{ settings.preview_dpi }}</td><td class="small">page images in the browser</td></tr>
|
|
95
|
+
<tr><td><code>LLM_DPI</code> / <code>LLM_MAX_EDGE_PX</code></td><td>{{ settings.llm_dpi }} / {{ settings.llm_max_edge_px }}</td><td class="small">image sent to the LLM</td></tr>
|
|
96
|
+
<tr><td><code>OCR_DPI</code></td><td>{{ settings.ocr_dpi }}</td><td class="small">image given to Tesseract</td></tr>
|
|
97
|
+
<tr><td><code>LLM_CONCURRENCY</code></td><td>{{ settings.llm_concurrency }}</td><td class="small">parallel LLM calls</td></tr>
|
|
98
|
+
<tr><td><code>MAX_UPLOAD_MB</code></td><td>{{ settings.max_upload_mb }}</td><td class="small">upload limit</td></tr>
|
|
99
|
+
</table>
|
|
100
|
+
<p class="small">A ready-to-edit template of every setting is in <code>.env.example</code>; run
|
|
101
|
+
<code>pyocr init</code> to copy it into the current directory.</p>
|
|
102
|
+
</section>
|
|
103
|
+
{% endblock %}
|
|
104
|
+
{% block scripts %}<script src="/static/providers.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Text · {{ doc.filename }}{% endblock %}
|
|
4
|
+
{% block subnav %}{% include "_doctabs.html" %}{% endblock %}
|
|
5
|
+
{% block content %}
|
|
6
|
+
<div id="reader-root" data-doc-id="{{ doc.id }}">
|
|
7
|
+
<div class="toolbar sticky">
|
|
8
|
+
<label>Source
|
|
9
|
+
<select id="source-select">
|
|
10
|
+
{% for s in sources %}
|
|
11
|
+
<option value="{{ s.id }}" {{ 'disabled' if not s.page_count }}>{{ s.label }} ({{ s.page_count }}/{{ doc.page_count }} pages)</option>
|
|
12
|
+
{% endfor %}
|
|
13
|
+
</select>
|
|
14
|
+
</label>
|
|
15
|
+
<label class="check"><input type="checkbox" id="show-images"> {{ icon('image') }}Page images</label>
|
|
16
|
+
<input type="search" id="find" placeholder="Find in text…">
|
|
17
|
+
<span id="find-count" class="small"></span>
|
|
18
|
+
<div class="spacer"></div>
|
|
19
|
+
<button class="btn small ghost" id="copy-all">{{ icon('copy') }}Copy all</button>
|
|
20
|
+
<details class="menu right"><summary class="btn small">{{ icon('download') }}Download {{ icon('chevron-down') }}</summary>
|
|
21
|
+
<div id="downloads"></div>
|
|
22
|
+
</details>
|
|
23
|
+
</div>
|
|
24
|
+
<div id="reader-summary" class="small"></div>
|
|
25
|
+
<div id="reader-pages" class="reader-pages"></div>
|
|
26
|
+
</div>
|
|
27
|
+
{% endblock %}
|
|
28
|
+
{% block scripts %}<script src="/static/reader.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Search{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
<div class="page-head"><div>
|
|
6
|
+
<h1>Search all documents</h1>
|
|
7
|
+
<p>Case-insensitive; phrases match across line breaks. OCR and LLM text is searched where it has been extracted.</p>
|
|
8
|
+
</div></div>
|
|
9
|
+
<form id="lib-search" action="/search">
|
|
10
|
+
<div class="search-bar">
|
|
11
|
+
<input type="search" name="q" id="q" value="{{ q }}" placeholder="Words or a phrase…" autofocus>
|
|
12
|
+
<button class="btn primary">{{ icon('search') }}Search</button>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="chips" style="margin:4px 0 22px">
|
|
15
|
+
<label><input type="checkbox" name="src" value="native" checked> {{ icon('type') }}Native text</label>
|
|
16
|
+
<label><input type="checkbox" name="src" value="ocr" checked> {{ icon('cpu') }}OCR</label>
|
|
17
|
+
<label><input type="checkbox" name="src" value="llm" checked> {{ icon('sparkles') }}LLM</label>
|
|
18
|
+
</div>
|
|
19
|
+
</form>
|
|
20
|
+
<div id="lib-results"></div>
|
|
21
|
+
{% endblock %}
|
|
22
|
+
{% block scripts %}<script src="/static/search.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Page {{ page_no }} · {{ doc.filename }}{% endblock %}
|
|
4
|
+
{% block body_class %}app{% endblock %}
|
|
5
|
+
{% block subnav %}{% include "_doctabs.html" %}{% endblock %}
|
|
6
|
+
{% block main %}
|
|
7
|
+
<main id="workspace" data-doc-id="{{ doc.id }}" data-page="{{ page_no - 1 }}" data-is-pdf="{{ 'true' if doc.is_pdf else 'false' }}">
|
|
8
|
+
<aside class="sidebar">
|
|
9
|
+
<form id="search-form" class="search">
|
|
10
|
+
<input id="search-input" type="search" placeholder="Search this document…" title="Shortcut: /">
|
|
11
|
+
<div class="search-sources chips" title="Which texts to search">
|
|
12
|
+
<label><input type="checkbox" value="native" checked> Native</label>
|
|
13
|
+
<label><input type="checkbox" value="ocr" checked> OCR</label>
|
|
14
|
+
<label><input type="checkbox" value="llm" checked> LLM</label>
|
|
15
|
+
</div>
|
|
16
|
+
</form>
|
|
17
|
+
<div id="search-results" hidden></div>
|
|
18
|
+
<ol id="page-list" class="pages"></ol>
|
|
19
|
+
</aside>
|
|
20
|
+
|
|
21
|
+
<section class="viewer">
|
|
22
|
+
<div class="viewer-toolbar">
|
|
23
|
+
<button id="prev-page" class="btn small ghost icon-only" title="Previous page (←)">{{ icon('chevron-left') }}</button>
|
|
24
|
+
<span id="page-label">–</span>
|
|
25
|
+
<button id="next-page" class="btn small ghost icon-only" title="Next page (→)">{{ icon('chevron-right') }}</button>
|
|
26
|
+
<span class="sep"></span>
|
|
27
|
+
<button id="zoom-out" class="btn small ghost icon-only" title="Zoom out" aria-label="Zoom out">{{ icon('zoom-out') }}</button>
|
|
28
|
+
<span id="zoom-label">100%</span>
|
|
29
|
+
<button id="zoom-in" class="btn small ghost icon-only" title="Zoom in" aria-label="Zoom in">{{ icon('zoom-in') }}</button>
|
|
30
|
+
<button id="zoom-fit" class="btn small ghost">{{ icon('maximize') }}Fit</button>
|
|
31
|
+
<span class="sep badges-sep"></span>
|
|
32
|
+
<span id="page-badges"></span>
|
|
33
|
+
<div class="spacer"></div>
|
|
34
|
+
<a id="open-image" class="btn small ghost" target="_blank" title="Open a high-resolution render">{{ icon('image') }}Hi-res</a>
|
|
35
|
+
</div>
|
|
36
|
+
<div id="page-scroll" class="page-scroll">
|
|
37
|
+
<div id="page-frame" class="page-frame">
|
|
38
|
+
<img id="page-img" alt="page">
|
|
39
|
+
<div id="highlight-layer"></div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</section>
|
|
43
|
+
|
|
44
|
+
<section class="panel">
|
|
45
|
+
<nav class="tabs" role="tablist">
|
|
46
|
+
<button data-tab="native" class="active">{{ icon('type') }}Native</button>
|
|
47
|
+
<button data-tab="ocr">{{ icon('cpu') }}OCR</button>
|
|
48
|
+
<button data-tab="llm">{{ icon('sparkles') }}LLM</button>
|
|
49
|
+
<button data-tab="compare">{{ icon('diff') }}Compare</button>
|
|
50
|
+
<button data-tab="side" title="Native, OCR and LLM text in columns (5)">{{ icon('columns') }}Side by side</button>
|
|
51
|
+
</nav>
|
|
52
|
+
|
|
53
|
+
<div class="tab-body" data-tab="native">
|
|
54
|
+
<div class="tab-meta"><span id="native-meta"></span><div class="spacer"></div>
|
|
55
|
+
<button class="btn small ghost" data-copy="#native-text" title="Copy text">{{ icon('copy') }}Copy</button></div>
|
|
56
|
+
<pre id="native-text" class="text"></pre>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div class="tab-body" data-tab="ocr" hidden>
|
|
60
|
+
<div class="tab-meta"><span id="ocr-meta"></span><div class="spacer"></div>
|
|
61
|
+
<button class="btn small ghost" data-copy="#ocr-text" title="Copy text">{{ icon('copy') }}Copy</button>
|
|
62
|
+
<button id="run-ocr" class="btn small">{{ icon('play') }}<span class="lbl">Run OCR</span></button></div>
|
|
63
|
+
<pre id="ocr-text" class="text"></pre>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div class="tab-body" data-tab="llm" hidden>
|
|
67
|
+
{% set picker_id = 'ws' %}{% include "_llm_picker.html" %}
|
|
68
|
+
<div class="tab-meta">
|
|
69
|
+
<button id="run-llm" class="btn small primary">{{ icon('sparkles') }}Transcribe this page</button>
|
|
70
|
+
<button id="rerun-llm" class="btn small ghost" title="Ignore the cache and call the model again">{{ icon('refresh') }}Re-run</button>
|
|
71
|
+
<div class="spacer"></div>
|
|
72
|
+
<button class="btn small ghost" data-copy="#llm-text" title="Copy text">{{ icon('copy') }}Copy</button>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="tab-meta">
|
|
75
|
+
<label class="grow">Stored <select id="llm-result-select" title="Transcriptions stored for this page"></select></label>
|
|
76
|
+
<button id="delete-llm" class="btn small ghost danger icon-only" title="Delete this stored result">{{ icon('trash') }}</button>
|
|
77
|
+
</div>
|
|
78
|
+
<div id="llm-meta" class="tab-meta small"></div>
|
|
79
|
+
<pre id="llm-text" class="text"></pre>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div class="tab-body" data-tab="side" hidden>
|
|
83
|
+
<div class="side-cols">
|
|
84
|
+
<section class="side-col"><div class="side-head"><b>{{ icon('type') }}Native</b><span id="side-native-meta"></span></div><pre id="side-native" class="text"></pre></section>
|
|
85
|
+
<section class="side-col"><div class="side-head"><b>{{ icon('cpu') }}OCR</b><span id="side-ocr-meta"></span></div><pre id="side-ocr" class="text"></pre></section>
|
|
86
|
+
<section class="side-col"><div class="side-head"><b>{{ icon('sparkles') }}LLM</b><span id="side-llm-meta"></span></div><pre id="side-llm" class="text"></pre></section>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div class="tab-body" data-tab="compare" hidden>
|
|
91
|
+
<div class="compare-controls">
|
|
92
|
+
<label>Reference <select id="cmp-ref"></select></label>
|
|
93
|
+
<label>vs <select id="cmp-hyp"></select></label>
|
|
94
|
+
<label class="check"><input type="checkbox" id="cmp-case" checked> Ignore case</label>
|
|
95
|
+
<label class="check"><input type="checkbox" id="cmp-punct"> Ignore punctuation</label>
|
|
96
|
+
<button id="run-compare" class="btn small primary">{{ icon('diff') }}Compare</button>
|
|
97
|
+
</div>
|
|
98
|
+
<div id="cmp-metrics" class="metrics"></div>
|
|
99
|
+
<div class="legend" id="cmp-legend" hidden>
|
|
100
|
+
<span class="del">missing in candidate</span>
|
|
101
|
+
<span class="ins">extra in candidate</span>
|
|
102
|
+
<span class="rep"><s>reference</s> → candidate</span>
|
|
103
|
+
</div>
|
|
104
|
+
<pre id="cmp-diff" class="text diff"></pre>
|
|
105
|
+
</div>
|
|
106
|
+
</section>
|
|
107
|
+
</main>
|
|
108
|
+
{% endblock %}
|
|
109
|
+
{% block scripts %}<script src="/static/workspace.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}{{ ws.name }}{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
{% set status_cls = {'complete': 'ok', 'scanned': 'scan', 'partial': 'run'} %}
|
|
6
|
+
<div class="page-head" id="ws-root" data-ws-id="{{ ws.id }}" data-ws-name="{{ ws.name }}">
|
|
7
|
+
<div class="ws-title">
|
|
8
|
+
<a href="/workspaces" class="crumb small">Workspaces</a>
|
|
9
|
+
<div class="ws-name-row">
|
|
10
|
+
<h1 id="ws-name">{{ ws.name }}</h1>
|
|
11
|
+
<button type="button" class="btn small ghost icon-only" id="ws-rename" title="Rename" aria-label="Rename workspace">{{ icon('pencil') }}</button>
|
|
12
|
+
</div>
|
|
13
|
+
<form id="ws-rename-form" class="ws-rename-form" hidden>
|
|
14
|
+
<input id="ws-rename-input" maxlength="80" value="{{ ws.name }}" aria-label="Workspace name" required>
|
|
15
|
+
<button class="btn small primary">Save</button>
|
|
16
|
+
<button type="button" class="btn small ghost" id="ws-rename-cancel">Cancel</button>
|
|
17
|
+
<div class="chips ws-suggest" id="ws-rename-suggest"></div>
|
|
18
|
+
</form>
|
|
19
|
+
<p>{{ ws.docs|length }} document{{ 's' if ws.docs|length != 1 }} · {{ ws.page_count }} page{{ 's' if ws.page_count != 1 }} · {{ ws.size_bytes|filesize }}
|
|
20
|
+
{% if ws.docs %} · {% if ws.missing_pages %}<b class="warn">{{ ws.missing_pages }} page{{ 's' if ws.missing_pages != 1 }} still without text</b>{% else %}every page has text{% endif %}{% endif %}</p>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="ws-actions">
|
|
23
|
+
<label class="btn primary">{{ icon('upload') }}Add files
|
|
24
|
+
<input class="upload-input" type="file" hidden multiple data-workspace="{{ ws.id }}"
|
|
25
|
+
accept=".zip,.pdf,.xps,.oxps,.epub,.cbz,.fb2,.mobi,.svg,.png,.jpg,.jpeg,.jp2,.jpx,.bmp,.gif,.tif,.tiff,.pnm,.pgm,.pbm,.ppm,.psd,.webp">
|
|
26
|
+
</label>
|
|
27
|
+
<button type="button" class="btn ghost danger" id="ws-delete">{{ icon('trash') }}Delete workspace</button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
{% if ws.docs %}
|
|
31
|
+
<div class="lib-grid" id="lib-grid">
|
|
32
|
+
{% for d in ws.docs %}{% include "_doc_card.html" %}{% endfor %}
|
|
33
|
+
</div>
|
|
34
|
+
{% else %}
|
|
35
|
+
<div class="empty">
|
|
36
|
+
<div class="empty-icon">{{ icon('inbox') }}</div>
|
|
37
|
+
<h2>This workspace is empty</h2>
|
|
38
|
+
<p>Use <b>Add files</b> or drop PDFs, images or a .zip anywhere on this page. They go straight into <b>{{ ws.name }}</b>.</p>
|
|
39
|
+
</div>
|
|
40
|
+
{% endif %}
|
|
41
|
+
{% endblock %}
|
|
42
|
+
{% block scripts %}<script src="/static/workspaces.js?v={{ version }}"></script>{% endblock %}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% from "_icons.html" import icon %}
|
|
3
|
+
{% block title %}Workspaces{% endblock %}
|
|
4
|
+
{% block content %}
|
|
5
|
+
<div class="page-head">
|
|
6
|
+
<div>
|
|
7
|
+
<h1>Workspaces</h1>
|
|
8
|
+
<p>A workspace groups documents uploaded together, such as several PDFs or a zip, under one name you can edit.</p>
|
|
9
|
+
</div>
|
|
10
|
+
<button type="button" class="btn" id="ws-new">{{ icon('folders') }}New empty workspace</button>
|
|
11
|
+
</div>
|
|
12
|
+
{% if spaces %}
|
|
13
|
+
<div class="lib-grid ws-grid">
|
|
14
|
+
{% for w in spaces %}
|
|
15
|
+
<a class="card ws-card" href="/workspaces/{{ w.id }}">
|
|
16
|
+
<div class="ws-thumbs">
|
|
17
|
+
{% for d in w.docs[:3] %}<img loading="lazy" src="/api/documents/{{ d.id }}/pages/0/image?dpi=40" alt="">{% endfor %}
|
|
18
|
+
{% if not w.docs %}<span class="ws-thumbs-empty">{{ icon('folders') }}</span>{% endif %}
|
|
19
|
+
</div>
|
|
20
|
+
<div class="lib-body">
|
|
21
|
+
<b class="file-name" title="{{ w.name }}">{{ w.name }}</b>
|
|
22
|
+
<div class="small muted">{{ w.docs|length }} document{{ 's' if w.docs|length != 1 }} · {{ w.page_count }} page{{ 's' if w.page_count != 1 }} · {{ w.size_bytes|filesize }}</div>
|
|
23
|
+
<div class="badges">
|
|
24
|
+
{% if not w.docs %}<span class="badge">Empty</span>
|
|
25
|
+
{% elif w.missing_pages %}<span class="badge scan">{{ w.missing_pages }} page{{ 's' if w.missing_pages != 1 }} need{{ 's' if w.missing_pages == 1 }} text</span>
|
|
26
|
+
{% else %}<span class="badge ok">All pages have text</span>{% endif %}
|
|
27
|
+
<span class="badge">Created {{ w.created_at|datetime }}</span>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</a>
|
|
31
|
+
{% endfor %}
|
|
32
|
+
</div>
|
|
33
|
+
{% else %}
|
|
34
|
+
<div class="empty">
|
|
35
|
+
<div class="empty-icon">{{ icon('folders') }}</div>
|
|
36
|
+
<h2>No workspaces yet</h2>
|
|
37
|
+
<p>Upload several files at once, or a <b>.zip</b>, and pyocr offers to put them in a workspace.
|
|
38
|
+
You can also start an empty one and add files to it.</p>
|
|
39
|
+
</div>
|
|
40
|
+
{% endif %}
|
|
41
|
+
{% endblock %}
|
|
42
|
+
{% block scripts %}<script src="/static/workspaces.js?v={{ version }}"></script>{% endblock %}
|