修复OpenViking记忆文件已生成但搜索不到的问题
修复 OpenViking 在 Windows + 本地向量库 + 本地 embedding 模型 组合下,记忆文件已生成但搜索不到的问题。
问题现象
- OpenViking 服务可以正常启动
- 记忆文件可以正常生成
- 但执行搜索时返回空结果
1 | ov find "LoopingIsle" --context-type memory |
返回:
1 | { |
服务日志出现:
1 | openviking.storage.viking_vector_index_backend - ERROR - Error reading existing record before partial update: Strings must be encoded before hashing |
根本原因
OpenViking 在把字符串 ID 转成 64 位整数时,使用了:
1 | xxhash.xxh64(input_string) |
但 xxhash 在 Python 3 中要求传入 bytes,不能直接传入 str,因此抛出:
1 | Strings must be encoded before hashing |
这导致:
- 记忆 Markdown 文件正常写入
- 向量没有成功写入向量库
- 所以记忆文件存在,但语义搜索找不到
修复
修改文件:
1 | openviking/storage/vectordb/utils/str_to_uint64.py |
修改前:
1 | def str_to_uint64(input_string: str) -> int: |
修改后:
1 | def str_to_uint64(input_string: str) -> int: |
补丁文件
| 文件 | 说明 |
|---|---|
patches/0001-fix-str_to_uint64-xxhash-encoding.patch |
Git 补丁,可直接 git apply |
patches/patch-openviking-xxhash.ps1 |
Windows PowerShell 一键打补丁脚本 |
patches/fix-openviking-memory.ps1 |
重置向量库并重新索引记忆的修复脚本 |
使用方法
方法一:Git apply
1 | git apply patches/0001-fix-str_to_uint64-xxhash-encoding.patch |
方法二:PowerShell 脚本
1 | powershell -ExecutionPolicy Bypass -File patches\patch-openviking-xxhash.ps1 |
修复后重新索引
1 | ov reindex viking://user/default/memories --mode semantic_and_vectors --wait true |
环境
| 项目 | 值 |
|---|---|
| 操作系统 | Windows |
| Python | 3.14.7 |
| OpenViking | 0.4.14 |
| 向量库 | local 本地向量库 |
| Embedding | 本地 GGUF 模型(512 维) |
| VLM | OpenCode Go(deepseek-v4-flash) |
为什么很多人没遇到
这个 bug 主要在以下组合下出现:
- Windows
- Python 3.14
- 本地向量库
- 本地 GGUF embedding 模型
大多数用户使用的是:
- Linux + Docker
- 云端 embedding API
- 云端/托管向量数据库
- 较旧的 Python 版本
所以这条本地路径测试覆盖较少。
额外注意
如果只是移动了 OpenViking 目录导致向量库元数据路径不匹配,可以在配置中加:
1 | { |
前提是模型没有换、维度没有变。