EchoCoders.AIServiceWrapper
1.0.0
dotnet add package EchoCoders.AIServiceWrapper --version 1.0.0
NuGet\Install-Package EchoCoders.AIServiceWrapper -Version 1.0.0
<PackageReference Include="EchoCoders.AIServiceWrapper" Version="1.0.0" />
<PackageVersion Include="EchoCoders.AIServiceWrapper" Version="1.0.0" />
<PackageReference Include="EchoCoders.AIServiceWrapper" />
paket add EchoCoders.AIServiceWrapper --version 1.0.0
#r "nuget: EchoCoders.AIServiceWrapper, 1.0.0"
#addin nuget:?package=EchoCoders.AIServiceWrapper&version=1.0.0
#tool nuget:?package=EchoCoders.AIServiceWrapper&version=1.0.0
EchoCoders.AIServiceWrapper
The EchoCoders.AIServiceWrapper
is a .NET library that provides an easy-to-use interface for interacting with OpenAI services. This library allows you to compare content similarity, summarize text, and extract tags from text using OpenAI's API.
Installation
You can install the package via NuGet:
Usage
Configuration
First, configure the OpenAIOptions
in your appsettings.json
:
Dependency Injection
Register the OpenAIService
and its dependencies in your Startup.cs
or Program.cs
:
Full Code to Register OpenAI service
builder.Services.AddHttpClient("YourHttpClientName");
builder.Services.Configure<OpenAIOptions>(builder.Configuration.GetSection("YourOpenAISectionName"));
builder.Services.AddScoped<IAIService, OpenAIService>();
/*
"YourOpenAISectionName":{
APIKey: "your-open-AI-api-key",
URL: "api-url",//optional
Model:"your-model-name"//optional
}
*/
EchoCoders.AIServiceWrapper.DependencyInjection
There is a supplementary package which covers dependency injection in .NET Core framework. To inject the depdency you need to call following methods:
services.AddOpenAIService(options =>
{
options.APIKey = "your-api-key";
options.URL = "api-url";//optional
options.Model= "your-model-name";//optional
});
The AddOpenAIService
method allows you to configure the OpenAIOptions
using a configuration action. Here are some of the properties you can configure:
ApiKey
: The API key for accessing OpenAI services.URL
: The base URL for the OpenAI API (optional, defaults to the official OpenAI API URL).Model
: The model name to use for the OpenAI service (optional, defaults to the default model).`
Using the Service
Inject the IAIService
into your class and use its methods:
Methods
AreContentsSimilarAsync
Compares the similarity between two content strings.
var similarity = await _aiService.AreContentsSimilarAsync("Source Text", "Destination Text",.8);
GetSummarizedTextAsync
Summarizes the given input text based on the provided user prompt.
var summary = await _aiService.GetSummarizedTextAsync("input text", "Summarize this text within 50 words");
GetTagsFromTextAsync
Extracts tags from the given input text based on the provided user prompt.
var tags = await _aiService.GetTagsFromTextAsync("input text", "Extract tags from this text");
License
This project is licensed under the MIT License.
Supported .NET versions
.NET 8 and upper
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EchoCoders.AIServiceWrapper:
Package | Downloads |
---|---|
EchoCoders.AIServiceWrapper.DependencyInjection
Dependency Injection extensions for EchoCoders AI Service Wrapper |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 85 | 3/14/2025 |