24 lines
657 B
C#
24 lines
657 B
C#
using System.Net.Http.Headers;
|
|
using Admin.NET.Core.Ai.Option;
|
|
|
|
namespace Admin.NET.Core.Ai.Handlers;
|
|
|
|
public class LLMDelegatingHandler: DelegatingHandler
|
|
{
|
|
private readonly LLMCustomOptions _options;
|
|
|
|
public LLMDelegatingHandler(IOptions<LLMCustomOptions> options)
|
|
{
|
|
_options = options.Value;
|
|
}
|
|
|
|
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
|
{
|
|
//设置header
|
|
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _options.ApiKey);
|
|
return await base.SendAsync(request, cancellationToken);
|
|
}
|
|
}
|
|
|
|
|