Add provider abstraction layer with Mistral and Ollama implementations
Define IProvider interface and implement concrete providers for Mistral (with custom DTOs for chat completion API) and Ollama (via OllamaSharp). Includes DI registration extensions using Microsoft.Extensions.AI.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Luna.Configuration;
|
||||
using Luna.Providers.Abstractions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Luna.Providers.Extensions;
|
||||
|
||||
public static class ServiceProviderExtensions
|
||||
{
|
||||
extension(IServiceProvider provider)
|
||||
{
|
||||
public TProvider GetProvider<TProvider>(string? name = null)
|
||||
where TProvider : IProvider
|
||||
{
|
||||
name ??= TProvider.Name;
|
||||
return provider.GetRequiredKeyedService<TProvider>(name);
|
||||
}
|
||||
|
||||
public ProviderOptions GetProviderOptions<TProvider>(string? name = null)
|
||||
where TProvider : IProvider
|
||||
{
|
||||
name ??= TProvider.Name;
|
||||
return provider
|
||||
.GetRequiredService<IOptionsMonitor<ProviderOptions>>()
|
||||
.Get(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user