Mythosia 1.4.0

dotnet add package Mythosia --version 1.4.0
                    
NuGet\Install-Package Mythosia -Version 1.4.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" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mythosia" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Mythosia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mythosia --version 1.4.0
                    
#r "nuget: Mythosia, 1.4.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.
#:package Mythosia@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mythosia&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Mythosia&version=1.4.0
                    
Install as a Cake Tool

Mythosia

This project supports custom functions that are not directly provided by .NET as extension methods so that they can be conveniently used within the project. <br/> The extensions supported by this project include the following. <br/>

To string or To Byte array

using Mythosia;

var data = "=".Repeat(10); // data is "=========="

var data = "12345".ToDefaultArray(); // Equal with Encoding.Default.GetBytes("12345");
var data = "12345".ToASCIIArray(); // Equal with Encoding.ASCII.GetBytes("12345");
var data = "12345".ToUTF8Array(); // Equal with Encoding.UTF8.GetBytes("12345");
var data = "12345".ToUTF32Array(); // Equal with Encoding.UTF32.GetBytes("12345");

IEnumerable<byte> data = new List<byte>() { 0x45, 0x46, 0x47, 0x48, 0x49 };
var result = data.AsOrToArray(); // if data is byte[] then return data (O(1)) else return data.ToArray() (O(n));

data.ToDefaultString(); // Equal with Encoding.Default.GetString(data.AsOrToByteArray(), 0, data.Count());
data.ToASCIIString(); // Equal with Encoding.ASCII.GetString(data.AsOrToByteArray(), 0, data.Count());
data.ToUTF8String(); // Equal with Encoding.UTF8.GetString(data.AsOrToByteArray(), 0, data.Count());
data.ToUTF32String(); // Equal with Encoding.UTF32.GetString(data.AsOrToByteArray(), 0, data.Count());

To numeric string (sbyte, byte, short, ushort, int, uint, float, double)

using Mythosia;

var result = 56.IsInRange(0, 100);  // result is true 
var result = 56.IsInRange(0, 30);   // result is false

// see https://m.blog.naver.com/alluck/220931066035
var data = 56000000.ToSIPrefix();   // data is "56 M"  (find the unit that can present the best simple)
var data = 56000000.ToSIPrefix(SIPrefixUnit.Kilo); // data is "56000 k"
var data = 56000000.ToSIPrefix(SIPrefixUnit.Giga, 5); // data is "0.056 G"  (the second param means the maximum number of digits after decimal point)

var data = 1.4235123.ToSIPrefix();  // data is "1.42"  (find the unit that can present the best simple)
var data = 1.4235123.ToSIPrefix(SIPrefixUnit.Mili);  // data is "1423.51 m"
var data = 1.4235123.ToSIPrefix(SIPrefixUnit.Mili, 5);  // data is "1423.5123 m" 
var data = 1.4235123.ToSIPrefix(SIPrefixUnit.Micro);  // data is "1423512.3 u"

var data = 423.42031.HostToNetworkEndian();	// change endian (host to big)
var data = 234.52.ToByteArray();	// Equal with BitConverter.GetBytes(234.52);

To Numeric array (ushort, uint, ulong)

using Mythosia;

List<byte> test = new List<byte>() { 10, 16, 15, 30, 45, 65, 90, 32 };

// if system endian is little endian then result is 0x100a, 0x1e0f, 0x412d, 0x205a
// if system endian is big endian then result is 0x0a10, 0x0f1e, 0x2d41, 0x5a20
var result = test.ToUShortArray();

// if system endian is little endian then result is 0x1e0f100a, 0x205a412d
// if system endian is big endian then result is 0x0a100f1e, 0x2d415a20
var result = test.ToUIntArray();

// if system endian is little endian then result is 0x205a412d1e0f100a
// if system endian is big endian then result is 0x0a100f1e2d415a20
var result = test.ToULongArray();

Notation

using Mythosia;

private List<byte> test = new List<byte>() { 10, 16, 15, 30, 45, 65 };

// binary
test.ToBinaryString();  // result is "000010100001000000001111000111100010110101000001"
test.ToBinaryString(BinaryPartitionSize.Bit2) // result is "00 00 10 10 00 01 00 00 00 00 11 11 00 01 11 10 00 10 11 01 01 00 00 01"
test.ToBinaryString(BinaryPartitionSize.HalfByte) // result is "0000 1010 0001 0000 0000 1111 0001 1110 0010 1101 0100 0001"
test.ToBinaryString(BinaryPartitionSize.Byte) // result is "00001010 00010000 00001111 00011110 00101101 01000001"
test.ToBinaryString(BinaryPartitionSize.Byte, "0b") // result is "0b00001010 0b00010000 0b00001111 0b00011110 0b00101101 0b01000001"

// hex
var result = test.ToHexStringL();  // result is  "0a100f1e2d41"
var result = test.ToHexStringL(HexPartitionSize.Byte);  // result is "0a 10 0f 1e 2d 41
var result = test.ToHexStringL(HexPartitionSize.Byte2); // result is "0a10 0f1e 2d41"

var result = test.ToHexStringU(HexPartitionSize.Byte2);  // result is "0A10 0F1E 2D41"
var result = test.ToHexStringU(HexPartitionSize.Byte2, "0x");  // result is "0x0A10 0x0F1E 0x2D41"
var result = test.ToHexStringU(HexPartitionSize.Byte2, "", "h");  // result is "0A10h 0F1Eh 2D41h"

Enumerable (included ConcurrentBag)

var result = test.ToEncodedString(Encoding.GetEncoding("ISO-8859-1"));		// convert string as "ISO-8859-1" format
var result = test.ToASCIIString();	// equal with Encoding.ASCII.GetString(test.ToArray(), 0, test.Count());

var result = test.IndexOf(new List(){ 0xab, 0x01 });	// return the index that subsequence is finded.
test.AddExceptNull(item);					// add item if item is not null

new List<byte> newItems = new List<bye>(){ 0x01, 0x02 };
test.AddRangeParallel(newItems);    // add items as parallel

Delegate

using Mythosia;

// If you have a function that success or fails according to condition as below.
bool WireConnect()
{
    // Check whether the wire is connected
    // If connected to wire return true else false.
}


// Here you may want to call the function to repeat to specified timeout.
// Then you can solute just by calling the function "RetryIfFailed" as below. 
void Test()
{
    var func = WireConnect;             // you need c# 10.0
    bool result = func.RetryIfFailed(30000);      // Call WireConnect function to repeat while a maximum of 30,000 ms (the 30s) or until success

    if(result) Console.WriteLine("Success");
    else Console.WriteLine("Failed");
}

Stream

using Mythosia;

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class TestMarshalClass
{
    public int a;
    public int b;
}

TestMarshalClass test = new();

var serializeData = test.SerializeUsingMarshal();   // Serialize
test.DeSerializeUsingMarshal(serializeData);    // Deserialize to test

Enum

using Mythosia;

public enum CarBrand
{
    [Description("Mercedes")] Benz = 0,
    [Description("Bayerische Motoren Werke AG")] BMW,
}

CarBrand test = CarBrand.Benz;
var value = test.ToDescription();   // value is "Mercedes"
var enum = value.GetEnumFromDescription<CarBrand>();   // enum is CarBrand.Benz

int carBrand = 1;
var result = carBrand.ToEnum<CarBrand>();   // result is CarBrand.BMW
var result = "BMW".GetEnumFromName<CarBrand>();  // result is CarBrand.BMW

Json Serialize, Deserialize

using Mythosia;


public class TestClass
{
    public int A { get; set; } = 10;
    public string B { get; set; } = string.Empty;
}


var testClass = new TestClass();

// serialize, deserialize with System.Text.Json
var jsonString = testClass.ToJsonStringS();
var compareClass = jsonString.FromJsonStringS<TestClass>();


// serialize, deserialize with Newtonsoft.Json
var jsonString = testClass.ToJsonStringN();
var compareClass = jsonString.FromJsonStringN<TestClass>();

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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (4)

Showing the top 4 NuGet packages that depend on Mythosia:

Package Downloads
Mythosia.AI

