Ikon.Sdk.DotNet 1.30.0.919

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ikon.Sdk.DotNet --version 1.30.0.919                
NuGet\Install-Package Ikon.Sdk.DotNet -Version 1.30.0.919                
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="Ikon.Sdk.DotNet" Version="1.30.0.919" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ikon.Sdk.DotNet --version 1.30.0.919                
#r "nuget: Ikon.Sdk.DotNet, 1.30.0.919"                
#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 Ikon.Sdk.DotNet as a Cake Addin
#addin nuget:?package=Ikon.Sdk.DotNet&version=1.30.0.919

// Install Ikon.Sdk.DotNet as a Cake Tool
#tool nuget:?package=Ikon.Sdk.DotNet&version=1.30.0.919                

Ikon AI C# SDK

Welcome to the Ikon AI C# SDK. This SDK is designed to help developers integrate and interact with Ikon's services easily using C#. The SDK provides a straightforward API to manage channels, handle events, communicate, and interact with the AI agent within the Ikon platform.

Features

  • Initialize clients with developer credentials
  • Connect to and manage multiple channels
  • Send and receive text messages within channels
  • Send and receive audio streams
  • Register and handle custom functions callable from the AI agent
  • Manage state variables and message history
  • Event handling for various channel events, including connection, disconnection, and message events

Installation

To start using the Ikon AI C# SDK, include the libraries in your C# project. Ensure that your project is compatible with .NET 8.0 or .NET Standard 2.1.

Usage

Creating an Ikon Client

To create an Ikon client instance, you need an API key, a space ID, and a user ID.

var ikonClientInfo = new Sdk.IkonClientInfo
{
    // Get the API key from the Ikon Portal and then supply it with e.g. environment variable. Do not hardcode it.
    ApiKey = Environment.GetEnvironmentVariable("IKON_SDK_API_KEY") ?? throw new Exception("API key is missing. Please set the 'IKON_SDK_API_KEY' environment variable."),

    // Get the space ID from Ikon Portal. This can be hardcoded.
    SpaceId = Environment.GetEnvironmentVariable("IKON_SDK_SPACE_ID") ?? "<<SET_SPACE_ID_HERE>>",

    // Set a unique ID for the player. This can be the player's ID in your game. This can be hardcoded.
    UserId = Environment.GetEnvironmentVariable("IKON_SDK_USER_ID") ?? "<<SET_USER_ID_HERE>>",

    // Use the production endpoint by default. Set to false to use the development endpoint.
    UseProductionEndpoint = Environment.GetEnvironmentVariable("IKON_SDK_USE_PROD_ENDPOINT")?.Trim().Equals("true", StringComparison.InvariantCultureIgnoreCase) ?? true,

    Description = "Example",
    DeviceId = Utils.GenerateDeviceId(),
    ProductId = "Ikon.Sdk.DotNet.Example",
    VersionId = Version.VersionString,
    InstallId = "1",
    UserType = UserType.Human,
    OpcodeGroupsFromServer = Opcode.GROUP_ALL,
    OpcodeGroupsToServer = Opcode.GROUP_ALL,
};

// Create an Ikon client
var ikonClient = await Sdk.CreateIkonClientAsync(ikonClientInfo);

Managing Channels

Once the client is initialized, you can connect to a channel, send messages, and handle various channel-related events.

// Set the channel key to use
var channelKey = Environment.GetEnvironmentVariable("IKON_SDK_CHANNEL_KEY") ?? "<<SET_CHANNEL_KEY_HERE>>";

// Create or get a channel instance
var channel = Channel.Create(ikonClient, channelKey);

// Subscribe to channel events
channel.Connected += OnChannelConnected;
channel.Stopping += OnChannelStopping;
channel.Disconnected += OnChannelDisconnected;
// Subscribe to other events as needed...

// Connect to the channel
await channel.ConnectAsync();

// Signal readiness to other clients in the channel
channel.SignalReady();

// Wait for the AI agent to become ready
await channel.WaitForAIAgentAsync();

Sending and Receiving Text Messages

To send text messages to a channel and receive messages:

// Sending a text message
channel.SendText("Hello, Ikon!", generateChatMessage: true, sendBackToSender: true);

// Handling received text messages
channel.Text += OnChannelText;

private async Task OnChannelText(object sender, Channel.TextArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine($"\n{e.UserName}: {e.Text}\n");
}

Sending and Receiving Audio Streams

You can send and receive audio streams in real-time.

Sending Audio

To send audio to the channel:

// Prepare your audio samples as a float array
float[] samples = ...; // Your audio samples
int sampleRate = 48000; // Sample rate of your audio
int channels = 1; // Number of audio channels

