Skip to content

Repository files navigation

Build and Test Bugs Coverage Status

JevDotNet

JevDotNet is an opinionated, convention-based .NET client for the Jev API by TypeSafe AI.

NuGet Wiki Changelog YouTube API Reference

Quick start

Watch this video, or follow steps below.

Step 1

Define your return object and decorate its properties with the Jev attributes (Choice, Score, or Noul).

  • Each attributed property defines one question sent to Jev
  • The property types can be either simple or detailed types
using System.ComponentModel;
using JevDotNet;
using JevDotNet.Models;

public class MyJevReturnObject
{
    [JevChoiceQuestion<Category>("What is the primary category?")]
    public Category? Category { get; set; }

    [JevScoreQuestion<Severity>("How severe is the reported impact?")]
    public JevScore<Severity>? Severity { get; set; }

    [JevNoulQuestion("Is the product broken?", threshold: 0.7)]
    public bool? IsBroken { get; set; }
}

public enum Category
{
    [Description("Questions about using or troubleshooting the product")]
    Technical,

    [Description("Questions about invoices, payments, or subscriptions")]
    Billing,

    Other
}

public enum Severity
{
    Cosmetic,
    Degraded,
    Blocking
}

Step 2

Create a client and evaluate some text:

JevClient client = new JevClient("<api-key>");

string input = "The customer cannot sign in after resetting their password.";
JevResponse<MyJevReturnObject> response = await client.EvaluateAsync<MyJevReturnObject>(input);

MyJevReturnObject myReturnObject = response.Result;

Category? category = myReturnObject.Category;
double? severity = myReturnObject.Severity.Score;
bool? isBroken = myReturnObject.IsBroken;

Question types

Choice

[JevChoiceQuestion<TEnum>] returns one enum member:

[JevChoiceQuestion<Category>("What is the primary category?")]
public Category? Category { get; set; }

or

[JevChoiceQuestion<Category>("What is the primary category?")]
public JevChoice<Category>? Category { get; set; }

Score

[JevScoreQuestion<TEnum>] uses an enum with 2–10 members as an ordered scale. The members are ordered by their underlying numeric values and mapped to levels 0, 1, 2, and so on. Use double, decimal, or their nullable forms for only the score:

[JevScoreQuestion<Severity>("How severe is this?")]
public double? Severity { get; set; }

or

[JevScoreQuestion<Severity>("How severe is this?")]
public JevScore<Severity>? Severity { get; set; }

Noul

[JevNoulQuestion] returns a probability from 0 to 1. Use double, decimal or JevNoul to receive the probability.

Boolean properties default to true at 0.5 or above. Configure the inclusive threshold on the question itself:

[JevNoulQuestion("Is the product broken?", threshold: 0.7)]
public bool? IsBroken { get; set; }

Custom client configuration

For custom configuration, construct the client with JevClientOptions:

HttpClient httpClient = new HttpClient();

var client = new JevClient(new JevClientOptions
{
    ApiKey = apiKey,
    Model = "jev-latest",
    Endpoint = new Uri("https://api.typesafe.ai/v1/systemone"),
    HttpClientFactory = () => httpClient
});

About

An opinionated and convention-based .NET implementation of the Jev Classification AI by TypeSafeAI

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages