BotSharp/src/Platforms/BotSharp.Platform.LlamaSharp/LlamaSharplServiceCollectionExtensions.cs

22 lines
693 B
C#
Raw Normal View History

2023-05-27 01:58:31 +00:00
using BotSharp.Abstraction;
using BotSharp.Platform.LlamaSharp;
using BotSharp.Platform.Local.Handlers;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace BotSharp.Core;
public static class LlamaSharplServiceCollectionExtensions
{
public static IServiceCollection AddLlamaSharp(this IServiceCollection services, IConfiguration config)
{
services.AddSingleton(x =>
{
var settings = new LlamaSharpSettings();
config.Bind("LlamaSharp", settings);
return settings;
});
services.AddScoped<IChatCompletionHandler, ChatCompletionHandler>();
return services;
}
}