| | | 1 | | using Intentum.AI.Embeddings; |
| | | 2 | | using Intentum.AI.Similarity; |
| | | 3 | | using Intentum.Core.Contracts; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | using Microsoft.Extensions.DependencyInjection; |
| | | 6 | | |
| | | 7 | | namespace Intentum.AI.Mistral; |
| | | 8 | | |
| | | 9 | | [UsedImplicitly] |
| | | 10 | | public static class MistralServiceCollectionExtensions |
| | | 11 | | { |
| | | 12 | | [UsedImplicitly] |
| | | 13 | | public static IServiceCollection AddIntentumMistral( |
| | | 14 | | this IServiceCollection services, |
| | | 15 | | MistralOptions options) |
| | 0 | 16 | | { |
| | 0 | 17 | | options.Validate(); |
| | 0 | 18 | | services.AddSingleton(options); |
| | 0 | 19 | | var httpClient = new HttpClient { BaseAddress = new Uri(options.BaseUrl!) }; |
| | 0 | 20 | | httpClient.DefaultRequestHeaders.Authorization = |
| | 0 | 21 | | new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", options.ApiKey); |
| | 0 | 22 | | services.AddSingleton(httpClient); |
| | 0 | 23 | | services.AddSingleton<IIntentEmbeddingProvider>(sp => |
| | 0 | 24 | | new MistralEmbeddingProvider(options, sp.GetRequiredService<HttpClient>())); |
| | 0 | 25 | | services.AddSingleton<IIntentSimilarityEngine, SimpleAverageSimilarityEngine>(); |
| | 0 | 26 | | services.AddSingleton<IIntentModel, MistralIntentModel>(); |
| | | 27 | | |
| | 0 | 28 | | return services; |
| | 0 | 29 | | } |
| | | 30 | | } |