Mythosia.AI 1.6.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Mythosia.AI --version 1.6.0                
NuGet\Install-Package Mythosia.AI -Version 1.6.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mythosia.AI" Version="1.6.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mythosia.AI --version 1.6.0                
#r "nuget: Mythosia.AI, 1.6.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mythosia.AI as a Cake Addin
#addin nuget:?package=Mythosia.AI&version=1.6.0

// Install Mythosia.AI as a Cake Tool
#tool nuget:?package=Mythosia.AI&version=1.6.0                

Mythosia.AI

Package Summary

The Mythosia.AI library provides an abstraction for various AI models, including support for OpenAI GPT-4, Anthropic Claude, and DeepSeek, Sonar models. This library allows easy interaction with AI services, enabling both synchronous completion and streaming capabilities for models like GPT-3.5, GPT-4, Claude, DeepSeek, and more.

Supported Models

  • OpenAI GPT-4 and GPT-4 Turbo, GPT-3.5 Turbo
  • Claude 3.x variants (Claude3_5Sonnet, Claude3Opus, Claude3Haiku)
  • DeepSeek models (deepseek-chat, deepseek-reasoner)
  • Sonar models (sonar, sonar-pro, sonar-reasoning)

Key Features

  • Synchronous completion and streaming support for AI models
  • Customizable model selection, temperature, and max tokens
  • Abstraction over the complexity of managing HTTP requests and responses
  • Extendable structure for adding support for new AI models

How to Use

allocation

using Mythosia.AI;
using System.Net.Http;

var httpClient = new HttpClient();

var aiService = new ChatGptService("your_openai_api_key", httpClient);
var aiService = new ClaudeService("your_anthropic_api_key", httpClient);
var aiService = new DeepSeekService("your_deepseek_api_key", httpClient);
var aiService = new SonarService("your_sonar_api_key", httpClient);

completion

string response = await aiService.GetCompletionAsync("What is AI?");

Model Switching Example

// Add to existing ChatBlock usage
aiService.ActivateChat.ChangeModel(AIModel.Gpt4oLatest);
aiService.ActivateChat.ChangeModel("o1-2024-12-17"); // change with string

Streaming Responses

await aiService.StreamCompletionAsync("Explain quantum computing", content => {
Console.WriteLine(content);
});

ASP.NET Core Integration

public void ConfigureServices(IServiceCollection services)
{
    services.AddHttpClient();
    
    // Existing registrations
    services.AddScoped<ChatGptService>(sp => 
        new ChatGptService("openai_key", sp.GetRequiredService<HttpClient>()));
    
    services.AddScoped<ClaudeService>(sp => 
        new ClaudeService("claude_key", sp.GetRequiredService<HttpClient>()));
    
    // DeepSeek registration
    services.AddScoped<DeepSeekService>(sp => 
        new DeepSeekService("deepseek_key", sp.GetRequiredService<HttpClient>()));
}

Service Usage in Controllers

public class AIController : ControllerBase
{
    // Existing services
    private readonly ChatGptService _chatGptService;
    private readonly ClaudeService _claudeService;
    
    // DeepSeek addition
    private readonly DeepSeekService _deepseekService;

    public AIController(ChatGptService chatGptService, 
                       ClaudeService claudeService,
                       DeepSeekService deepseekService)
    {
        _chatGptService = chatGptService;
        _claudeService = claudeService;
        _deepseekService = deepseekService;
    }

    // Add new endpoint
    [HttpPost("deepseek-completion")]
    public async Task<IActionResult> GetDeepSeekCompletion([FromBody] string prompt)
    {
        var result = await _deepseekService.GetCompletionAsync(prompt);
        return Ok(result);
    }
}

Conclusion

The Mythosia.AI library simplifies integration with AI services, offering a unified API for OpenAI's GPT, Anthropic's Claude, and DeepSeek models. It provides support for real-time streaming and synchronous completion across all integrated services.

ASP.NET Core Integration

public void ConfigureServices(IServiceCollection services)
{
    services.AddHttpClient();
    
    // Existing registrations
    services.AddScoped<ChatGptService>(sp => 
        new ChatGptService("openai_key", sp.GetRequiredService<HttpClient>()));
    
    services.AddScoped<ClaudeService>(sp => 
        new ClaudeService("claude_key", sp.GetRequiredService<HttpClient>()));
    
    // DeepSeek registration
    services.AddScoped<DeepSeekService>(sp => 
        new DeepSeekService("deepseek_key", sp.GetRequiredService<HttpClient>()));
}

Service Usage in Controllers

public class AIController : ControllerBase
{
    // Existing services
    private readonly ChatGptService _chatGptService;
    private readonly ClaudeService _claudeService;
    
    // DeepSeek addition
    private readonly DeepSeekService _deepseekService;

    public AIController(ChatGptService chatGptService, 
                       ClaudeService claudeService,
                       DeepSeekService deepseekService)
    {
        _chatGptService = chatGptService;
        _claudeService = claudeService;
        _deepseekService = deepseekService;
    }

    // Add new endpoint
    [HttpPost("deepseek-completion")]
    public async Task<IActionResult> GetDeepSeekCompletion([FromBody] string prompt)
    {
        var result = await _deepseekService.GetCompletionAsync(prompt);
        return Ok(result);
    }
}

Conclusion

The Mythosia.AI library simplifies integration with AI services, offering a unified API for OpenAI's GPT, Anthropic's Claude, and DeepSeek models. It provides support for real-time streaming and synchronous completion across all integrated services.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.7.1 65 2/3/2025
1.7.0 39 2/2/2025
1.6.0 5 1/29/2025
1.5.0 37 1/26/2025
1.4.0 67 12/9/2024
1.3.2 69 11/25/2024
1.3.1 81 10/21/2024
1.3.0 67 10/8/2024
1.2.1 66 9/27/2024
1.2.0 68 9/26/2024
1.1.1 72 9/24/2024
1.1.0 66 9/22/2024
1.0.0 107 9/22/2024