Skip to content

Commit 4a195e3

Browse files
committed
add image uploader and update README
1 parent 907cd14 commit 4a195e3

File tree

7 files changed

+489
-4
lines changed

7 files changed

+489
-4
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ LoFS 聚焦“本地优先”的知识管理场景,将文件管理与语义检
2020
- 🔍 **多模态处理**:自动解析 `.md``.txt``.docx``.pdf``.pptx``.json` 等文本与图像内容。
2121
- 📁 **文件树交互**:支持一键挂载/卸载、PDF 专属解析、进度实时可视化。
2222
- 🧠 **主题驱动检索**:在传统 Faiss/BM25s/reranker 之上引入“文档主题摘要 + 语义/词法加权”的两阶段检索,问题可先与摘要匹配再回退全文。
23+
- 🤖 **多平台模型接入**:内置 SiliconFlow,并新增对 ModelScope、通义千问(DashScope)的兼容,支持在线连通性检测、流式问答与 `<think>` 思考返回。
24+
- 💬 **智能聊天体验**:聊天页记住上次选用的模型,重启后即刻恢复;模型输出的思考内容会以灰色卡片独立展示,方便分析与引用。
2325
- 🔒 **本地优先**:所有文件、向量与索引均保存在本地 SQLite 与 Faiss 中,核心数据不出域。
2426
- 🛠️ **开箱即用**:Electron 桌面端 + FastAPI 后端,兼容多系统打包。
2527

@@ -31,6 +33,7 @@ LoFS 聚焦“本地优先”的知识管理场景,将文件管理与语义检
3133
- **桌面端(Electron)**:负责文件树、解析状态、检索结果的交互体验。
3234
- **后端(FastAPI)**:承载挂载、解析、索引构建等核心任务,提供 REST API。
3335
- **检索引擎**:通过 Faiss、BM25s 与 FlagEmbedding(BGE 系列)构成的混合检索流水线,支持文本与图像向量,并内置主题摘要检索通路。
36+
- **模型管理**:前端提供模型库视图,可添加自定义模型并测试连通性;支持 SiliconFlow、ModelScope 与通义千问(DashScope)三大平台。
3437
- **数据存储**:SQLite 保存结构化元数据,Faiss 保存向量索引,本地文件系统管理模型与缓存。
3538

3639
```text
@@ -51,6 +54,7 @@ LoFS 聚焦“本地优先”的知识管理场景,将文件管理与语义检
5154
3. 🧮 **索引构建**:将文本向量写入 Faiss,将关键词倒排写入 BM25s,元数据落盘至 SQLite。
5255
4. 🧾 **生成主题摘要**(可选):启用“文档总结”后,调用指定模型为整篇文档生成主题概述,并写入独立向量与 SQLite。
5356
5. 🔎 **分层检索**:输入查询后先与主题摘要做语义/词法混合匹配(分数 ≥ 0.7 即入选),命中文档的完整内容 + 摘要会一并注入提示词;若无命中则自动回退至传统混合检索。
57+
6. 💬 **LLM 问答**:选择任一已配置的模型即可发起流式对话;若模型支持思考输出(ModelScope、DashScope),LoFS 会将 `<think>` 内的内容转成灰色卡片单独展示。
5458

5559
模型目录按需懒加载,首次使用对应能力时自动下载;也可以提前拉取以免首轮等待:
5660

@@ -64,6 +68,14 @@ LoFS 聚焦“本地优先”的知识管理场景,将文件管理与语义检
6468
python -c "from service.model_manager import get_model_manager; manager = get_model_manager(); [manager.get_model_path(key) for key in ('bge_m3', 'bge_reranker_v2_m3', 'clip_vit_b_32', 'clip_vit_b_32_multilingual', 'pdf_extract_kit')]"
6569
```
6670

71+
### 3.2 多平台模型接入
72+
-**设置 → API Key** 中填写对应凭证:
73+
- SiliconFlow:`siliconflwApiKey`
74+
- ModelScope:`modelscopeApiKey`
75+
- 通义千问(DashScope):`qwenApiKey`
76+
- 进入 **模型库 → 添加模型**,选择平台即可测试连通性;失败时会返回接口错误信息辅助排查。
77+
- 聊天页面的模型下拉会记住上次选择,重启后自动恢复;支持流式输出,若模型返回 `<think>` 思考段落会以灰色卡片单独展示(默认适用于 ModelScope、DashScope)。
78+
6779
## 4. 部署使用
6880
### 4.1 环境要求
6981
| 组件 | 最低版本 | 推荐 |

README_EN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ LoFS fuses local file organization with semantic retrieval to deliver an “alwa
2020
- 🔍 **Multimodal ingestion**: parses `.md`, `.txt`, `.docx`, `.pdf`, `.pptx`, `.json`, and extracts both text and images.
2121
- 📁 **Explorer-style UX**: mount/remount flows, PDF-only parsing, and live progress indicators keep operations transparent.
2222
- 🧠 **Theme-driven retrieval**: augments the Faiss/BM25s/reranker stack with document-level summaries plus semantic/lexical blending so questions land on the right topic before falling back to full-text recall.
23+
- 🤖 **Multi-provider LLM support**: built-in adapters for SiliconFlow, ModelScope, and Alibaba DashScope (Qwen) let you plug in your favorite service, validate connectivity, and use streaming responses with `<think>` reasoning blocks.
24+
- 💬 **Chat experience upgrades**: the chat view remembers your last-selected model across restarts, and thinking traces render as dedicated gray cards for easier auditing.
2325
- 🔒 **Local-first by design**: SQLite and Faiss stay on disk, ensuring data never leaves your machine.
2426
- 🛠️ **Shipping-ready app**: Electron desktop shell plus FastAPI backend, complete with cross-platform packaging scripts.
2527

