Skip to content

Zoean-z/askRAG

Repository files navigation

askRAg

本地优先的 AI 知识工作台,支持文档问答、长期记忆、可选联网搜索和可持续的会话工作流。

这个项目的当前边界很明确:

  • Chroma 负责静态文档证据与本地检索
  • OpenViking 负责长期记忆、回答时上下文和可持久化记忆能力
  • 主应用现在分层落在 app/core/app/memory/app/retrieval/

现在能做什么

  • 流式聊天
  • 多轮对话与会话恢复
  • .txt / .md 文档上传、删除和本地索引
  • 本地优先的文档问答
  • 文档概览 / 简介 / 摘要问答
  • 证据不足时返回关联证据,而不是直接空拒答
  • 长期记忆的提取、审批、回滚、编辑和删除
  • 记忆中心可视化查看
  • 可选联网搜索开关
  • 独立的知识库页、记忆页和设置 / 支持浮层

项目结构

  • app/core/: API 入口、RAG、路由、工作流、文档与系统状态
  • app/memory/: 长期记忆、提取、审批、回滚、复用
  • app/retrieval/: chunk 检索、父子片段选择、后端封装、重排
  • app/frontend/: 聊天、知识库、记忆页和前端浮层面板
  • data/docs/: 正式业务文档
  • data/state/: 会话、文档注册表、循环状态、记忆状态等持久化状态
  • data/backups/: 备份产物
  • data/chroma/: 本地向量索引
  • data/openviking_workspace/: OpenViking 工作区

项目边界

  • 文档检索只走 Chroma
  • 长期记忆只走 OpenViking
  • conversation_threads.json 只是对话回放和用户可见状态,不是主推理存储
  • 关闭联网开关时,本地检索和记忆仍然可用,但不会自动升级到联网

运行方式

安装依赖:

.\.venv\Scripts\python.exe -m pip install -r requirements.txt

构建或重建本地索引:

.\.venv\Scripts\python.exe -m app.core.rag index

启动 API 服务:

.\.venv\Scripts\python.exe -m app.core.main

打开页面:

Chat:    http://127.0.0.1:8001/
Library: http://127.0.0.1:8001/library
Memory:  http://127.0.0.1:8001/memory

如果你要使用联网搜索或 OpenAI 兼容模型,需要先配置对应环境变量。项目当前支持 OpenAI-compatible 的 chat 和 embedding provider。

OpenViking

OpenViking 不是基础文档问答的必需项,但它是长期记忆和回答时上下文体验的核心依赖。

不依赖 OpenViking 也能用

  • 文档上传与删除
  • 本地索引重建
  • Chroma 文档检索
  • 基础聊天 / 知识库页面

依赖 OpenViking 的能力

  • 长期记忆同步与复用
  • 回答时记忆上下文组装
  • 记忆中心里的长期偏好与稳定事实

启动和检查

.\.venv\Scripts\openviking-server.exe --config %USERPROFILE%\.openviking\ov.conf
.\.venv\Scripts\ov.exe health

API 概览

  • GET /health
  • GET /conversations
  • POST /conversations
  • GET /conversations/{conversation_id}
  • DELETE /conversations/{conversation_id}
  • GET /documents
  • POST /documents/upload
  • DELETE /documents?source=...
  • POST /ask
  • POST /ask/stream
  • GET /memories
  • POST /memories/extract
  • POST /memories/{memory_id}/approve
  • POST /memories/{memory_id}/rollback
  • PATCH /memories/{memory_id}
  • DELETE /memories/{memory_id}
  • GET /ops/state
  • POST /ops/rebuild-index

验证

.\.venv\Scripts\python.exe -m unittest discover -s tests
.\.venv\Scripts\python.exe scripts\run_regression_eval.py

当前状态

  • 代码已经按 core / memory / retrieval / frontend 分层
  • 前端已经有 Chat / Knowledge Base / Memory 三页和设置 / 支持浮层
  • 文档简介类问法会优先走 local_doc_summary
  • 证据不足时会优先展示最相关片段,而不是直接空拒答

