Skip to content

Commit b982069

Browse files
committed
v0.9.0: early opus 4.7 support; major Paper Reader overhaul (beta); Amazon Bedrock endpoint; SQLite fallback (no PostgreSQL required); numerous bug fixes
1 parent a4dbd5a commit b982069

192 files changed

Lines changed: 19584 additions & 6299 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,7 @@ jobs:
8989
needs: lint
9090
timeout-minutes: 15
9191

92-
services:
93-
postgres:
94-
image: postgres:17
95-
env:
96-
POSTGRES_USER: chatui
97-
POSTGRES_PASSWORD: chatui
98-
POSTGRES_DB: chatui
99-
ports:
100-
- 5432:5432
101-
options: >-
102-
--health-cmd "pg_isready -U chatui"
103-
--health-interval 10s
104-
--health-timeout 5s
105-
--health-retries 5
106-
107-
env:
108-
CHATUI_PG_HOST: localhost
109-
CHATUI_PG_PORT: "5432"
110-
CHATUI_PG_USER: chatui
111-
CHATUI_PG_PASSWORD: chatui
112-
CHATUI_PG_DBNAME: chatui
113-
92+
# No service containers needed — SQLite is built into Python
11493
steps:
11594
- uses: actions/checkout@v4
11695

@@ -150,5 +129,3 @@ jobs:
150129

151130
- name: Run healthcheck
152131
run: python healthcheck.py
153-
154-

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ data/
2323
/sundries/
2424
/tools/
2525

26+
# ── SWE-bench workdir (large, causes FUSE timeouts) ──
27+
swebench_workdir/
28+
2629
# ── Test coverage ──
2730
.coverage
2831

