Not able to parse DateTimeSpec value "the hour" while reading response from luis in bot app
See original GitHub issueAsk
May I know why “the hour” text could not be converted in DateTimeSpec type? Do I need to tweak something from my c# model side to allow it?
Package
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.12.0" />
Luis response JSON
{
"useralias": [
"abcd"
],
"number": [
2
],
"datetime": [
{
"timex": [
"(T14, T15,PT1H)"
],
"type": "timerange"
},
"the hour"
],
"personName": [
"Tony"
],
"$instance": {
"useralias": [
{
"type": "useralias",
"text": "abcd",
"startIndex": 0,
"endIndex": 10,
"modelType": "Entity Extractor",
"recognitionSources": [
"model"
]
}
],
"number": [
{
"type": "builtin.number",
"text": "2",
"startIndex": 31,
"endIndex": 32,
"modelType": "Prebuilt Entity Extractor",
"recognitionSources": [
"model"
]
}
],
"datetime": [
{
"type": "builtin.datetimeV2.timerange",
"text": "2 to 3pm",
"startIndex": 31,
"endIndex": 39,
"modelType": "Prebuilt Entity Extractor",
"recognitionSources": [
"model"
]
},
{
"type": "builtin.datetimeV2.duration",
"text": "the hour",
"startIndex": 99,
"endIndex": 107,
"modelType": "Prebuilt Entity Extractor",
"recognitionSources": [
"model"
]
}
],
"personName": [
{
"type": "builtin.personName",
"text": "Tony",
"startIndex": 59,
"endIndex": 65,
"modelType": "Prebuilt Entity Extractor",
"recognitionSources": [
"model"
]
}
]
}
}
Error
{"Error converting value \"the hour\" to type 'Microsoft.Bot.Builder.AI.Luis.DateTimeSpec'. Path 'entities.datetime[1]', line 1, position 362."}
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at Luis.GeneralLuis.Convert(Object result)
at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.<RecognizeAsync>d__26`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at OOFAssistant.Controllers.NotifyController.<PullAliasRecord>d__17.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at OOFAssistant.Controllers.NotifyController.<BotCallback>d__15.MoveNext()
Inner exception
Could not cast or convert from System.String to Microsoft.Bot.Builder.AI.Luis.DateTimeSpec.
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
Convert logic
public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<GeneralLuis>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
DatetimeV2 Prebuilt entities - LUIS - Azure AI services
The datetimeV2 prebuilt entity extracts date and time values. These values resolve in a standardized format for client programs to consume. When an...
Read more >Luis not returning the same details to bot
When I submit new utterances to the API, it only typically returns 1 of 2 intents and no entities. Ever. But when I...
Read more >Add natural language understanding to your bot - Bot Service
Learn how to use LUIS for natural language understanding in your bot.
Read more >Build a Doctor Appointment Bot with Azure Bot Service ...
When the bot receives a message, it asks Language Understanding (LUIS) to analyze the message. LUIS responds with the intent of the message, ......
Read more >Best practices
1. Best practices. Best practices when developing a Bot Framework Skill. Language understanding. Best practices. A key aspect of your ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue is solved in the new version of Recognizers. We are updating the .NET SDK to use these packages in PR #5992.
Thanks Dana for the update. The recognizers-text team has released new packages, and we are indeed waiting for LUIS (and the C# SDK) to pickup the latest packages. The SDK is planning to take these in R14, with @EricDahlvang having looked at them.