## 🚀 What's New in v3.0.0 ### Major Features - **Function Calling**: AI models can now execute your custom functions during conversations - **Enhanced Streaming**: New StreamingContent with metadata support and real-time function execution - **Policy System**: Control function execution with timeouts, retry logic, and concurrency limits - **Attribute-Based Functions**: Register methods with [AiFunction] and [AiParameter] attributes - **Fluent Function Builder**: Chain function definitions with builder pattern ### Function Calling Support - ✅ **OpenAI**: GPT-4o, GPT-4.1, o3 series (full support) - ✅ **Anthropic**: Claude 3/4 series (native tool use) - 🔜 **Coming Soon**: GPT-5, Gemini (planned for next update) - Build AI assistants that can send emails, query databases, call APIs, and more! ## Comprehensive AI Model Support - **OpenAI**: GPT-5*, GPT-4.1, GPT-4o, o3 series (*function calling coming soon) - **Anthropic**: Claude 4 (Opus 4.1, Sonnet 4), Claude 3.7, Claude 3.5 - **Google**: Gemini 2.5 Pro/Flash, Gemini 2.0, Gemini 1.5 - **DeepSeek**: Chat and Reasoner models - **Perplexity**: Sonar with web search and citations ## Key Features - ✅ **Function Calling**: Let AI execute your code (v3.0.0) - ✅ **Streaming 2.0**: IAsyncEnumerable with metadata (v3.0.0) - ✅ **Policy Control**: Timeout and retry management (v3.0.0) - ✅ **Multimodal**: Text + images for vision models - ✅ **Web Search**: Real-time search with citations (Perplexity) - ✅ **Audio**: TTS and STT support (OpenAI) - ✅ **Stateless Mode**: Independent requests without history - ✅ **Fluent API**: Intuitive message builder - ✅ **Token Management**: Precise counting and limits ## Quick Example ```csharp // Define functions that AI can call var service = new ChatGptService(apiKey) .WithFunction("get_weather", "Gets weather for a city", ("city", "City name", required: true), city => $"Weather in {city}: Sunny, 22°C") .WithFunction("send_email", "Sends an email", ("to", "Recipient", true), ("subject", "Subject", true), async (to, subject) => await EmailService.SendAsync(to, subject)); // AI automatically calls functions as needed var response = await service.GetCompletionAsync( "What's the weather in Seoul? If sunny, email john@example.com" ); // AI will: 1) Call get_weather("Seoul") // 2) Check if sunny // 3) Call send_email() if condition met // 4) Provide natural language response // Stream with real-time function execution await foreach (var content in service.StreamAsync(query, StreamOptions.WithFunctions)) { if (content.Type == StreamingContentType.FunctionCall) Console.WriteLine($"Calling: {content.Metadata["function_name"]}"); else if (content.Type == StreamingContentType.Text) Console.Write(content.Content); } ``` ## Documentation - Basic Usage: https://github.com/AJ-comp/Mythosia/wiki - Advanced Features: https://github.com/AJ-comp/Mythosia/wiki/Advanced-Features - GitHub: https://github.com/AJ-comp/Mythosia

Mythosia.Integrity

From this version, you can use the polymorphism. Please see the GitHub readme file. support checksum8: 1. xor (using in NMEA format) 2. modulo-256 3. 2's complement support CRC8: 1. CRC8 2. CRC8 Maxim support CRC16: 1. CRC16 2. CRC16 (modbus) 3. CRC16 CCITT (xModem) 4. CRC16 DNP support CRC32 1. CRC32

Mythosia.Azure.Storage.Blobs

**New Features**: This update introduces an extension method to automatically convert strings into valid Azure Blob Storage container names. Azure Blob Storage imposes strict naming rules requiring lowercase letters, numbers, and hyphens, with specific constraints on hyphen placement and name length. This new feature ensures that container names comply with these rules by transforming arbitrary input strings into valid container names seamlessly. **Key Benefits**: - Converts camelCase or PascalCase strings to lowercase with hyphens automatically. - Replaces disallowed characters with hyphens, ensuring valid naming conventions. - Handles name length constraints (minimum 3 characters, maximum 63 characters). - Simplifies compliance with Azure Blob Storage naming standards, reducing errors and improving consistency. **Usage Example**: ```csharp using Mythosia.Azure.Storage.Blobs; // Convert a string to a valid container name string validName = "PhonoMaster@123".ToBlobContainerName(); // Output: "phono-master-123" ```

Mythosia.Security.Cryptography

support symmetric algorithm 1. AES128 2. AES192 3. AES256 4. 3DES 5. DES 6. SEED support HashCode for IV (Integrity Verification) 1. SHA1 2. SHA256 3. SHA384 4. SHA512 5. MD2 6. MD4 7. MD5 refer to https://github.com/AJ-comp/Mythosia/tree/master/Mythosia.Security.Cryptography for detail.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 495 11/9/2024
1.3.0 124 10/25/2024
1.2.4 134 10/23/2024
1.2.3 350 6/17/2024
1.2.2 1,116 10/16/2023
1.2.1 1,151 8/20/2023
1.2.0 2,419 8/9/2023
1.1.5 1,211 7/17/2023
1.1.4 1,210 7/3/2023
1.1.3 1,243 7/3/2023
1.1.2 1,110 6/28/2023
1.1.1 1,370 6/25/2023
1.1.0 1,172 6/23/2023
1.0.3 1,183 6/23/2023
1.0.2 1,147 6/21/2023
1.0.1 1,372 6/19/2023
1.0.0 1,264 6/18/2023