feat(knowledge): 阶段二 向量 RAG 与召回注入
- embeddings.py:OpenAI 兼容 embedding 客户端,未配置时关键词兜底
- chunking.py + knowledge_embeddings 表:Markdown 分块与向量索引(Python 余弦)
- search.py:keyword/vector/hybrid 三种模式,向量不可用自动降级
- 笔记创建/更新自动重建向量索引;新增 /reindex 维护接口
- KnowledgeRagMiddleware:按对话级开关 knowledge_rag_enabled 注入 <knowledge-context>,接入 lead agent 中间件链(默认随 config.knowledge.rag_enabled)
- service.build_rag_context(wiki-query 风格分层召回)
- 笔记版本快照(knowledge_note_versions)+ GET /notes/{id}/versions
- 前端:聊天页「知识库」对话级 RAG 开关 + 类型字段
- 新增 entities/relations 表(阶段四预置)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8463289f75
commit
683cc6d76e
14 files changed
+738
-40
No files matched your search
+14
-3
@@ -20,11 +20,22 @@ class KnowledgeQueryConfig(BaseModel):
|
||||
|
||||
|
||||
class KnowledgeEmbeddingConfig(BaseModel):
|
||||
"""Vector embedding config (phase 2 — disabled in the first release)."""
|
||||
"""Vector embedding config (phase 2).
|
||||
|
||||
Vector RAG is opt-in: set ``enabled: true`` and point ``base_url`` at an
|
||||
OpenAI-compatible ``/embeddings`` endpoint. When disabled or unreachable,
|
||||
search transparently falls back to keyword scoring, so the feature degrades
|
||||
gracefully on offline deployments without an embedding model.
|
||||
"""
|
||||
|
||||
enabled: bool = Field(default=False, description="Enable vector embeddings.")
|
||||
provider: str = Field(default="local", description="Embedding provider.")
|
||||
model: str = Field(default="", description="Embedding model name.")
|
||||
provider: str = Field(default="openai", description="Embedding provider (openai-compatible).")
|
||||
model: str = Field(default="", description="Embedding model name, e.g. text-embedding-3-small / bge-m3.")
|
||||
base_url: str = Field(default="", description="OpenAI-compatible base URL (…/v1). Empty disables vector mode.")
|
||||
api_key: str = Field(default="", description="API key for the embedding endpoint ($ENV resolved like other config).")
|
||||
dimensions: int | None = Field(default=None, description="Optional embedding dimensions hint sent to the endpoint.")
|
||||
batch_size: int = Field(default=32, description="Texts per embedding request.")
|
||||
timeout_seconds: int = Field(default=30, description="HTTP timeout per embedding request.")
|
||||
|
||||
|
||||
class KnowledgeConfig(BaseModel):
|
||||
|
||||
Reference in new issue
Block a user