Metadata-Version: 2.4
Name: easycat
Version: 0.0.7
Summary: 知识库系统：文档解析、全文与向量检索、多智能体问答，支持多工作空间隔离
Author-email: Joe <joe@example.com>
License-Expression: LicenseRef-Proprietary
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Healthcare Industry
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: Flask>=3.0.0
Requires-Dist: bcrypt>=4.0.0
Requires-Dist: cryptography>=42.0.0
Requires-Dist: zvec>=0.5.0
Requires-Dist: markitdown>=0.1.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: html2text>=2024.1.0
Requires-Dist: json-repair>=0.28.0
Requires-Dist: python-docx>=1.0.0
Requires-Dist: doc2txt>=1.0.6
Requires-Dist: markdown>=3.5
Requires-Dist: beautifulsoup4>=4.12
Requires-Dist: numpy>=1.23
Requires-Dist: sentence-transformers>=3.0.0
Requires-Dist: modelscope>=1.15.0
Requires-Dist: pypdfium2>=4.0.0
Requires-Dist: pdfplumber>=0.11.0
Requires-Dist: Pillow>=10.0.0
Requires-Dist: PyYAML>=6.0
Provides-Extra: browser
Requires-Dist: playwright>=1.40.0; extra == "browser"
Requires-Dist: pyperclip>=1.8.0; extra == "browser"
Provides-Extra: production
Requires-Dist: waitress>=2.1.0; extra == "production"
Provides-Extra: pdf-ocr-light
Requires-Dist: rapidocr-onnxruntime>=1.3.0; extra == "pdf-ocr-light"
Requires-Dist: onnxruntime>=1.16.0; extra == "pdf-ocr-light"
Provides-Extra: pdf-ocr-paddle
Requires-Dist: paddlepaddle>=2.6.0; extra == "pdf-ocr-paddle"
Requires-Dist: paddleocr>=2.7.0; extra == "pdf-ocr-paddle"
Dynamic: license-file

# 智析数据 · 知识库

本机部署的知识库系统。按工作空间隔离存放法规、指南与技术文档，提供全文检索、向量检索与
多智能体问答，并对账户、权限与审计日志进行管理。文档、索引与对话记录均保存在本机，
检索与向量化在本机完成，不依赖外部服务。

本页为双语：中文说明在前，英文说明自「Zhixi Knowledge Base」一节起。

## 概述

| 页面 | 职责 |
| --- | --- |
| 知识库 | 目录与文档的组织、上传、解析与维护 |
| 检索 | 全文检索与向量检索，可按工作空间与文档范围限定 |
| 问答 | 普通模式（检索直答）与智能体模式（任务拆解后多轮查阅） |
| 知识图谱 | 文档间的关联展示 |
| PDF 工坊 | PDF 解析、扫描件识别与导出 Word |
| 用户与令牌 | 账户、角色、工作空间授权与开放接口令牌 |
| 审计日志 | 登录、上传、检索与配置变更的记录 |
| 模型配置 | 模型接口、检索参数与向量索引的维护 |

## 运行环境

- Python 3.8 及以上。安装包为 Windows x64 预编译二进制包（`cp38-abi3-win_amd64`），
  安装时无需编译环境，适用于 64 位 CPython 3.8 及以上版本。不支持 32 位与 ARM 平台。
- 端口 26804 需处于空闲状态。
- 默认监听 `0.0.0.0`，同一网段的其他主机可访问；仅本机使用时将 `EASYCAT_HOST` 设为 `127.0.0.1`。
- 首次启动会加载本地的向量嵌入模型。模型文件在首次使用时下载，需要一定的磁盘空间与等待时间；
  下载完成后离线可用。
- 单个上传文件不超过 100 MB，可用 `EASYCAT_MAX_UPLOAD_MB` 调整。

## 安装

```bash
pip install easycat
```

安装完成后提供 `easycat` 命令行入口，同时可用 `python -m easycat` 启动；
模块导入名称为 `easycat`。

以下组件按需安装，不影响基础功能：

| 组件 | 用途 |
| --- | --- |
| `easycat[browser]` | 网页抓取所需的无头浏览器与剪贴板组件 |
| `easycat[production]` | 以 waitress 替代 Flask 内置服务器，多人同时访问时建议安装 |
| `easycat[pdf-ocr-light]` | 扫描件识别（ONNX 版 RapidOCR，纯 CPU，体积较小） |
| `easycat[pdf-ocr-paddle]` | 扫描件识别（PP-OCRv5，含版面、表格与公式，识别质量较好，体积较大） |

## 启动

```bash
easycat                 # 启动服务，默认 http://127.0.0.1:26804
```