@@ -61,3 +64,4 @@ docs/RATE_LIMITING_DOS_AUDIT_REPORT.md
6164
# ── Uploads ──
6265
uploads/images/*
6366
!uploads/images/.gitkeep
67+
uploads/pptx/

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ FROM python:3.12-slim AS base
1313

1414
# ── System dependencies ─────────────────────────────────────
1515
RUN apt-get update && apt-get install -y --no-install-recommends \
16-
# PostgreSQL (Debian bookworm ships v16 — compatible with PG 18+ protocol)
17-
postgresql-16 \
18-
postgresql-client-16 \
1916
# Build tools for compiled Python packages
2017
gcc g++ \
2118
# Playwright / browser automation system deps
@@ -49,18 +46,16 @@ RUN mkdir -p /app/data /app/logs /app/uploads
4946
# ── Environment defaults ───────────────────────────────────
5047
ENV PORT=15000 \
5148
BIND_HOST=0.0.0.0 \
52-
# PostgreSQL runs as a local subprocess managed by the app
53-
# Data lives in the mounted volume at /app/data
5449
PYTHONUNBUFFERED=1 \
5550
PYTHONDONTWRITEBYTECODE=1
5651

5752
# ── Expose port ────────────────────────────────────────────
5853
EXPOSE 15000
5954

6055
# ── Health check ───────────────────────────────────────────
61-
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
56+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
6257
CMD curl -f http://localhost:15000/ || exit 1
6358

6459
# ── Entrypoint ─────────────────────────────────────────────
65-
# server.py auto-bootstraps PostgreSQL on first run
60+
# SQLite auto-creates the database on first run — zero setup needed
6661
CMD ["python", "server.py"]

README.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<p align="center">
88
<a href="https://github.com/rangehow/ToFu/actions/workflows/ci.yml"><img src="https://github.com/rangehow/ToFu/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
99
<img src="https://img.shields.io/badge/python-3.10+-3776ab?logo=python&logoColor=white" alt="Python" />
10-
<img src="https://img.shields.io/badge/PostgreSQL-18+-336791?logo=postgresql&logoColor=white" alt="PostgreSQL" />
10+
<img src="https://img.shields.io/badge/SQLite-3-003B57?logo=sqlite&logoColor=white" alt="SQLite" />
11+
<img src="https://img.shields.io/badge/PostgreSQL-18+ (optional)-336791?logo=postgresql&logoColor=white" alt="PostgreSQL optional" />
1112
<img src="https://img.shields.io/badge/license-MIT-green" alt="License" />
1213
<img src="https://img.shields.io/badge/platform-Linux%20·%20macOS%20·%20Windows-lightgrey" alt="Platform" />
1314
</p>
@@ -50,7 +51,9 @@ git clone https://github.com/rangehow/ToFu.git && cd ToFu
5051
python install.py
5152
```
5253

53-
This creates a virtual environment, installs dependencies, bootstraps PostgreSQL, and starts the server. Open **http://localhost:15000** when it's ready.
54+
This creates a virtual environment, installs dependencies, and starts the server. Open **http://localhost:15000** when it's ready.
55+
56+
> 💾 **Database: zero-config out of the box.** Tofu uses **SQLite** by default — it's built into Python, no install needed. If PostgreSQL is available it will auto-bootstrap and upgrade to PG (better concurrency for 100+ users). Force SQLite with `CHATUI_DB_BACKEND=sqlite`.
5457
5558
```bash
5659
# Pre-configure API key and port
@@ -75,15 +78,29 @@ Open **http://localhost:15000** — done. All data persists in Docker volumes.
7578
<details>
7679
<summary><strong>Manual Install</strong> (for full control)</summary>
7780

78-
**Prerequisites:** Python 3.10+, PostgreSQL 18+, ripgrep & fd-find (recommended)
81+
**Prerequisites:** Python 3.10+, ripgrep & fd-find (recommended). PostgreSQL 18+ is *optional* — Tofu uses SQLite by default.
82+
83+
> 💡 **Strongly recommended: use [Miniforge](https://github.com/conda-forge/miniforge) to manage your Python environment.**
84+
> Old system-installed conda/Anaconda versions often cause dependency conflicts. Install the latest Miniforge for a clean, up-to-date conda-forge environment:
85+
> ```bash
86+
> # Download and install Miniforge (Linux x86_64 example)
87+
> wget -O /tmp/Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh"
88+
> bash /tmp/Miniforge3.sh -b -p ~/miniforge3
89+
> ~/miniforge3/bin/conda init bash && source ~/.bashrc
90+
>
91+
> # Create a dedicated environment
92+
> conda create -n tofu python=3.10 -y
93+
> conda activate tofu
94+
> ```
95+
> For other platforms, see the [Miniforge releases page](https://github.com/conda-forge/miniforge/releases).
7996
8097
```bash
8198
git clone https://github.com/rangehow/ToFu.git && cd ToFu
8299
83-
# Create environment
100+
# Create environment (skip if using conda/Miniforge)
84101
python -m venv .venv && source .venv/bin/activate
85102
86-
# Install PostgreSQL (if not already)
103+
# Optional: install PostgreSQL for better concurrency (SQLite works out of the box)
87104
# macOS: brew install postgresql@18
88105
# Ubuntu: sudo apt install postgresql
89106
# conda: conda install -c conda-forge postgresql>=18
@@ -104,7 +121,7 @@ python server.py
104121
105122
</details>
106123

107-
> **PostgreSQL** runs as a local userspace process no `sudo`, no system service. On first launch, the database auto-bootstraps (initdb, schema creation, port selection).
124+
> **Database auto-detection:** On first launch, Tofu tries PostgreSQL first (for best concurrency). If PG isn't available, it falls back to **SQLite** automatically — no action needed on your part. PostgreSQL runs as a local userspace process when present (no `sudo`, no system service). Set `CHATUI_DB_BACKEND=sqlite` to force SQLite.
108125
109126
> **Missing packages?** If any dependency is missing, `server.py` auto-delegates to `bootstrap.py`, which uses the LLM to diagnose the error and `pip install` the right packages — even when *every* pip package is missing.
110127
@@ -120,7 +137,7 @@ Click **⚙️ Settings → 🔗 Providers** and add your API keys. Tofu works w
120137

121138
| Provider | Setup |
122139
|---|---|
123-
| OpenAI, Anthropic, Google Gemini, DeepSeek, Qwen, MiniMax, GLM, Doubao, Mistral, Grok, Baidu Qianfan, OpenRouter | Click **⚡ Add from template** — one click |
140+
| OpenAI, Anthropic, Amazon Bedrock, Google Gemini, DeepSeek, Qwen, MiniMax, GLM, Doubao, Mistral, Grok, Baidu Qianfan, OpenRouter | Click **⚡ Add from template** — one click |
124141
| Ollama, vLLM, or any local model server | Add as custom provider with your local endpoint |
125142
| Azure OpenAI | Template available with deployment-specific base URL |
126143

@@ -348,6 +365,22 @@ The agent connects to your Tofu server and exposes tools for file operations, cl
348365

349366
---
350367

368+
### 📄 Paper Reader (beta)
369+
370+
When you're reading research papers — arXiv PDFs, conference proceedings, internal whitepapers — Paper Reader turns Tofu into a dedicated research companion.
371+
372+
**How to use:** Click the **📄 Paper** button in the sidebar. The screen splits: **PDF on the left**, **chat + notes on the right**. Upload a PDF or paste an arXiv URL (`arxiv.org/abs/XXXX.XXXXX`) — Tofu fetches, parses, and indexes the full text so the assistant can answer questions grounded in the paper.
373+
374+
**What it does:**
375+
- **Grounded Q&A** — ask "what's the ablation result in Table 3?" or "explain Section 4.2" — the assistant cites the specific passage it's drawing from
376+
- **Paper library** — the left sidebar shows all papers you've read, grouped by date; switch between them without losing conversation context
377+
- **Side-by-side reading** — scroll the PDF while chatting; the assistant sees the page you're on
378+
- **Notes tab** — drop your own notes alongside the paper; they persist across sessions
379+
380+
> ⚠️ **Beta:** Paper Reader is actively being iterated on. Feedback welcome on [GitHub Issues](https://github.com/rangehow/ToFu/issues).
381+
382+
---
383+
351384
### 🖼️ Image Generation
352385

353386
When you need visual content — illustrations, diagrams, logos, edited photos — the assistant can generate images mid-conversation.
@@ -501,7 +534,7 @@ The `.env.example` file documents all supported variables. Key ones:
501534
│ ├── agent_backends/ CLI backend switching (builtin/Claude Code/Codex)
502535
│ ├── llm_client.py LLM API client (streaming, retry)
503536
│ ├── llm_dispatch/ Multi-key multi-model smart dispatcher
504-
│ ├── database/ PostgreSQL (auto-bootstrap, migrations)
537+
│ ├── database/ Dual backend — SQLite default, PostgreSQL auto-bootstrap
505538
│ ├── tasks_pkg/ Task orchestration & context compaction
506539
│ │ ├── orchestrator.py Main LLM ↔ tool loop
507540
│ │ ├── executor.py Tool execution engine
@@ -536,7 +569,8 @@ The `.env.example` file documents all supported variables. Key ones:
536569
| Feature | Linux | macOS | Windows |
537570
|---|:---:|:---:|:---:|
538571
| Core chat & tools ||||
539-
| PostgreSQL auto-bootstrap ||||
572+
| SQLite (default, zero-config) ||||
573+
| PostgreSQL auto-bootstrap (optional) ||||
540574
| Project co-pilot ||||
541575
| Shell commands ||| ✅ (`cmd.exe`) |
542576
| Desktop agent ||||

README_CN.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<p align="center">
88
<a href="https://github.com/rangehow/ToFu/actions/workflows/ci.yml"><img src="https://github.com/rangehow/ToFu/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
99
<img src="https://img.shields.io/badge/python-3.10+-3776ab?logo=python&logoColor=white" alt="Python" />
10-
<img src="https://img.shields.io/badge/PostgreSQL-18+-336791?logo=postgresql&logoColor=white" alt="PostgreSQL" />
10+
<img src="https://img.shields.io/badge/SQLite-3-003B57?logo=sqlite&logoColor=white" alt="SQLite" />
11+
<img src="https://img.shields.io/badge/PostgreSQL-18+ (可选)-336791?logo=postgresql&logoColor=white" alt="PostgreSQL 可选" />
1112
<img src="https://img.shields.io/badge/license-MIT-green" alt="License" />
1213
<img src="https://img.shields.io/badge/platform-Linux%20·%20macOS%20·%20Windows-lightgrey" alt="Platform" />
1314
</p>
@@ -50,7 +51,9 @@ git clone https://github.com/rangehow/ToFu.git && cd ToFu
5051
python install.py
5152
```
5253

53-
安装脚本会自动创建虚拟环境、安装依赖、初始化 PostgreSQL 并启动服务器。就绪后打开 **http://localhost:15000**。
54+
安装脚本会自动创建虚拟环境、安装依赖并启动服务器。就绪后打开 **http://localhost:15000**。
55+
56+
> 💾 **数据库:开箱即用、无需配置。** Tofu 默认使用 **SQLite** —— Python 内置,无需安装。如果系统中有 PostgreSQL,Tofu 会自动初始化并升级为 PG 后端(支持 100+ 用户更高并发)。设置 `CHATUI_DB_BACKEND=sqlite` 即可强制使用 SQLite。
5457
5558
```bash
5659
# 预配置 API 密钥和端口
@@ -75,15 +78,29 @@ docker compose up -d
7578
<details>
7679
<summary><strong>手动安装</strong>(完全控制)</summary>
7780

78-
**前提条件:** Python 3.10+,PostgreSQL 18+,ripgrep & fd-find(推荐)
81+
**前提条件:** Python 3.10+,ripgrep & fd-find(推荐)。PostgreSQL 18+ 为*可选* —— Tofu 默认使用 SQLite。
82+
83+
> 💡 **强烈推荐:使用 [Miniforge](https://github.com/conda-forge/miniforge) 管理 Python 环境。**
84+
> 旧版系统自带的 conda/Anaconda 经常导致依赖冲突。安装最新版 Miniforge 可获得干净、最新的 conda-forge 环境:
85+
> ```bash
86+
> # 下载并安装 Miniforge(Linux x86_64 示例)
87+
> wget -O /tmp/Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh"
88+
> bash /tmp/Miniforge3.sh -b -p ~/miniforge3
89+
> ~/miniforge3/bin/conda init bash && source ~/.bashrc
90+
>
91+
> # 创建专用环境
92+
> conda create -n tofu python=3.10 -y
93+
> conda activate tofu
94+
> ```
95+
> 其他平台请参考 [Miniforge 发布页面](https://github.com/conda-forge/miniforge/releases)。
7996
8097
```bash
8198
git clone https://github.com/rangehow/ToFu.git && cd ToFu
8299
83-
# 创建环境
100+
# 创建环境(如果已用 conda/Miniforge 则跳过此步)
84101
python -m venv .venv && source .venv/bin/activate
85102
86-
# 安装 PostgreSQL(如尚未安装
103+
# 可选:安装 PostgreSQL 以获得更高并发(SQLite 开箱即用
87104
# macOS: brew install postgresql@18
88105
# Ubuntu: sudo apt install postgresql
89106
# conda: conda install -c conda-forge postgresql>=18
@@ -104,7 +121,7 @@ python server.py
104121
105122
</details>
106123

107-
> **PostgreSQL** 以本地用户态进程运行 —— 无需 `sudo`,无需系统服务。首次启动时数据库自动初始化(initdb、建表、端口选择)
124+
> **数据库自动检测:**首次启动时,Tofu 优先尝试 PostgreSQL(更好的并发性);如 PG 不可用则自动回退到 **SQLite** —— 你无需任何操作。PostgreSQL 如存在会以本地用户态进程运行(无需 `sudo`,无需系统服务)。设置 `CHATUI_DB_BACKEND=sqlite` 即可强制使用 SQLite
108125
109126
> **缺少依赖?** 如果有任何 pip 包缺失,`server.py` 会自动委托给 `bootstrap.py`,通过 LLM 诊断错误并自动 `pip install` 所需的包 —— 即使*所有*依赖都缺失也能工作。
110127
@@ -120,7 +137,7 @@ python server.py
120137

121138
| 服务商 | 配置方式 |
122139
|---|---|
123-
| OpenAI、Anthropic、Google Gemini、DeepSeek、Qwen、MiniMax、GLM、Doubao、Mistral、Grok、百度千帆、OpenRouter | 点击 **⚡ 从模板添加** —— 一键完成 |
140+
| OpenAI、Anthropic、Amazon Bedrock、Google Gemini、DeepSeek、Qwen、MiniMax、GLM、Doubao、Mistral、Grok、百度千帆、OpenRouter | 点击 **⚡ 从模板添加** —— 一键完成 |
124141
| Ollama、vLLM 或任何本地模型服务 | 添加为自定义服务商,填入你的本地端点 |
125142
| Azure OpenAI | 模板可用,填入部署专属的 Base URL |
126143

@@ -348,6 +365,22 @@ python lib/desktop_agent.py --server http://your-server:15000 --allow-write --al
348365

349366
---
350367

368+
### 📄 论文阅读模式(Beta)
369+
370+
阅读科研论文 —— arXiv PDF、会议论文集、内部白皮书 —— Paper Reader 把 Tofu 变成一个専用的科研阅读伙伴。
371+
372+
**使用方法:** 点击侧边栏的 **📄 Paper** 按钮。页面分屏:**左侧 PDF、右侧对话 + 笔记**。上传 PDF 或粘贴 arXiv 链接(`arxiv.org/abs/XXXX.XXXXX`) —— Tofu 会抓取、解析、索引全文,令助手能基于论文内容精准回答。
373+
374+
**能做什么:**
375+
- **有据可依的问答** —— “表 3 的消融实验结果是什么?”或“解释 4.2 节”,助手会引用具体段落
376+
- **论文库** —— 左侧侧边栏展示你读过的所有论文,按时间分组;切换论文不丢失上下文
377+
- **并排阅读** —— 滚动 PDF 的同时聊天;助手可感知你当前所在页面
378+
- **笔记面板** —— 在论文旁边记录你自己的笔记,跨会话持久保存
379+
380+
> ⚠️ **Beta:** 论文阅读模式正在持续迭代中,欢迎在 [GitHub Issues](https://github.com/rangehow/ToFu/issues) 反馈。
381+
382+
---
383+
351384
### 🖼️ 图片生成
352385

353386
当你需要视觉内容 —— 插图、图表、Logo、修图 —— 助手可以在对话中直接生成图片。
@@ -501,7 +534,7 @@ vim .env # 填入你的值
501534
│ ├── agent_backends/ CLI 后端切换(内置/Claude Code/Codex)
502535
│ ├── llm_client.py LLM API 客户端(流式,重试)
503536
│ ├── llm_dispatch/ 多密钥多模型智能调度器
504-
│ ├── database/ PostgreSQL自动初始化,迁移)
537+
│ ├── database/ 双后端—— SQLite 默认,PostgreSQL 自动初始化
505538
│ ├── tasks_pkg/ 任务编排与上下文压缩
506539
│ │ ├── orchestrator.py LLM ↔ 工具主循环
507540
│ │ ├── executor.py 工具执行引擎
@@ -536,7 +569,8 @@ vim .env # 填入你的值
536569
| 功能 | Linux | macOS | Windows |
537570
|---|:---:|:---:|:---:|
538571
| 核心对话与工具 ||||
539-
| PostgreSQL 自动初始化 ||||
572+
| SQLite(默认,零配置) ||||
573+
| PostgreSQL 自动初始化(可选) ||||
540574
| 项目协作 ||||
541575
| Shell 命令 ||| ✅ (`cmd.exe`) |
542576
| 桌面代理 ||||

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.0
1+
0.9.0

0 commit comments

Comments
 (0)