最近在学习 Kernel Memory,想给 HttpClient 添加一个 DelegatingHandler 看看 OpenAI 的 api 响应内容
var builder = new KernelMemoryBuilder()
.WithOpenAIDefaults(OPENAI_API_KEY);
builder.Services.ConfigureHttpClientDefaults(b =>
b.ConfigurePrimaryHttpMessageHandler(() => new LoggingHandler()));
但上面的代码中 ConfigureHttpClientDefaults
却出现编译错误
'ServiceCollectionPool' does not contain a definition for 'ConfigureHttpClientDefaults'...
请问如何解决?
原来是少个 nuget 包,我还以为 ServiceCollectionPool
不支持 ConfigureHttpClientDefaults
,ServiceCollectionPool
也实现了 IServiceCollection
接口
dotnet add package Microsoft.Extensions.Http