fylepy 0.1.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.
- fyle/__init__.py +46 -0
- fyle/_core/__init__.py +5 -0
- fyle/_core/api.py +164 -0
- fyle/_core/chunking.py +107 -0
- fyle/_core/document.py +345 -0
- fyle/_core/fetcher.py +68 -0
- fyle/_core/registry.py +107 -0
- fyle/_core/sniffer.py +251 -0
- fyle/_readers/__init__.py +32 -0
- fyle/_readers/_md_structure.py +208 -0
- fyle/_readers/_whisper.py +126 -0
- fyle/_readers/archive/__init__.py +8 -0
- fyle/_readers/archive/stdlib.py +513 -0
- fyle/_readers/audio/__init__.py +9 -0
- fyle/_readers/audio/faster_whisper.py +162 -0
- fyle/_readers/base.py +70 -0
- fyle/_readers/csv/__init__.py +6 -0
- fyle/_readers/csv/stdlib.py +119 -0
- fyle/_readers/docx/__init__.py +6 -0
- fyle/_readers/docx/mammoth.py +130 -0
- fyle/_readers/html/__init__.py +6 -0
- fyle/_readers/html/markdownify.py +113 -0
- fyle/_readers/image/__init__.py +18 -0
- fyle/_readers/image/stdlib.py +136 -0
- fyle/_readers/markdown/__init__.py +6 -0
- fyle/_readers/markdown/stdlib.py +61 -0
- fyle/_readers/pdf/__init__.py +2 -0
- fyle/_readers/pdf/pymupdf4llm.py +202 -0
- fyle/_readers/pptx/__init__.py +7 -0
- fyle/_readers/pptx/python_pptx.py +306 -0
- fyle/_readers/sqlite/__init__.py +8 -0
- fyle/_readers/sqlite/stdlib.py +366 -0
- fyle/_readers/text/__init__.py +7 -0
- fyle/_readers/text/stdlib.py +76 -0
- fyle/_readers/video/__init__.py +10 -0
- fyle/_readers/video/scenedetect.py +330 -0
- fyle/_readers/xlsx/__init__.py +6 -0
- fyle/_readers/xlsx/openpyxl.py +158 -0
- fyle/errors.py +42 -0
- fyle/sqlite.py +175 -0
- fylepy-0.1.0.dist-info/METADATA +272 -0
- fylepy-0.1.0.dist-info/RECORD +44 -0
- fylepy-0.1.0.dist-info/WHEEL +4 -0
- fylepy-0.1.0.dist-info/licenses/LICENSE +21 -0
fyle/sqlite.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""Read-only SQLite query helpers, intended for LLM tool-call use.
|
|
2
|
+
|
|
3
|
+
Why this module exists
|
|
4
|
+
----------------------
|
|
5
|
+
``fyle.open("x.sqlite")`` returns a ``Document`` that previews every table's
|
|
6
|
+
schema plus a handful of sample rows. That is the right default: it gives
|
|
7
|
+
an LLM enough context to understand the database in a single prompt.
|
|
8
|
+
|
|
9
|
+
It is **not** enough when the LLM actually needs to answer questions from
|
|
10
|
+
the data ("how many orders above $100 last month?"). For that scenario, an
|
|
11
|
+
agent framework wires up tool calls — one tool-call per SQL query — and
|
|
12
|
+
this module provides the three read-only primitives that cover the vast
|
|
13
|
+
majority of such cases:
|
|
14
|
+
|
|
15
|
+
- :func:`tables` — list user tables and views.
|
|
16
|
+
- :func:`schema` — describe the columns of a table or view.
|
|
17
|
+
- :func:`query` — run an arbitrary read-only SQL statement and format the
|
|
18
|
+
result as a Markdown pipe table.
|
|
19
|
+
|
|
20
|
+
Design rules
|
|
21
|
+
------------
|
|
22
|
+
- **Read-only**. The underlying connection is opened with
|
|
23
|
+
``mode=ro&immutable=1``, so ``INSERT`` / ``UPDATE`` / ``DELETE`` / DDL
|
|
24
|
+
statements raise ``sqlite3.OperationalError`` from SQLite itself. We do
|
|
25
|
+
not offer an ``execute`` counterpart: writes fall outside fyle's "open
|
|
26
|
+
anything, read everything" scope.
|
|
27
|
+
- **No row cap**. The caller (or the LLM's own ``LIMIT`` clause) decides
|
|
28
|
+
how much data to pull. Silent truncation would be a footgun — better to
|
|
29
|
+
let the caller see the real shape of their data.
|
|
30
|
+
- **No cell truncation**. Cell values are stringified verbatim; ``None``
|
|
31
|
+
becomes the literal string ``"NULL"`` to keep the rendered table
|
|
32
|
+
unambiguous.
|
|
33
|
+
- **Stateless API**. Every call opens and closes its own connection. There
|
|
34
|
+
is no session object to manage, which matches how LLM tools typically
|
|
35
|
+
invoke Python functions (fresh arguments per call).
|
|
36
|
+
|
|
37
|
+
Parameter binding uses SQLite's positional ``?`` placeholder, same as the
|
|
38
|
+
``sqlite3`` stdlib module.
|
|
39
|
+
"""
|
|
40
|
+
from __future__ import annotations
|
|
41
|
+
|
|
42
|
+
import sqlite3
|
|
43
|
+
from pathlib import Path
|
|
44
|
+
from typing import Optional, Union
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
__all__ = ["tables", "schema", "query"]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _connect(path: Union[str, Path]) -> sqlite3.Connection:
|
|
51
|
+
"""Open ``path`` as a read-only immutable SQLite connection.
|
|
52
|
+
|
|
53
|
+
``immutable=1`` promises the file will not change on disk and lets
|
|
54
|
+
SQLite skip lock acquisition, which matters when the same file is
|
|
55
|
+
concurrently opened by other processes.
|
|
56
|
+
"""
|
|
57
|
+
p = Path(path)
|
|
58
|
+
if not p.exists():
|
|
59
|
+
raise FileNotFoundError(f"SQLite file not found: {p}")
|
|
60
|
+
uri = f"file:{p}?mode=ro&immutable=1"
|
|
61
|
+
return sqlite3.connect(uri, uri=True)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _render_md_table(headers: list[str], rows: list[list[str]]) -> str:
|
|
65
|
+
"""Render an arbitrarily wide/long GFM pipe table.
|
|
66
|
+
|
|
67
|
+
Consistent with the rest of fyle's Markdown output so results can be
|
|
68
|
+
pasted straight back into an LLM prompt.
|
|
69
|
+
"""
|
|
70
|
+
if not headers:
|
|
71
|
+
return "(no columns)"
|
|
72
|
+
try:
|
|
73
|
+
from tabulate import tabulate as _tabulate
|
|
74
|
+
return _tabulate(rows, headers=headers, tablefmt="github")
|
|
75
|
+
except ImportError:
|
|
76
|
+
esc = lambda s: str(s).replace("|", "\\|")
|
|
77
|
+
out = ["| " + " | ".join(esc(h) for h in headers) + " |"]
|
|
78
|
+
out.append("|" + "|".join(["---"] * len(headers)) + "|")
|
|
79
|
+
for row in rows:
|
|
80
|
+
out.append("| " + " | ".join(esc(c) for c in row) + " |")
|
|
81
|
+
return "\n".join(out)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _stringify_row(row) -> list[str]:
|
|
85
|
+
"""Format a single DB row. ``None`` -> ``"NULL"``; no truncation."""
|
|
86
|
+
return ["NULL" if v is None else str(v) for v in row]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def tables(path: Union[str, Path]) -> list[str]:
|
|
90
|
+
"""Return every user table and view name, alphabetically.
|
|
91
|
+
|
|
92
|
+
System tables (``sqlite_master``, ``sqlite_sequence`` and friends —
|
|
93
|
+
anything prefixed with ``sqlite_``) are filtered out.
|
|
94
|
+
"""
|
|
95
|
+
conn = _connect(path)
|
|
96
|
+
try:
|
|
97
|
+
cur = conn.cursor()
|
|
98
|
+
cur.execute(
|
|
99
|
+
"SELECT name FROM sqlite_master "
|
|
100
|
+
"WHERE type IN ('table', 'view') "
|
|
101
|
+
"AND name NOT LIKE 'sqlite_%' "
|
|
102
|
+
"ORDER BY name"
|
|
103
|
+
)
|
|
104
|
+
return [r[0] for r in cur.fetchall()]
|
|
105
|
+
finally:
|
|
106
|
+
conn.close()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def schema(path: Union[str, Path], table: str) -> str:
|
|
110
|
+
"""Describe the columns of ``table`` as a Markdown pipe table.
|
|
111
|
+
|
|
112
|
+
Columns: ``column | type | nullable | default | pk``.
|
|
113
|
+
Raises ``ValueError`` if the table/view is unknown.
|
|
114
|
+
"""
|
|
115
|
+
conn = _connect(path)
|
|
116
|
+
try:
|
|
117
|
+
cur = conn.cursor()
|
|
118
|
+
cur.execute(f'PRAGMA table_info("{table}")')
|
|
119
|
+
rows = cur.fetchall()
|
|
120
|
+
if not rows:
|
|
121
|
+
raise ValueError(f"Unknown table or view: {table!r}")
|
|
122
|
+
headers = ["column", "type", "nullable", "default", "pk"]
|
|
123
|
+
body: list[list[str]] = []
|
|
124
|
+
for _cid, col_name, col_type, notnull, dflt, pk in rows:
|
|
125
|
+
body.append([
|
|
126
|
+
str(col_name),
|
|
127
|
+
str(col_type or ""),
|
|
128
|
+
"NO" if notnull else "YES",
|
|
129
|
+
"" if dflt is None else str(dflt),
|
|
130
|
+
str(pk) if pk else "",
|
|
131
|
+
])
|
|
132
|
+
return _render_md_table(headers, body)
|
|
133
|
+
finally:
|
|
134
|
+
conn.close()
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def query(
|
|
138
|
+
path: Union[str, Path],
|
|
139
|
+
sql: str,
|
|
140
|
+
params: Optional[list] = None,
|
|
141
|
+
) -> str:
|
|
142
|
+
"""Run a read-only SQL statement and return results as a Markdown table.
|
|
143
|
+
|
|
144
|
+
The connection is opened in read-only mode, so any write attempt (INSERT,
|
|
145
|
+
UPDATE, DELETE, DDL) raises ``sqlite3.OperationalError`` at execute time.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
path: Filesystem path to the SQLite database.
|
|
149
|
+
sql: SQL text. Use ``?`` placeholders for parameters.
|
|
150
|
+
params: Optional positional parameters for the ``?`` placeholders.
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
A Markdown pipe table including headers and every returned row, plus
|
|
154
|
+
a trailing ``(N rows)`` summary. For statements that return no column
|
|
155
|
+
set (e.g. ``PRAGMA`` variants that yield nothing), returns a short
|
|
156
|
+
informational string.
|
|
157
|
+
|
|
158
|
+
Deliberately does not:
|
|
159
|
+
- cap the returned row count (use ``LIMIT`` in your SQL);
|
|
160
|
+
- truncate long cell values.
|
|
161
|
+
"""
|
|
162
|
+
conn = _connect(path)
|
|
163
|
+
try:
|
|
164
|
+
cur = conn.cursor()
|
|
165
|
+
cur.execute(sql, params or [])
|
|
166
|
+
headers = [d[0] for d in (cur.description or [])]
|
|
167
|
+
rows_raw = cur.fetchall()
|
|
168
|
+
if not headers:
|
|
169
|
+
return f"(statement returned no columns; {len(rows_raw)} rows affected in read-only session)"
|
|
170
|
+
rows = [_stringify_row(r) for r in rows_raw]
|
|
171
|
+
table = _render_md_table(headers, rows)
|
|
172
|
+
suffix = f"\n\n({len(rows)} row{'s' if len(rows) != 1 else ''})"
|
|
173
|
+
return table + suffix
|
|
174
|
+
finally:
|
|
175
|
+
conn.close()
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fylepy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open anything, get clean Markdown for LLMs.
|
|
5
|
+
Project-URL: Homepage, https://github.com/zhixiangxue/fyle
|
|
6
|
+
Project-URL: Design, https://github.com/zhixiangxue/fyle/blob/main/design/02-fyle-sdk-design.md
|
|
7
|
+
Author: zhixiangxue
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 zhixiangxue
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: document,llm,markdown,parsing,pdf
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
39
|
+
Classifier: Topic :: Text Processing
|
|
40
|
+
Requires-Python: >=3.10
|
|
41
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
42
|
+
Requires-Dist: httpx>=0.27
|
|
43
|
+
Requires-Dist: lxml>=5
|
|
44
|
+
Requires-Dist: mammoth>=1.8
|
|
45
|
+
Requires-Dist: markdown-it-py>=3
|
|
46
|
+
Requires-Dist: markdownify>=0.11
|
|
47
|
+
Requires-Dist: openpyxl>=3.1
|
|
48
|
+
Requires-Dist: pdfplumber>=0.11
|
|
49
|
+
Requires-Dist: pillow>=10
|
|
50
|
+
Requires-Dist: pydantic>=2
|
|
51
|
+
Requires-Dist: pymupdf4llm>=0.0.17
|
|
52
|
+
Requires-Dist: pymupdf>=1.24
|
|
53
|
+
Requires-Dist: pypdf>=4
|
|
54
|
+
Requires-Dist: python-docx>=1.1
|
|
55
|
+
Requires-Dist: python-magic>=0.4
|
|
56
|
+
Requires-Dist: python-pptx>=0.6
|
|
57
|
+
Requires-Dist: tabulate>=0.9
|
|
58
|
+
Requires-Dist: tiktoken>=0.7
|
|
59
|
+
Provides-Extra: audio
|
|
60
|
+
Requires-Dist: faster-whisper>=1.0; extra == 'audio'
|
|
61
|
+
Provides-Extra: av
|
|
62
|
+
Requires-Dist: av>=12; extra == 'av'
|
|
63
|
+
Requires-Dist: faster-whisper>=1.0; extra == 'av'
|
|
64
|
+
Requires-Dist: scenedetect[pyav]>=0.6; extra == 'av'
|
|
65
|
+
Provides-Extra: dev
|
|
66
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
67
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
68
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
69
|
+
Provides-Extra: video
|
|
70
|
+
Requires-Dist: av>=12; extra == 'video'
|
|
71
|
+
Requires-Dist: faster-whisper>=1.0; extra == 'video'
|
|
72
|
+
Requires-Dist: scenedetect[pyav]>=0.6; extra == 'video'
|
|
73
|
+
Description-Content-Type: text/markdown
|
|
74
|
+
|
|
75
|
+
<div align="center">
|
|
76
|
+
|
|
77
|
+
<img src="https://raw.githubusercontent.com/zhixiangxue/fyle/main/docs/assets/logo.png" alt="fyle" width="120">
|
|
78
|
+
|
|
79
|
+
[](https://pypi.org/project/fylepy/)
|
|
80
|
+
[](https://pypi.org/project/fylepy/)
|
|
81
|
+
[](LICENSE)
|
|
82
|
+
[](https://pypi.org/project/fylepy/)
|
|
83
|
+
|
|
84
|
+
**Any file in. Clean Markdown out. LLM ready.**
|
|
85
|
+
|
|
86
|
+
A lightweight library that turns PDF, DOCX, XLSX, audio, video, and ~100 more formats into the Markdown your LLM already understands.
|
|
87
|
+
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## What is this?
|
|
93
|
+
|
|
94
|
+
A lightweight library for reading files. What makes it different: the output is **LLM-ready** — clean Markdown you can feed straight into any model, no post-processing, no cleanup.
|
|
95
|
+
|
|
96
|
+
**One line. Every common file. LLM-ready Markdown.** Point fyle at a path, URL, or raw bytes — what comes back is already something a model can read natively. No OCR plumbing, no format-specific parser glue, no prompt engineering to "please strip the headers and footers".
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import fyle
|
|
100
|
+
|
|
101
|
+
text = fyle.read("report.pdf") # or .docx / .xlsx / .mp3 / .mp4 / an http(s) URL / raw bytes
|
|
102
|
+
llm.complete(text) # that's it.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Works out of the box on:
|
|
106
|
+
|
|
107
|
+
- **PDF / DOCX / XLSX / PPTX / HTML / Markdown / CSV** — parsed into Markdown
|
|
108
|
+
- **Images** — base64 `data:image/...` URLs ready for multimodal models
|
|
109
|
+
- **Audio / video** — local ASR transcripts with `[MM:SS]` timestamps (+ keyframes for video)
|
|
110
|
+
- **SQLite** — schema preview + fluent `doc.table(t).query(sql)` API
|
|
111
|
+
- **Archive** — safe extraction + Markdown manifest, agent decides what to open next
|
|
112
|
+
- **~100 source / config / log formats** — passthrough as plain text
|
|
113
|
+
|
|
114
|
+
> 100% local. No cloud APIs. No telemetry. No API keys.
|
|
115
|
+
> Just `fyle.open(...)` and the file becomes something an LLM can see.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Install
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pip install fylepy
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Audio / video transcription are opt-in extras (native wheels + a ~140 MB model on first run):
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pip install 'fylepy[audio]' # faster-whisper
|
|
129
|
+
pip install 'fylepy[video]' # faster-whisper + PySceneDetect + PyAV
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Quick start
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
import fyle
|
|
138
|
+
|
|
139
|
+
doc = fyle.open("report.pdf")
|
|
140
|
+
# or: fyle.open("https://example.com/report.pdf")
|
|
141
|
+
# or: fyle.open(raw_bytes) # format auto-detected from magic bytes
|
|
142
|
+
|
|
143
|
+
# Three views of the same document:
|
|
144
|
+
print(doc.text) # pure content — whatever the reader produced
|
|
145
|
+
print(str(doc)) # LLM-ready: filename + format + size header, then content
|
|
146
|
+
print(repr(doc)) # short debug line for logs
|
|
147
|
+
|
|
148
|
+
# Typical usage — hand the whole thing to your model in one line:
|
|
149
|
+
llm.complete(str(doc)) # filename carries real signal the model can use
|
|
150
|
+
|
|
151
|
+
print(doc.meta.format) # "pdf"
|
|
152
|
+
print(doc.meta.ext) # "pdf"
|
|
153
|
+
print(doc.pages[0].text) # just page 1
|
|
154
|
+
|
|
155
|
+
# One-shot convenience: str in, LLM-ready string out (same as str(fyle.open(...)))
|
|
156
|
+
text = fyle.read("report.pdf")
|
|
157
|
+
|
|
158
|
+
# Check which readers are available in your install
|
|
159
|
+
fyle.readers()
|
|
160
|
+
# {"pdf": ["pymupdf4llm*"], "audio": ["faster-whisper*"], ...}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Supported formats
|
|
166
|
+
|
|
167
|
+
| Family | Extensions | Reader |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| PDF | `.pdf` | pymupdf4llm |
|
|
170
|
+
| Word | `.docx` | mammoth |
|
|
171
|
+
| Excel | `.xlsx` | openpyxl + tabulate |
|
|
172
|
+
| PowerPoint | `.pptx` | python-pptx |
|
|
173
|
+
| Web | `.html` `.htm` | markdownify |
|
|
174
|
+
| Markdown | `.md` `.markdown` | markdown-it-py |
|
|
175
|
+
| CSV | `.csv` | stdlib + tabulate |
|
|
176
|
+
| Image | `.png` `.jpg` `.jpeg` `.webp` | Pillow → base64 data URL |
|
|
177
|
+
| Audio | `.mp3` `.m4a` `.wav` `.flac` `.ogg` | faster-whisper (CPU, int8) |
|
|
178
|
+
| Video | `.mp4` `.m4v` `.mov` `.avi` `.mkv` `.webm` | PySceneDetect + Whisper |
|
|
179
|
+
| Database | `.db` `.sqlite` `.sqlite3` | stdlib + fluent SQL API |
|
|
180
|
+
| Archive | `.zip` `.tar` `.gz` `.bz2` `.xz` ... | stdlib — extract to disk + manifest |
|
|
181
|
+
| Text | `.py` `.js` `.go` `.rs` `.java` `.json` `.yaml` `.toml` `.sql` `.log` ... (~100) | passthrough |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Audio & video
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
doc = fyle.open("meeting.mp4")
|
|
189
|
+
|
|
190
|
+
print(doc.text)
|
|
191
|
+
# # Video: meeting.mp4
|
|
192
|
+
#
|
|
193
|
+
# - Duration: `12:34`
|
|
194
|
+
# - Keyframes: 8
|
|
195
|
+
# - Language: `en`
|
|
196
|
+
#
|
|
197
|
+
# ## Transcript
|
|
198
|
+
#
|
|
199
|
+
# [00:00] Welcome everyone to the quarterly review...
|
|
200
|
+
|
|
201
|
+
for img in doc.images:
|
|
202
|
+
print(img.caption, img.src[:32])
|
|
203
|
+
# "02:17" "data:image/jpeg;base64,/9j/4AA..."
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
First call downloads the Whisper `base` model (~140 MB). CPU only — no GPU needed.
|
|
207
|
+
Override with `FYLE_WHISPER_MODEL=small` (or `medium` / `large-v3`) for higher quality.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## SQLite
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
doc = fyle.open("chinook.db")
|
|
215
|
+
|
|
216
|
+
for page in doc.pages:
|
|
217
|
+
print(page.name) # table or view name
|
|
218
|
+
print(page.text) # schema + sample rows
|
|
219
|
+
|
|
220
|
+
rows = doc.table("Customer").query(
|
|
221
|
+
"SELECT Country, COUNT(*) AS n FROM Customer GROUP BY Country ORDER BY n DESC"
|
|
222
|
+
)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Archive
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
doc = fyle.open("~/Downloads/invoices.zip")
|
|
231
|
+
|
|
232
|
+
print(doc.text) # Markdown listing of extracted files
|
|
233
|
+
print(doc.meta.warnings) # ["extracted to: /.../invoices/"]
|
|
234
|
+
|
|
235
|
+
# Agent's next step: fyle.open(one of the extracted files)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Refuses `..` path traversal and symlink escapes; extracts to the archive's sibling directory.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Chunking for RAG
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
for chunk in doc.chunks(max_tokens=4000, overlap=200):
|
|
246
|
+
embed(chunk.text)
|
|
247
|
+
# chunk.tokens / chunk.page_range also available
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Notes
|
|
253
|
+
|
|
254
|
+
1. **Offline only.** Every reader runs locally. The audio/video reader downloads the Whisper model from Hugging Face on first run; after that, no network.
|
|
255
|
+
2. **Archive reader is list-only.** It extracts files to disk and returns a manifest — it does not recursively parse contents. The agent decides what to open next.
|
|
256
|
+
3. **Alpha.** Core is stable, but APIs may move between `0.x` releases.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Feedback
|
|
261
|
+
|
|
262
|
+
Issues, PRs, and stars are welcome.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
MIT © 2026 zhixiangxue
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
<div align="right"><img src="https://raw.githubusercontent.com/zhixiangxue/fyle/main/docs/assets/logo.png" alt="fyle" width="120"></div>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
fyle/__init__.py,sha256=BmjgtIvpluuVxo8hvN5r_KSJvo_eyTnsb1bSwU8fq2s,1336
|
|
2
|
+
fyle/errors.py,sha256=Qlv7wUTPRcru7YVTgKTWYoOdhjGJxhanIsrKwHmjkXk,1351
|
|
3
|
+
fyle/sqlite.py,sha256=QaQk8CgweibK-o12r8P5lRJ5MqRpC2iXWCUo1evZSsQ,6563
|
|
4
|
+
fyle/_core/__init__.py,sha256=PhmiugULygH5MORvldX6_FaSRfP0iHx5OXhBALiQJWA,229
|
|
5
|
+
fyle/_core/api.py,sha256=PcMuYaVyumEJYJLt2BcswKNNUP_y_szPUT92DLAdjXA,6680
|
|
6
|
+
fyle/_core/chunking.py,sha256=5gdSnaYlbePYhk2eeI0a3dA2Y8l56nysNbAuIgl6Krk,3702
|
|
7
|
+
fyle/_core/document.py,sha256=F3q82PjBJI03hafnXN7u1FCRh3bW5iQx2EDGnZRAkxM,13064
|
|
8
|
+
fyle/_core/fetcher.py,sha256=KkaZrP25GQnhJejnfTAuVDAbYL7ozNRShouqy7WvtiE,2199
|
|
9
|
+
fyle/_core/registry.py,sha256=eSAb7JdFjwGDrm-qhvSf3sITwL2hze1m92VL3PeU-oc,3791
|
|
10
|
+
fyle/_core/sniffer.py,sha256=Um9aFPcwJtCSy4KgiUrHDV9nAZ9Vry4oCHke1V9i9cc,8753
|
|
11
|
+
fyle/_readers/__init__.py,sha256=6fTqEZfoW0keXnxvRhe8Lv0a7rncAAM1XLTha_yflRY,1525
|
|
12
|
+
fyle/_readers/_md_structure.py,sha256=ompMx5GtAPgbn7UsBSw50KaK0QGXH08kbpnUWCnQ3EY,7076
|
|
13
|
+
fyle/_readers/_whisper.py,sha256=92wTVAhOzccHafJ-HEIFSCL3w9EHyUS9_ooySsKU2sE,4955
|
|
14
|
+
fyle/_readers/base.py,sha256=EzJ4UYLvVSoOx7fLE1wawyd1xMFX8LCE_xO2bvWuPRE,2680
|
|
15
|
+
fyle/_readers/archive/__init__.py,sha256=VUlCsTf7rEOPG-D-_P-gTHp_2By093mBNx2nnJ5GKvc,267
|
|
16
|
+
fyle/_readers/archive/stdlib.py,sha256=YrNEzzpzZ1KwOCAeiAUyaOEKqOaIfdYyKoHbIimV2-8,16778
|
|
17
|
+
fyle/_readers/audio/__init__.py,sha256=HtDqNVkHBnPYLyRgNeFKMI0ymnX6oZH07IWdMPloH4M,329
|
|
18
|
+
fyle/_readers/audio/faster_whisper.py,sha256=qQHkAW2a7EVod2hGLos_sMO0Il9A9zhjbp5-rd-0CkM,5425
|
|
19
|
+
fyle/_readers/csv/__init__.py,sha256=OXFtKAWXeK94P_MiNV5bd9kjnJZN5ZvxdqKE81ejyO8,260
|
|
20
|
+
fyle/_readers/csv/stdlib.py,sha256=UFXOIZXRCUt0dzhnzcPsJPoXGzhpvxi8qhsc-a6xLVQ,4517
|
|
21
|
+
fyle/_readers/docx/__init__.py,sha256=xnaJ6-4TmVUryfLxaTY3Kx9xXqwHshmRFVgOhvrnpAs,273
|
|
22
|
+
fyle/_readers/docx/mammoth.py,sha256=yoAP8RZ3dOgsGc44yeryaFZO2x-BW6uiK2ZyYVusiwg,5220
|
|
23
|
+
fyle/_readers/html/__init__.py,sha256=cM2GTFO21VycTnAJi7OvauaDJn2-SygCClsWV0upPEA,275
|
|
24
|
+
fyle/_readers/html/markdownify.py,sha256=TqIeWpSqe3KiDPRAt85POzbHzDlBrRvq-w0zMCKteY4,4453
|
|
25
|
+
fyle/_readers/image/__init__.py,sha256=Apa-ZqS-TVi68MtL3OE1ZGPd-nkwR903pVCIbVQf-Lg,780
|
|
26
|
+
fyle/_readers/image/stdlib.py,sha256=wyjAGEH2iaTXjzFgDk48cEw2Ou-tQPDywm3V4T7kQdk,4676
|
|
27
|
+
fyle/_readers/markdown/__init__.py,sha256=Z-HuK69ZoDUou8I0wRzQQBm0kaiPjnN655CheamKFjU,249
|
|
28
|
+
fyle/_readers/markdown/stdlib.py,sha256=uAO1U5FkakJom5HCH8k6LAvnqtiRaYvVXSApC90fuVw,2264
|
|
29
|
+
fyle/_readers/pdf/__init__.py,sha256=sToR8bYtf3vkz--aN3utgadVco_an8FopU9ilcYESqA,131
|
|
30
|
+
fyle/_readers/pdf/pymupdf4llm.py,sha256=d8GrNoKSdyk-4xpW9ZAnqkVBsUlWxLsscmw403IuMJs,7212
|
|
31
|
+
fyle/_readers/pptx/__init__.py,sha256=5Sh9vFI4krOM9c__grjSWaUmjVs-TGvVJi95NF_WHE0,174
|
|
32
|
+
fyle/_readers/pptx/python_pptx.py,sha256=hMayGCA3juccTIqz84-VtEIKya3Ycz-atE_r_sbB0Tg,10469
|
|
33
|
+
fyle/_readers/sqlite/__init__.py,sha256=fvpF3ZivVS9QfbjECQ026yiJw7z2X0MMHZ-gg8cl0tE,187
|
|
34
|
+
fyle/_readers/sqlite/stdlib.py,sha256=wH4ijSRuo7AHO8o8OhFHB9yNSO-2xAdPD9sCqyyn3Ag,13095
|
|
35
|
+
fyle/_readers/text/__init__.py,sha256=bmPZs5VBgNXmBW0uOhByFBGdCNcNKS5CQ8mzuj3s8R0,322
|
|
36
|
+
fyle/_readers/text/stdlib.py,sha256=3KEDF-TWOyDlN88I1_fWoyzhB-Somy_LUbNqrfsVB7U,2796
|
|
37
|
+
fyle/_readers/video/__init__.py,sha256=YV2vNjydOUYiLkQoY6HsVrLgEVZFOD_KYbwFY_8-eXU,365
|
|
38
|
+
fyle/_readers/video/scenedetect.py,sha256=rXYCVmQXeLrNfy711kQQ7lU4ulpOWdpVIGJg1bA_1ag,11057
|
|
39
|
+
fyle/_readers/xlsx/__init__.py,sha256=aqyPaMrrScVYzFTEcsWuSs83Lw9IAvzIM4Dy8jy61xo,259
|
|
40
|
+
fyle/_readers/xlsx/openpyxl.py,sha256=bcYsN-h6Sl9OCPEuAKHyymAM1dkTU7KTe_NbxuRrd6o,5576
|
|
41
|
+
fylepy-0.1.0.dist-info/METADATA,sha256=AFnsVAT3NenYu-loDldA8OnMvJtc-xDbO_UoPPWjdY4,9237
|
|
42
|
+
fylepy-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
43
|
+
fylepy-0.1.0.dist-info/licenses/LICENSE,sha256=BZb7GIBeVw6V5V3h8frLtfczjyBTnRiUqJp47ayDWRc,1068
|
|
44
|
+
fylepy-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zhixiangxue
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|