| 变量 | 默认值 | 说明 |
| --- | --- | --- |
| `EASYCAT_PORT` | `26804` | 服务端口 |
| `EASYCAT_HOST` | `0.0.0.0` | 监听地址 |
| `EASYCAT_HOME` | `C:\Users\<用户名>\easycat` | 数据根目录 |
| `EASYCAT_PRODUCTION` | `false` | 设为 `true` 时使用 waitress |
| `EASYCAT_THREADS` | `8` | waitress 线程数 |
| `EASYCAT_MAX_UPLOAD_MB` | `100` | 单文件上传上限 |
| `EASYCAT_DEFAULT_PASSWORD` | 空 | 指定首次登录口令，未设置时使用默认口令 |

## 初始账户

首次启动自动创建管理员账户 `admin`，默认口令 `easy123`。使用默认口令登录后须修改口令，
否则无法继续使用；通过 `EASYCAT_DEFAULT_PASSWORD` 指定的口令不强制修改。

## 功能

### 工作空间

每个工作空间拥有独立的数据库与文档目录，彼此不共享内容与索引。适用于按项目、按产品线或
按客户划分知识范围，也便于单独备份与迁移。

### 文档接入

支持 `.doc`、`.docx`、`.txt`、`.md`、`.markdown`、`.xls`、`.xlsx`、`.csv`、`.ppt`、`.pptx`
与 `.pdf`。Office 与表格文件经 markitdown 提取并保留表格结构；带文本层的 PDF 由版面引擎解析，
可识别分栏、表格与标题；扫描件与混合型 PDF 由 OCR 组件处理，需另行安装。

文档按章节切分并建立索引，原文与索引均可重建。

### 检索

提供全文检索；启用向量检索后，按语义相似度召回并按相关度重排。嵌入与重排模型在本机运行，
不调用外部接口。向量索引在模型更换或文档大量变更后需重建，「模型配置」页提供重建入口。

### 问答

普通模式直接以检索结果作答，响应较快，适合事实性提问与短语追问。智能体模式先拆解问题，
再分派子任务并行查阅多个文档，最后汇总作答，适合跨文档、需要比对的提问。两种模式均支持
流式输出并标注引用来源。

### 权限与审计

账户分为管理员与普通用户。管理员可创建工作空间、分配可读或可写的范围、管理账户与令牌。
登录、上传、删除、检索与配置变更均记入审计日志，可按账户与时间范围查询。

### 开放接口

「API 令牌」页可创建访问令牌，用于以 HTTP 方式调用检索与问答接口，便于与其他系统集成。
令牌可设置有效期并随时吊销。

### PDF 工坊

提供 PDF 版面解析、扫描件识别与导出 Word。解析结果可保留标题层级与表格，导出为可编辑的
`.docx`。对话内容同样可导出为 Word 文档。

## 数据目录

所有可写内容存放于用户主目录下的 `easycat` 文件夹（`C:\Users\<用户名>\easycat`），
分为 data、models、cache、tmp、logs、backups 六个子目录。其中 data 为数据库、设置与各工作空间的
文档内容，是备份的主要对象。卸载、重装与升级均不修改该目录；升级前的自动快照存放于 backups。

迁移至其他主机时，将其复制到目标主机的相同位置即可，工作空间、账户与索引设置随之保留。
可用 `EASYCAT_HOME` 指定其他位置。

## 授权

本软件为专有软件，按组件、机器码与失效日期授权，一机一码。首次运行自动签发 90 天试用授权，
试用期内功能不受限制。授权到期后，在「授权信息」页面粘贴新的授权码即可生效。

更换主机、更换系统盘或重装操作系统将导致机器码变更，需重新申请授权。建议在到期前完成更新。

许可条款随安装包分发（`LICENSE.txt`）。不同意条款者请勿安装。

## 联系方式

授权申请、续期与问题反馈：857914532@qq.com

---

# Zhixi Knowledge Base

A locally deployed knowledge base. Documents such as regulations, guidelines and technical
manuals are stored in isolated workspaces, with full-text and vector retrieval, multi-agent
question answering, and management of accounts, permissions and audit logs. Documents, indexes
and conversations remain on the local machine; retrieval and embedding run locally without
external services.

## Overview

| Page | Responsibility |
| --- | --- |
| Knowledge base | Organisation, upload, parsing and maintenance of folders and documents |
| Search | Full-text and vector retrieval, scoped by workspace and document |
| Q&A | Direct answer from retrieved passages, or agent mode with task decomposition |
| Knowledge graph | Relations between documents |
| PDF workbench | PDF parsing, scanned-page recognition and Word export |
| Users and tokens | Accounts, roles, workspace grants and API tokens |
| Audit log | Records of sign-in, upload, deletion, search and configuration changes |
| Model settings | Model endpoints, retrieval parameters and vector index maintenance |

## Requirements

- Python 3.8 or later. The package is a prebuilt Windows x64 binary wheel
  (`cp38-abi3-win_amd64`); no build environment is required and it runs on 64-bit CPython 3.8
  and later. 32-bit and ARM platforms are not supported.