English

Open English version

askRAg

A local-first AI knowledge workspace for document Q&A, durable memory, optional web search, and ongoing multi-turn conversations.

The current boundary is intentionally clear:

  • Chroma handles static document evidence and local retrieval
  • OpenViking handles durable memory, answer-time context, and persisted remembered state
  • The main app now lives under app/core/, app/memory/, and app/retrieval/

What it can do now

  • Streaming chat
  • Multi-turn conversations with thread restore
  • Upload and delete .txt / .md documents
  • Local-first document Q&A
  • Document overview / intro / summary questions
  • Show related evidence when the evidence is incomplete
  • Long-term memory extraction, approval, rollback, editing, and deletion
  • A memory center for browsing stored memory
  • Optional web search toggle
  • Separate Chat, Knowledge Base, Memory, Settings, and Support surfaces

Project structure

  • app/core/: API entrypoints, RAG, routing, workflow, document, and system state logic
  • app/memory/: long-term memory, extraction, approval, rollback, and reuse
  • app/retrieval/: chunk retrieval, parent selection, backend seam, reranking
  • app/frontend/: chat, knowledge base, memory pages, and floating panels
  • data/docs/: canonical project documents
  • data/state/: persistent conversation, registry, loop state, and memory state
  • data/backups/: backup artifacts
  • data/chroma/: local vector index
  • data/openviking_workspace/: OpenViking workspace

Boundaries

  • Document retrieval is handled by Chroma
  • Durable memory is handled by OpenViking
  • conversation_threads.json is user-facing replay state, not the primary reasoning store
  • When web search is disabled, local retrieval and memory still work, but the system will not auto-upgrade to web

Run

Install dependencies:

.\.venv\Scripts\python.exe -m pip install -r requirements.txt

Build or rebuild the local index:

.\.venv\Scripts\python.exe -m app.core.rag index

Start the API server:

.\.venv\Scripts\python.exe -m app.core.main

Open the pages:

Chat:    http://127.0.0.1:8001/
Library: http://127.0.0.1:8001/library
Memory:  http://127.0.0.1:8001/memory

If you want web search or OpenAI-compatible providers, configure the corresponding environment variables first.

OpenViking

OpenViking is not required for the basic document-Q&A workflow, but it is required for the full durable-memory experience.

Works without OpenViking

  • document upload and delete
  • local index rebuild
  • Chroma-backed document retrieval
  • basic chat and library pages

Depends on OpenViking

  • durable memory synchronization and reuse
  • answer-time memory context assembly
  • long-term preferences and stable facts in the memory center

Start and health check

.\.venv\Scripts\openviking-server.exe --config %USERPROFILE%\.openviking\ov.conf
.\.venv\Scripts\ov.exe health

API overview

  • GET /health
  • GET /conversations
  • POST /conversations
  • GET /conversations/{conversation_id}
  • DELETE /conversations/{conversation_id}
  • GET /documents
  • POST /documents/upload
  • DELETE /documents?source=...
  • POST /ask
  • POST /ask/stream
  • GET /memories
  • POST /memories/extract
  • POST /memories/{memory_id}/approve
  • POST /memories/{memory_id}/rollback
  • PATCH /memories/{memory_id}
  • DELETE /memories/{memory_id}
  • GET /ops/state
  • POST /ops/rebuild-index

Verification

.\.venv\Scripts\python.exe -m unittest discover -s tests
.\.venv\Scripts\python.exe scripts\run_regression_eval.py

Current status

  • The codebase is now split into core / memory / retrieval / frontend
  • The frontend includes Chat / Knowledge Base / Memory pages plus Settings / Support overlays
  • Document-intro questions now route to local_doc_summary
  • When evidence is incomplete, the app shows the most relevant snippets instead of returning a hard refusal immediately

About

Local-first AI knowledge workspace with document RAG, durable memory, and optional web search.本地优先的 AI 知识工作台,支持文档问答、长期记忆和可选联网搜索。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors