-
Notifications
You must be signed in to change notification settings - Fork 1
Jev Noul
Use Noul for one yes/no proposition, such as “Is the customer asking for a human agent?” The API returns a number from 0 to 1 representing the probability of yes. It is not a severity or intensity scale. Use Score for degree and Choice for one of several named options.
In JevDotNet, [JevNoulQuestion] defines the proposition. Your property can keep the probability, convert it to a Boolean at a threshold, or keep a JevNoul record with convenience methods.
using JevDotNet.Models;
public sealed class SupportSignals
{
[JevNoulQuestion("Is the customer asking to speak with a person?")]
public double? WantsHumanProbability { get; set; }
}The property name WantsHumanProbability becomes the question ID in the request and answer ID in the response. The text in the attribute becomes the API's instructions; it must not be blank. A statement such as “The customer requests a refund” also works. Phrase it so a high probability consistently means yes. Split compound questions into separate Noul properties and combine the results in C#.
| Property type | What you get |
|---|---|
double, double?, decimal, or decimal?
|
The raw probability of yes. |
bool or bool?
|
true when the probability is at least the attribute's threshold. |
JevNoul or JevNoul?
|
A record with Probability, Value, and IsAtLeast(threshold). |
JevNoul does not have a separate Confidence field. A nullable property is convenient before evaluation; a successful answer still supplies a value. The property must be public and writable.
This complete example needs the NuGet package and a TypeSafe AI key in JEV_API_KEY:
using System;
using JevDotNet;
using JevDotNet.Models;
string apiKey = Environment.GetEnvironmentVariable("JEV_API_KEY")
?? throw new InvalidOperationException("Set JEV_API_KEY first.");
JevClient client = new(apiKey);
JevResponse<SupportSignals> response = await client.EvaluateAsync<SupportSignals>(
"I have asked three times now. Can I speak to a real person?");
double? probability = response.Result.WantsHumanProbability;
Console.WriteLine($"Probability of yes: {probability}");
public sealed class SupportSignals
{
[JevNoulQuestion("Is the customer asking to speak with a person?")]
public double? WantsHumanProbability { get; set; }
}The result class needs a public parameterless constructor; declaring no constructor provides one here. The property can instead be decimal? if your application wants decimal arithmetic.
For a Boolean property, JevDotNet compares the returned probability to the threshold inclusively (probability >= threshold). The default threshold is 0.5:
public sealed class HumanEscalation
{
[JevNoulQuestion("Is the customer asking to speak with a person?")]
public bool? WantsHumanAtDefaultThreshold { get; set; }
[JevNoulQuestion("Is the customer asking to speak with a person?", threshold: 0.8)]
public bool? WantsHumanAtHighThreshold { get; set; }
}If the API returns 0.8, both properties become true. If it returns 0.7 to both questions, the first becomes true and the second false. Each property is a separate question ID, so you ordinarily choose one threshold for a question instead of asking it twice. The sample shows the conversion rule, not a recommended request layout.
Thresholds must be finite values from 0 through 1. A custom threshold on a double, decimal, or JevNoul property is rejected because those shapes keep the raw number. The threshold affects only local Boolean conversion; it is not sent to Jev as part of the question. Choose the threshold to fit the cost of a false yes versus a missed yes.
Use JevNoul? when you want the probability and may apply different thresholds later:
public sealed class DetailedSupportSignals
{
[JevNoulQuestion("Is the customer asking to speak with a person?")]
public JevNoul? WantsHuman { get; set; }
}Then evaluate it and read the detailed answer:
JevResponse<DetailedSupportSignals> detailedResponse =
await client.EvaluateAsync<DetailedSupportSignals>(
"I have asked three times now. Can I speak to a real person?");
JevNoul answer = detailedResponse.Result.WantsHuman
?? throw new InvalidOperationException("WantsHuman answer was missing.");
double probability = answer.Probability;
bool defaultDecision = answer.Value; // Probability >= 0.5
bool highThresholdDecision = answer.IsAtLeast(0.8);In this follow-on snippet, client is defined as in the preceding example. IsAtLeast also validates its threshold: non-finite numbers and values outside 0–1 throw ArgumentOutOfRangeException.
For an ambiguous boundary, use the optional True and False criteria on the attribute:
public sealed class RepeatContact
{
[JevNoulQuestion(
"Has the customer contacted support about this before?",
True = "Mentions a previous support attempt or ticket",
False = "Gives no indication of previous contact")]
public JevNoul? IsRepeatContact { get; set; }
}Supply both True and False, or neither. JevDotNet sends these as the API's criteria.true and criteria.false. Supplying only one causes validation to fail before the request. The current attribute accepts string criteria; the underlying API also supports richer instruction structures that this wrapper does not expose.
The IsRepeatContact property above produces a Noul question shaped like this (the surrounding request also contains model and state):
{
"questions": {
"IsRepeatContact": {
"type": "noul",
"instructions": "Has the customer contacted support about this before?",
"criteria": {
"true": "Mentions a previous support attempt or ticket",
"false": "Gives no indication of previous contact"
}
}
}
}An illustrative response entry for that question is:
{
"IsRepeatContact": {
"type": "noul",
"noul": 0.84
}
}Without True and False, the criteria field is omitted. JevDotNet reads the noul number from the matching answer and maps it to your chosen property shape. A wrong answer type or missing noul field causes a mapping error.
-
Treating Noul as intensity:
0.8means an 80% probability of yes, not “80% severe.” -
Using a custom threshold with a numeric or
JevNoulproperty: keep the raw probability and compare it in your code, or change the property tobool/bool?. -
Using
>instead of the library's>=rule: a probability exactly at the threshold maps totrue. -
Setting only
Trueor onlyFalse: the pair is required when defining criteria. -
Looking for
Confidence: Noul has one probability and no separate confidence field.
Build the full return object · Evaluate text and use results · TypeSafe Noul reference