- Port 26804 must be free.
- The service listens on `0.0.0.0` by default and is reachable from other hosts on the local
  network. Set `EASYCAT_HOST` to `127.0.0.1` to restrict it to the local host.
- The local embedding model is loaded at startup. Model files are downloaded on first use and
  require disk space and some waiting time; afterwards the system works offline.
- A single uploaded file must not exceed 100 MB; adjust with `EASYCAT_MAX_UPLOAD_MB`.

## Installation

```bash
pip install easycat
```

Installation provides the `easycat` command-line entry point, and `python -m easycat` also
works; the import name is `easycat`.

The following components are optional and do not affect base functionality:

| Component | Purpose |
| --- | --- |
| `easycat[browser]` | Headless browser and clipboard support for web capture |
| `easycat[production]` | waitress instead of the built-in Flask server; recommended for concurrent use |
| `easycat[pdf-ocr-light]` | Scanned-page recognition (ONNX RapidOCR, CPU only, smaller footprint) |
| `easycat[pdf-ocr-paddle]` | Scanned-page recognition (PP-OCRv5 with layout, table and formula support) |

## Startup

```bash
easycat                 # starts the service, default http://127.0.0.1:26804
```

| Variable | Default | Description |
| --- | --- | --- |
| `EASYCAT_PORT` | `26804` | service port |
| `EASYCAT_HOST` | `0.0.0.0` | bind address |
| `EASYCAT_HOME` | `C:\Users\<user>\easycat` | data root |
| `EASYCAT_PRODUCTION` | `false` | set to `true` to use waitress |
| `EASYCAT_THREADS` | `8` | waitress thread count |
| `EASYCAT_MAX_UPLOAD_MB` | `100` | per-file upload limit |
| `EASYCAT_DEFAULT_PASSWORD` | empty | initial login password; the default is used when unset |

## Initial account

An administrator account `admin` is created on first start with the default password `easy123`.
Signing in with the default password requires changing it before the system can be used; a
password supplied through `EASYCAT_DEFAULT_PASSWORD` is not subject to that requirement.

## Features

### Workspaces

Each workspace has its own database and document directory, with no shared content or index.
Workspaces suit separation by project, product line or client, and can be backed up or moved
individually.

### Document import

`.doc`, `.docx`, `.txt`, `.md`, `.markdown`, `.xls`, `.xlsx`, `.csv`, `.ppt`, `.pptx` and `.pdf`
are supported. Office and spreadsheet files are extracted with markitdown, preserving table
structure. PDFs with a text layer are parsed by a layout engine that recognises columns, tables
and headings; scanned and mixed PDFs require the OCR component, installed separately.

Documents are split into sections and indexed; both the stored text and the index can be rebuilt.

### Retrieval

Full-text search is always available. With vector retrieval enabled, passages are recalled by
semantic similarity and re-ranked by relevance. Embedding and re-ranking models run locally and
call no external service. The vector index must be rebuilt after a model change or substantial
document changes; the settings page provides the rebuild action.

### Question answering

Direct mode answers from the retrieved passages and responds quickly, which suits factual
questions and short follow-ups. Agent mode decomposes the question, dispatches sub-tasks to read
several documents in parallel and consolidates the answer, which suits cross-document comparison.
Both stream the answer and cite sources.

### Permissions and audit

Accounts are either administrators or ordinary users. Administrators create workspaces, grant
read or write scope, and manage accounts and tokens. Sign-in, upload, deletion, search and
configuration changes are written to the audit log, queryable by account and time range.

### Open interface

The API tokens page issues tokens for calling the search and question-answering endpoints over
HTTP, for integration with other systems. Tokens can carry an expiry date and be revoked.

### PDF workbench

PDF layout parsing, scanned-page recognition and Word export. Parsed results keep heading levels
and tables and are exported as an editable `.docx`. Conversations can also be exported to Word.

## Data directory

All writable content is stored in `C:\Users\<user>\easycat` in six subdirectories: data, models,
cache, tmp, logs and backups. The data directory holds the database, settings and the document
content of each workspace, and is the main backup target. Uninstalling, reinstalling and upgrading
do not modify this directory; pre-upgrade snapshots are written to backups.

To migrate, copy the folder to the same location on the target host; workspaces, accounts and
index settings are retained. `EASYCAT_HOME` overrides the location.

## Licence

The software is proprietary and licensed per machine by component, machine code and expiry date.
A 90-day trial licence is issued automatically on first run, with no feature restrictions. After
expiry, a new licence code can be entered on the licence page.

Replacing the host, the system disk or reinstalling the operating system changes the machine code
and requires a new licence. Updating before expiry is recommended. Licence terms are distributed
with the package (`LICENSE.txt`). Do not install the software if the terms are not accepted.

## Contact

Licence requests, renewals and defect reports: 857914532@qq.com