// Send the audio samples
channel.SendAudio(samples, sampleRate, channels, isFirst: true, isLast: true);

// Optionally, fade out any ongoing audio streams
channel.FadeoutAudio(2.0f); // Fade out over 2 seconds
Receiving Audio

Handle audio stream events to receive audio from the channel:

channel.AudioStreamBegin += OnChannelAudioStreamBegin;
channel.AudioFrame += OnChannelAudioFrame;
channel.AudioStreamEnd += OnChannelAudioStreamEnd;

private async Task OnChannelAudioStreamBegin(object sender, Channel.AudioStreamBeginArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine($"Audio Stream Begin: StreamId={e.StreamId}, SampleRate={e.SampleRate}, Channels={e.Channels}");
}

private async Task OnChannelAudioFrame(object sender, Channel.AudioFrameArgs e)
{
    await Task.CompletedTask;
    // Process the received audio samples
    var samples = e.Samples;
    // ...
}

private async Task OnChannelAudioStreamEnd(object sender, Channel.AudioStreamEndArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine($"Audio Stream End: StreamId={e.StreamId}");
}

Registering Functions for the AI Agent

You can register functions in your code that the AI agent can call during conversation. This allows for dynamic interactions where the AI agent can execute code in your application.

Register a Function
channel.RegisterFunction<int, string, string>("example_function", ExampleFunction);
Define the Function
private async Task<string> ExampleFunction(int argument1, string argument2)
{
    await Task.CompletedTask;
    // Implement your logic here
    return $"Function result: {argument1}, {argument2}";
}

Managing State and Message History

You can set and manage state variables, control message history, and control the AI agent's response generation.

// Set a state variable
channel.SetState("ExampleVariable", 123);

// Clear all state variables
channel.ClearState();

// Instruct the AI agent to generate an answer without providing new input
channel.GenerateAnswer();

// Clear the message history of the whole channel
channel.ClearMessageHistory();

Handling Channel Events

Implement event handlers to manage different channel events, such as connection status, messages, and custom events.

// Subscribe to events
channel.Connected += OnChannelConnected;
channel.Stopping += OnChannelStopping;
channel.Disconnected += OnChannelDisconnected;
channel.Text += OnChannelText;
channel.ClassificationResult += OnChannelClassificationResult;
channel.SpecialLog += OnChannelSpecialLog;
channel.Usage += OnChannelUsage;
channel.AudioStreamBegin += OnChannelAudioStreamBegin;
channel.AudioFrame += OnChannelAudioFrame;
channel.AudioStreamEnd += OnChannelAudioStreamEnd;

// Event handler examples
private async Task OnChannelConnected(object sender, Channel.ConnectedArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine("Connected to the channel");
}

private async Task OnChannelStopping(object sender, Channel.StoppingArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine("Channel is stopping");
}

private async Task OnChannelDisconnected(object sender, Channel.DisconnectedArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine("Disconnected from the channel");
}

private async Task OnChannelClassificationResult(object sender, Channel.ClassificationResultArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine($"Classification Result: {e.Result}");
}

private async Task OnChannelSpecialLog(object sender, Channel.SpecialLogArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine($"Special Log - {e.Title}:\n{e.Message}");
}

private async Task OnChannelUsage(object sender, Channel.UsageArgs e)
{
    await Task.CompletedTask;
    Console.WriteLine($"Usage - {e.UsageName}: {e.Usage}");
}

Helper Functions

The SDK provides several helper functions to manage state and control the AI agent's behavior:

channel.SetState("TestVariable", 1234); // Set a variable defined in the Input section
channel.ClearState(); // Clear all variables from the state
channel.GenerateAnswer(); // Generate an answer without providing any input
channel.ClearMessageHistory(); // Clear the message history of the whole channel
channel.FadeoutAudio(2.0f); // Send a signal to fade out audio streams over 2 seconds

Example Program

An up-to-date example program is included in the Ikon.Sdk.DotNet.Examples.Chat/Program.cs source file. This example demonstrates how to:

  • Initialize the Ikon client
  • Connect to a channel
  • Send and receive text messages
  • Handle various events
  • Register custom functions callable by the AI agent
  • Manage state variables and message history
  • Send and receive audio streams

License

This SDK is licensed under the Ikon AI SDK License. See the LICENSE file for more details.

Support

