feat: 添加知识库检索功能和改进模型路由错误处理
- 在ChatRequest中添加Citation事件类型,支持引用来源展示 - 实现聊天上下文准备服务,构建带源元数据的受限聊天上下文 - 添加ThreadedProcess类以支持Windows平台的子进程操作 - 改进检索引擎中的错误处理和向量搜索逻辑 - 实现严格的嵌入模型验证和索引重建机制 - 添加前端聊天界面的知识库检索开关 - 实现搜索历史记录功能和错误降级处理 - 更新模型路由设置提示信息以反映索引重建需求
This commit is contained in:
@@ -77,12 +77,12 @@ def _delete_markdown(rel_path: str) -> None:
|
||||
PreparedIndex = tuple[list[list[float]], routed_vectors.RemoteEmbeddings | None]
|
||||
|
||||
|
||||
async def prepare_note_index(parsed: ParsedNote) -> PreparedIndex:
|
||||
async def prepare_note_index(parsed: ParsedNote, *, strict=False) -> PreparedIndex:
|
||||
"""Compute vectors before opening a write transaction (including API I/O)."""
|
||||
texts = [block.content for block in parsed.blocks]
|
||||
if isinstance(embedding, LocalEmbedding):
|
||||
# One routed invocation: API first, validated local fallback. No hash vectors.
|
||||
remote = await routed_vectors.embed_remote(texts, accept_local=True)
|
||||
remote = await routed_vectors.embed_remote(texts, accept_local=True, strict=strict)
|
||||
return [], remote
|
||||
vectors = await embedding.embed_documents(texts)
|
||||
remote = await routed_vectors.embed_remote(texts)
|
||||
|
||||
Reference in New Issue
Block a user