NeuralTrust 1.0.12

dotnet add package NeuralTrust --version 1.0.12
                    
NuGet\Install-Package NeuralTrust -Version 1.0.12
                    
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="NeuralTrust" Version="1.0.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NeuralTrust" Version="1.0.12" />
                    
Directory.Packages.props
<PackageReference Include="NeuralTrust" />
                    
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 NeuralTrust --version 1.0.12
                    
#r "nuget: NeuralTrust, 1.0.12"
                    
#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 NeuralTrust@1.0.12
                    
#: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=NeuralTrust&version=1.0.12
                    
Install as a Cake Addin
#tool nuget:?package=NeuralTrust&version=1.0.12
                    
Install as a Cake Tool

NeuralTrust SDK

The NeuralTrust SDK provides a convenient way to interact with the NeuralTrust API. It allows you to create and send traces asynchronously.

Installation

To install the SDK, add the following package references to your project:

<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />

Usage

Initialization

First, initialize the NeuralTrustClient with your API key:

using NeuralTrust;

var apiKey = "YOUR_API_KEY";
var client = new NeuralTrustClient(apiKey);

You can also set the baseUrl and timeoutInSeconds if needed:

var client = new NeuralTrustClient(apiKey);

Creating and Sending Traces

To create a new trace:

var trace = client.CreateTrace(
    conversationId: "conv_1234",
    sessionId: "sess_123",
    user: new User { UserId = "user_123" },
    metadata: new Metadata
    {
        UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
        Timezone = "America/New_York"
    }
);

To end the trace and send it to the API:

// Simulate a user sending a message and the bot generating a response
trace.Generation("Hello, how are you?");
trace.End("I'm good, thank you!");

// Simulate a user asking for their name and the bot retrieving it
trace.Retrieval("What is my name?");
var retrievalResponse = JsonSerializer.Serialize(new
{
    results = new[]
    {
        new { name = "John Doe", similarity = 0.95 },
        new { name = "Jane Smith", similarity = 0.82 },
        new { name = "John Smith", similarity = 0.78 }
    }
});
trace.End(retrievalResponse);

// Simulate a routing decision based on user input
trace.Router("What is my name?");
var routerResponse = JsonSerializer.Serialize(new
{
    route = "name_agent",
    confidence = 0.95m,
    metadata = new
    {
        intent = "name_inquiry",
        entities = new[] { "name" }
    }
});
trace.End(routerResponse);

Metadata Class

The Metadata class allows you to provide additional information about the user's environment. Here are the available options:

  • UserAgent (Optional[string]): The user agent string of the browser. If provided, Os and Browser can be inferred and are not necessary.
  • Timezone (Optional[string]): The timezone of the user. If provided, Location can be inferred and is not necessary.
  • Browser (Optional[string]): The browser used by the user.
  • Device (Optional[string]): The device used by the user.
  • Os (Optional[string]): The operating system of the user's device.
  • Locale (Optional[string]): The locale of the user.
  • Location (Optional[string]): The location of the user.

User Class

The User class allows you to provide information about the user. Here are the available options:

  • UserId (Optional[string]): The unique identifier of the user.
  • UserEmail (Optional[string]): The email address of the user.
  • UserPhone (Optional[string]): The phone number of the user.

Full Example

Here is a full example of how to interact with the SDK:

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NeuralTrust;
using NeuralTrustApi;

namespace NeuralTrustExample
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var apiKey = "YOUR_API_KEY";
            var client = new NeuralTrustClient(apiKey);

            // Create a new trace
            var trace = client.CreateTrace(
                conversationId: "1234",
                sessionId: "123",
                user: new User { UserId = "123" },
                metadata: new Metadata
                {
                    UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
                    Timezone = "America/New_York"
                }
            );

            // Simulate a user sending a message and the bot generating a response
            trace.Generation("Hello, how are you?");
            trace.End("I'm good, thank you!");
            
            // Simulate a user asking for their name and the bot retrieving it
            trace.Retrieval("What is my name?");
            var retrievalResponse = JsonSerializer.Serialize(new
            {
                results = new[]
                {
                    new { name = "John Doe", similarity = 0.95 },
                    new { name = "Jane Smith", similarity = 0.82 },
                    new { name = "John Smith", similarity = 0.78 }
                }
            });
            trace.End(retrievalResponse);

            // Simulate a routing decision based on user input
            trace.Router("What is my name?");
            var routerResponse = JsonSerializer.Serialize(new
            {
                route = "name_agent",
                confidence = 0.95m,
                metadata = new
                {
                    intent = "name_inquiry",
                    entities = new[] { "name" }
                }
            });
            trace.End(routerResponse);
        }
    }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.