@@ -31,6 +33,7 @@ LoFS fuses local file organization with semantic retrieval to deliver an “alwa
3133
- **Electron desktop**: renders the file tree, orchestration panels, and search UI.
3234
- **FastAPI backend**: exposes REST endpoints for mounting, parsing, indexing, and retrieval orchestration.
3335
- **Retrieval pipeline**: Faiss + BM25s + FlagEmbedding (BGE family) power fast semantic/keyword blending, now enhanced with summary vectors for topic-first search, plus CLIP embeddings for images.
36+
- **Model management**: the desktop UI exposes a model library so you can add custom endpoints, run health checks, and manage keys for SiliconFlow, ModelScope, and DashScope in one place.
3437
- **Storage layer**: SQLite for metadata, Faiss for vector indices, and the local filesystem for model caches.
3538

3639
```text
@@ -51,6 +54,7 @@ LoFS fuses local file organization with semantic retrieval to deliver an “alwa
5154
3. 🧮 **Index build**: persist embeddings to Faiss, keyword metadata to BM25s, and structured info to SQLite.
5255
4. 🧾 **Topic summaries (optional)**: when the “Document Theme Summary” setting is on, a chosen LLM produces per-document abstracts that are stored in SQLite and embedded separately.
5356
5. 🔎 **Layered retrieval**: each query first matches against the summary vectors with a semantic (0.6) + lexical (0.4) score fusion; summaries scoring ≥ 0.7 bring their full document chunks and the summary into the LLM prompt. If nothing passes the threshold, the pipeline transparently falls back to classic hybrid retrieval.
57+
6. 💬 **Conversational hand-off**: when a model is selected in the chat panel, LoFS streams replies (including `<think>` reasoning for ModelScope/DashScope) and caches the selection so it’s restored on the next launch.
5458

5559
Model assets download lazily the first time a capability is invoked. Prefetch them to warm the cache:
5660

@@ -64,6 +68,11 @@ python -c "from service.model_manager import get_model_manager; manager = get_mo
6468
- 🔁 **Graceful fallback**: if no summary clears the threshold, LoFS automatically reverts to the standard hybrid pipeline; matched responses surface a “Reference Theme” card for transparency.
6569
- 🧩 **Prompt enrichment**: selected documents contribute both the full chunk set and their summaries to the LLM context, helping the assistant stay on-topic and cite accurately.
6670

71+
### 3.2 Multi-provider LLM integration
72+
- Configure API keys under **Settings → API Key** (`siliconflwApiKey`, `modelscopeApiKey`, `qwenApiKey`).
73+
- Use the **Model Library** to add endpoints and run connectivity tests; failures return verbose error payloads for troubleshooting.
74+
- During chat, the dropdown retains your last pick even after restarts. Models that emit `<think>` blocks (ModelScope/DashScope) render their reasoning in a separate, gray “Thinking” panel ahead of the final answer.
75+
6776
## 4. Deployment & Usage
6877
### 4.1 Requirements
6978
| Component | Minimum | Recommended |

electron/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,19 @@ <h1 class="splash-title">LoFS</h1>
277277
</div>
278278
<div id="chat-input-area">
279279
<div id="chat-status-text"></div>
280+
<div id="chat-image-preview" class="chat-image-preview" hidden>
281+
<div id="chat-image-preview-list" class="chat-image-preview-list"></div>
282+
</div>
280283
<div class="chat-input-wrapper">
284+
<button id="chat-upload-btn" class="chat-upload-btn" type="button" aria-label="上传图片">
285+
<svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
286+
<path d="M4 7h16v12H4z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" fill="none" />
287+
<path d="M4 16l3.5-3.5a2 2 0 0 1 2.9 0L16 18" stroke="currentColor" stroke-width="1.5"
288+
stroke-linecap="round" stroke-linejoin="round" fill="none" />
289+
<circle cx="15.5" cy="11" r="1.75" fill="currentColor" />
290+
</svg>
291+
</button>
292+
<input id="chat-upload-input" type="file" accept="image/*" multiple aria-hidden="true">
281293
<textarea id="chat-input" rows="1" placeholder="询问任何问题" autocomplete="off" spellcheck="false"></textarea>
282294
<button id="chat-send-btn" type="button" aria-label="发送消息">
283295
<svg class="icon-arrow" width="18" height="18" viewBox="0 0 24 24" aria-hidden="true" focusable="false">

electron/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "LoFS",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"description": "LoFS (Load once Fast Search) is a desktop-first knowledge base manager for local files. Mount a directory once and enjoy millisecond hybrid search afterwards.",
55
"main": "main.js",
66
"scripts": {

0 commit comments

Comments
 (0)