ydy0615 9ff51ac2f3 feat(plugin): add document export, doc‑block, and TTS/ASR support
Adds a DocBlock component that renders embedded documents, new export buttons for DOCX
and PDF, and updates the file‑upload picker to accept *.txt, *.docx, *.pptx, and *.pdf.
Introduces a DOCX→PDF conversion bridge in the backend and new /tts and /asr
endpoints that expose TTS and speech‑recognition functionality.  The README is
rewritten to describe the new features and clean up legacy documentation.  All
changes are backward‑compatible and do not introduce breaking API changes.
2026-04-04 23:56:18 +08:00
2026-01-11 14:11:14 +00:00

LLM in Text - 智能写作助手

基于 Vue3 和 FastAPI 的智能 Markdown 编辑器集成大语言模型LLM实时补全建议功能。

功能特性

Markdown 编辑器

  • 基于 Milkdown Crepe 的所见即所得编辑体验
  • 支持 Markdown 语法和 LaTeX 公式
  • 支持 Mermaid 图表渲染
  • 导入/导出 Markdown 文件
  • 导出 DOCX 和 PDF 格式

AI 智能补全

  • 实时生成文本补全建议(灰色显示)
  • 流式响应,低延迟体验
  • 多种交互方式Tab接受、Esc拒绝、点击接受

文档处理

  • OCR 图片识别:上传图片自动识别文字
  • 文档转换PDF、DOCX、PPTX、TXT 转 Markdown
  • 文档块嵌入:可折叠的文档预览块
  • 智能大小限制32KB自动禁用AI

设置面板

  • 外观主题:亮色/暗色/跟随系统
  • 背景模式:默认/暖色/阅读灯/自定义图片
  • 模型智能:低/中/高思考级别
  • 隐私控制隐私模式防止发送IP
  • 多语言界面:中英日韩德法

语音功能

  • TTS文字转语音macOS
  • STT语音转文字

技术架构

前端: Vue3 + Vite + Milkdown + ProseMirror 后端: FastAPI + Python + Ollama

快速开始

环境: Node.js 18+、Python 3.8+、Ollama

安装:

  • 前端: npm install
  • 后端: pip install -r backend/requirements.txt

启动:

  • 后端: python backend/main.py (端口8001)
  • 前端: npm run dev (端口5173)

API接口

  • POST /v1/completions 流式补全建议
  • POST /v1/ocr 图片文字识别
  • POST /v1/convert 文档转换
  • POST /v1/completions/cancel 取消请求

核心实现

后端

  • main.py: FastAPI服务器、SSE流式响应
  • llm.py: 异步Ollama调用、超时控制
  • prompt.py: 7条Prompt规则
  • tts_asr.py: macOS 语音处理

前端

  • copilotPlugin.ts: ProseMirror Mark系统
  • 关键函数: scheduleFetch、insertGhostText
  • Pinia Store状态管理

设计亮点

  1. 前后端分离
  2. 低延迟优化:防抖+SSE+AbortController
  3. ProseMirror Mark系统
  4. 多种交互方式
  5. 智能大小限制
  6. 隐私保护
  7. 多语言支持
  8. 主题定制
  9. 文档处理
  10. 语音功能

开发指南

代码风格: Python(4空格,snake_case) JS/TS(2空格,camelCase) 测试: pytest 构建: npm run build

许可证

MIT License

Description
No description provided
Readme MIT 33 MiB
Languages
Vue 37.9%
Python 26.6%
JavaScript 16.7%
TypeScript 14.4%
CSS 2.7%
Other 1.7%