< Summary

Information
Class: Intentum.AI.OpenAI.OpenAIServiceCollectionExtensions
Assembly: Intentum.AI.OpenAI
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.AI.OpenAI/OpenAIServiceCollectionExtensions.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 30
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
AddIntentumOpenAI(...)100%11100%

File(s)

/home/runner/work/Intentum/Intentum/src/Intentum.AI.OpenAI/OpenAIServiceCollectionExtensions.cs

#LineLine coverage
 1using Intentum.AI.Embeddings;
 2using Intentum.AI.Similarity;
 3using Intentum.Core.Contracts;
 4using JetBrains.Annotations;
 5using Microsoft.Extensions.DependencyInjection;
 6
 7namespace Intentum.AI.OpenAI;
 8
 9[UsedImplicitly]
 10public static class OpenAIServiceCollectionExtensions
 11{
 12    [UsedImplicitly]
 13    public static IServiceCollection AddIntentumOpenAI(
 14        this IServiceCollection services,
 15        OpenAIOptions options)
 116    {
 117        options.Validate();
 118        services.AddSingleton(options);
 119        var httpClient = new HttpClient { BaseAddress = new Uri(options.BaseUrl!) };
 120        httpClient.DefaultRequestHeaders.Authorization =
 121            new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", options.ApiKey);
 122        services.AddSingleton(httpClient);
 123        services.AddSingleton<IIntentEmbeddingProvider>(sp =>
 224            new OpenAIEmbeddingProvider(options, sp.GetRequiredService<HttpClient>()));
 125        services.AddSingleton<IIntentSimilarityEngine, SimpleAverageSimilarityEngine>();
 126        services.AddSingleton<IIntentModel, OpenAIIntentModel>();
 27
 128        return services;
 129    }
 30}