2
votes

I need to retrieve all the labeled utterances (aka examples) for a particular intent.

It appears the only call in the LUIS Authoring API to do this is GET review labeled examples:

/luis/api/v2.0/apps/:appId/versions/:versionId/examples?skip=0&take=500 /luis/api/v2.0/apps/:appId/versions/:versionId/examples?skip=500&take=500

This returns all utterances for all intents. I have 880 labeled utterances, and due to the verbose reply, it's a 2.5MB file. This makes it slow.

The LUIS web UI uses a filtered call: /luis/webapi/v2.0/apps/:appId/versions/0.1/models/:modelId/reviewLabels. The resulting file is usually 10-50kB. However, there is no documentation around this call (notice the webapi in the path rather than just api).

So: is there a supported method for retrieving a filtered list of utterances?

1
I dont think Microsoft has exposed API for that functionality. Alternatively you can export the Model and apply LINQ to filter out utterances based on intent. That is the only way IMHOKunal Mukherjee
@KunalMukherjee Exporting the model (i.e. https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/:appId/versions/:versionId/export) produces a much smaller file, but it doesn't provide any ids. Without ids, it's useless from a programmatic perspective.Chris McGrath
are you talking about version Id's???Kunal Mukherjee
@KunalMukherjee When you call /examples/, each example has a unique numeric ID. /export doesn't provide that.Chris McGrath
you can get all the /examples in batches of 500 from this Programmatic APIKunal Mukherjee

1 Answers

4
votes

is there a supported method for retrieving a filtered list of utterances?

AFAIK, I could't find an API for this from server side, after research I found that even the Luis Web UI doesn't use any filter provided by server, it just gets all the utterances from server side and create filter use js in the foreground.

Since you're stratified with the result using webapi for Luis Web UI, after testing, we can call this webapi exactly the same as calling api together with Ocp-Apim-Subscription-Key as head, for example we can code like this in C#:

try
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{SubscriptionKey}");
        var uri = "https://westus.api.cognitive.microsoft.com/luis/webapi/v2.0/apps/{appId}/versions/{versionNumber}/models/{modelId}/reviewLabels";
        var response = await client.GetAsync(uri);
        //TODO:
    }
}
catch (Exception e)
{
    Debug.WriteLine(e.Message);
}

There's no official document about this webapi, but we can try to use Postman to analyse the http requests.