You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用KernelMemory+LLamaSharp时遇Volume not found异常求助

问题排查与解决:System.IO.DirectoryNotFoundException: 'Volume not found: default'

问题现象

调用ImportDocumentAsync或ImportWebPageAsync时触发异常:

System.IO.DirectoryNotFoundException: 'Volume not found: default'

触发代码示例:

await memo.ImportDocumentAsync(path, steps: Microsoft.KernelMemory.Constants.PipelineWithSummary);
// 或
await memo.ImportWebPageAsync("https://cdsarc.u-strasbg.fr/ftp/cats/J/A+A/ReadMe.txt", steps: Microsoft.KernelMemory.Constants.PipelineWithoutSummary);

当前IKernelMemory初始化代码:

string modelsPath = @"C:\rahul\Meta-Llama-3-8B-Instruct.Q2_K.gguf";

LLama.Common.InferenceParams infParams = new() { AntiPrompts = ["\n\n"] };
LLamaSharpConfig lsConfig = new(modelsPath) { DefaultInferenceParams = infParams };
SearchClientConfig searchClientConfig = new()
{
    MaxMatchesCount = 1,
    AnswerTokens = 100,
};

TextPartitioningOptions parseOptions = new()
{
    MaxTokensPerParagraph = 300,
    MaxTokensPerLine = 100,
    OverlappingTokens = 30
};

IKernelMemory memo = new KernelMemoryBuilder()
    .WithLLamaSharpDefaults(lsConfig)
    .WithSearchClientConfig(searchClientConfig)
    .With(parseOptions)
   .Build();

using LLama.Common;
using LLama;
using LLamaSharp.KernelMemory;
using Microsoft.KernelMemory.Configuration;
using Microsoft.KernelMemory;

原因分析

KernelMemory需要存储后端保存文档分片、向量数据等内容,默认会尝试使用名为default的存储卷,但你的代码仅配置了LLM(LLamaSharp)和文本解析参数,未指定任何存储实现,导致系统找不到可用存储卷。

解决方案

需在KernelMemoryBuilder中显式添加存储配置,以下是两种常用方案:

方案1:使用内存存储(适合快速测试)

内存存储将数据保存在内存中,进程关闭后数据丢失,适合调试或临时场景:

IKernelMemory memo = new KernelMemoryBuilder()
    .WithLLamaSharpDefaults(lsConfig)
    .WithSearchClientConfig(searchClientConfig)
    .With(parseOptions)
    .WithMemoryDb() // 添加内存存储
   .Build();

方案2:使用本地文件系统存储(持久化数据)

配置本地目录作为存储卷,数据会持久化保存到指定路径:

// 配置文件存储路径
var fileStorageConfig = new FileStorageConfig
{
    Directory = @"C:\KernelMemory\Storage" // 替换为你的实际存储目录
};

IKernelMemory memo = new KernelMemoryBuilder()
    .WithLLamaSharpDefaults(lsConfig)
    .WithSearchClientConfig(searchClientConfig)
    .With(parseOptions)
    .WithFileStorage(fileStorageConfig) // 添加本地文件存储
   .Build();

验证修改

添加存储配置后,重新运行代码,调用ImportDocumentAsync或ImportWebPageAsync即可正常执行,不再触发Volume not found异常。

内容的提问来源于stack exchange,提问作者Jimmy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 13:13:27