botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

C# - Paste as JSON for LUIS model from endpoint

Open warrenbuckley opened this issue 10 years ago • 1 comments

Hi as suggested by @dandriscoll to go with the WebClient approach & fetch the JSON & map it back to a POCO.

However when trying the same approach as shown in the BUILD demo/session or grabbing the JSON from the example query made from the LUIS portal and then doing a past special to generate a class I get the following error in VS15 Community Edition

screenshot 2016-04-01 19 59 02

And the JSON I was trying to paste special as a class is as follows:

{
  "query": "What time is it for Mikkel at 4 in the afternoon?",
  "intents": [
    {
      "intent": "TimeForUser",
      "score": 0.6357388,
      "actions": [
        {
          "triggered": true,
          "name": "TimeForUser",
          "parameters": [
            {
              "name": "User",
              "required": true,
              "value": [
                {
                  "entity": "mikkel",
                  "type": "User",
                  "score": 0.910984635
                }
              ]
            },
            {
              "name": "Time",
              "required": true,
              "value": [
                {
                  "entity": "4 in the afternoon",
                  "type": "builtin.datetime.time",
                  "resolution": {
                    "time": "T16"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "intent": "TimeForEveryone",
      "score": 0.223888189,
      "actions": [
        {
          "triggered": true,
          "name": "TimeForEveryone",
          "parameters": [
            {
              "name": "Time",
              "required": true,
              "value": [
                {
                  "entity": "4 in the afternoon",
                  "type": "builtin.datetime.time",
                  "resolution": {
                    "time": "T16"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "intent": "None",
      "score": 0.0346338227,
      "actions": null
    },
    {
      "intent": "RepeatLastTimeAsked",
      "score": 0.0171330366,
      "actions": null
    }
  ],
  "entities": [
    {
      "entity": "mikkel",
      "type": "User",
      "startIndex": 20,
      "endIndex": 25,
      "score": 0.910984635
    },
    {
      "entity": "4 in the afternoon",
      "type": "builtin.datetime.time",
      "startIndex": 30,
      "endIndex": 47,
      "resolution": {
        "time": "T16"
      }
    }
  ]
}

warrenbuckley avatar Apr 01 '16 19:04 warrenbuckley

I guess this is triggering a bug in paste special feature of Visual Studio. Try to paste the JSON below and it should generate the right classes. I manually changed null actions to empty array in your pasted JSON and Visual Studio started generating the code.


{
  "query": "What time is it for Mikkel at 4 in the afternoon?",
  "intents": [
    {
      "intent": "TimeForUser",
      "score": 0.6357388,
      "actions": [
        {
          "triggered": true,
          "name": "TimeForUser",
          "parameters": [
            {
              "name": "User",
              "required": true,
              "value": [
                {
                  "entity": "mikkel",
                  "type": "User",
                  "score": 0.910984635
                }
              ]
            },
            {
              "name": "Time",
              "required": true,
              "value": [
                {
                  "entity": "4 in the afternoon",
                  "type": "builtin.datetime.time",
                  "resolution": {
                    "time": "T16"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "intent": "TimeForEveryone",
      "score": 0.223888189,
      "actions": [
        {
          "triggered": true,
          "name": "TimeForEveryone",
          "parameters": [
            {
              "name": "Time",
              "required": true,
              "value": [
                {
                  "entity": "4 in the afternoon",
                  "type": "builtin.datetime.time",
                  "resolution": {
                    "time": "T16"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "intent": "None",
      "score": 0.0346338227,
      "actions": []
    },
    {
      "intent": "RepeatLastTimeAsked",
      "score": 0.0171330366,
      "actions": []
    }
  ],
  "entities": [
    {
      "entity": "mikkel",
      "type": "User",
      "startIndex": 20,
      "endIndex": 25,
      "score": 0.910984635
    },
    {
      "entity": "4 in the afternoon",
      "type": "builtin.datetime.time",
      "startIndex": 30,
      "endIndex": 47,
      "resolution": {
        "time": "T16"
      }
    }
  ]
} 

msft-shahins avatar Apr 01 '16 22:04 msft-shahins