For support, please open an issue on our GitHub repository or contact our support team through our support channel.

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 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. 
.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.30.0.976 0 3/3/2025
1.30.0.974 6 3/3/2025
1.30.0.968 6 3/3/2025
1.30.0.967 47 3/2/2025
1.30.0.966 44 3/2/2025
1.30.0.965 45 3/2/2025
1.30.0.964 41 3/2/2025
1.30.0.962 47 3/2/2025
1.30.0.957 45 3/2/2025
1.30.0.956 51 3/2/2025
1.30.0.955 46 3/2/2025
1.30.0.953 43 3/2/2025
1.30.0.949 51 3/1/2025
1.30.0.948 48 3/1/2025
1.30.0.945 42 3/1/2025
1.30.0.944 39 3/1/2025
1.30.0.943 38 3/1/2025
1.30.0.941 35 3/1/2025
1.30.0.940 49 2/28/2025
1.30.0.938 51 2/28/2025
1.30.0.936 53 2/27/2025
1.30.0.935 52 2/27/2025
1.30.0.932 47 2/27/2025
1.30.0.931 51 2/27/2025
1.30.0.929 50 2/27/2025
1.30.0.928 49 2/27/2025
1.30.0.927 48 2/26/2025
1.30.0.926 52 2/26/2025
1.30.0.925 44 2/26/2025
1.30.0.924 44 2/26/2025
1.30.0.923 48 2/26/2025
1.30.0.922 42 2/26/2025
1.30.0.921 43 2/26/2025
1.30.0.919 66 2/25/2025
1.30.0.916 66 2/25/2025
1.30.0.915 62 2/25/2025
1.30.0.914 88 2/25/2025
1.30.0.913 78 2/25/2025
1.30.0.912 70 2/25/2025
1.30.0.910 69 2/25/2025
1.30.0.909 71 2/25/2025
1.30.0.908 76 2/25/2025
1.30.0.906 73 2/25/2025
1.30.0.904 70 2/25/2025
1.30.0.900 75 2/25/2025
1.30.0.897 76 2/24/2025
1.30.0.895 73 2/24/2025
1.30.0.894 66 2/24/2025
1.30.0.893 71 2/24/2025
1.30.0.892 81 2/24/2025
1.30.0.891 84 2/24/2025
1.30.0.890 76 2/23/2025
1.30.0.888 79 2/22/2025
1.30.0.886 81 2/22/2025
1.30.0.885 78 2/22/2025
1.30.0.884 79 2/22/2025
1.30.0.882 82 2/22/2025
1.30.0.881 85 2/22/2025
1.30.0.880 87 2/21/2025
1.30.0.879 80 2/21/2025
1.30.0.877 83 2/21/2025
1.30.0.875 83 2/21/2025
1.30.0.874 81 2/21/2025
1.30.0.873 81 2/21/2025
1.30.0.872 85 2/21/2025
1.30.0.871 93 2/21/2025
1.30.0.870 80 2/21/2025
1.30.0.869 84 2/21/2025
1.30.0.868 82 2/21/2025
1.30.0.864 79 2/21/2025
1.30.0.863 80 2/21/2025
1.30.0.861 84 2/20/2025
1.30.0.856 87 2/20/2025
1.30.0.855 79 2/20/2025
1.30.0.854 74 2/20/2025
1.30.0.853 84 2/20/2025
1.30.0.852 80 2/20/2025
1.30.0.851 85 2/20/2025
1.30.0.847 80 2/20/2025
1.30.0.846 77 2/20/2025
1.30.0.845 81 2/20/2025
1.30.0.841 84 2/20/2025
1.30.0.840 83 2/20/2025
1.30.0.839 84 2/19/2025
1.30.0.838 80 2/19/2025
1.30.0.837 76 2/19/2025
1.30.0.836 88 2/19/2025
1.30.0.833 91 2/19/2025
1.30.0.831 75 2/19/2025
1.30.0.829 76 2/19/2025
1.30.0.828 92 2/19/2025
1.30.0.827 86 2/19/2025
1.30.0.826 76 2/19/2025
1.30.0.825 80 2/19/2025
1.30.0.824 89 2/19/2025
1.30.0.823 83 2/19/2025
1.30.0.822 87 2/19/2025
1.30.0.821 81 2/19/2025
1.30.0 114 12/31/2024
1.29.0 100 11/10/2024
1.28.0 117 9/18/2024
1.27.0 129 9/16/2024
1.26.0 110 9/5/2024
1.25.0 141 8/24/2024
1.24.0 143 8/22/2024
1.23.0 133 8/16/2024
1.22.0 124 8/15/2024
1.21.0 120 8/15/2024
1.20.0 86 8/2/2024
1.19.0 92 8/1/2024
1.18.0 93 8/1/2024
1.17.0 84 7/31/2024
1.16.0 95 7/30/2024
1.15.0 91 7/30/2024
1.14.0 86 7/30/2024
1.13.0 89 7/30/2024