Sarnendu De
Sarnendu De

Reputation: 31

Luis Error: An item with the same key has already been added

My Luis bot app was working fine when I tested in the 2nd week of March 2017. Testing includes -

1) using Luis end point start with "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/........." in browser and Luis.ai

2) using visual studio code where I provided the LuisDialog with LuisModel attribute having app id and subscription key.

When I today tried to test it again, it is working fine in browser and Luis.ai using luis end point but in NOT in visual studio.Please refer the screenshot. Every time it is giving "An item with the same key has already been added".

I checked the LUIS : An item with the same key has already been added but did not get answer.

enter image description here

I tried to integrate this luis bot app with Azure Bot service. Same error is there also -

"2017-03-12T12:27:17.657 Exception while executing function: Functions.messages. mscorlib: An item with the same key has already been added."

Please help.

Thanks,

Sarnendu

Upvotes: 1

Views: 1181

Answers (1)

Sarnendu De
Sarnendu De

Reputation: 31

I was keep trying to solve my issue for couple of days to run bot service in azure. Finally I am able to run. Mainly 2 issues were there -

  • One is wrong Luis API Host Name in Azure Portal
  • Another is wrong attribute in Intent.

Correcting the Luis API Host Name-

In Azure portal, I have updated the Luis API End Point to westus.api.cognitive.microsoft.com from api.projectoxford.ai.

Steps to follow - go to 'All Resources' and click on the bot. Now go to Setting Tab and click of Application Setting button. Please refer below screenshot.

Now update the LuisAPI end point key in yellow highlighted area as shown below- Updating Luis API Host Name

After updating this setting, my bot was not working and throwing same error.

Correcting the Wrong Attribute in Intent :

Later I checked LuisDialog.csx,
[LuisIntent("")] atrtibute was present in one of the Intents other than None Intent. Here [LuisIntent("")] was given in BookHoliday Intent.

Please refer below screenshot - Wrong attribute in Intent

Both [LuisIntent("")] and [LuisIntent("None")] can be used for None Intent. I removed [LuisIntent("")] from BookHoliday Intent, it works fine.

It was copy-paste error, I copied None intent and modified None to BookHoliday but did not removed the [LuisIntent("")].

"An item with the same key has already been added"- this issue may also be raised if &q appears more than 1 time in query string as part of Luis App Endpoint url.

Regarding code run issue in visual studio, it looks like VS was not updated. It works after updating.

Upvotes: 2

Related Questions