Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit d6825be

Browse files
xieofxieryanisgrig
authored andcommitted
skill fixes (#2449)
* POI: align tests to code, update lu * Bing search: add locale to GetSearchResult, update lu
1 parent 3ba2d2b commit d6825be

File tree

7 files changed

+25
-32
lines changed

7 files changed

+25
-32
lines changed

skills/csharp/experimental/bingsearchskill/Deployment/Resources/LU/en/BingSearchSkill.lu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
- tell me about the {MovieTitle=jurassic park} movie
3131
- tell me about the movie {MovieTitle=gone with the wind}
3232
- what is {MovieTitle=jurassic park}
33-
- whats {MovieTitle=hello} about?
34-
- whats the move {MovieTitle=harry potter} about?
33+
- what's {MovieTitle=hello} about?
34+
- what's the move {MovieTitle=harry potter} about?
3535
- how is {MovieTitlePatten}
3636
- tell me about the {MovieTitlePatten} movie
3737
- what's {MovieTitlePatten} about?
38-
- whats the move {MovieTitlePatten} about?
39-
- whats {MovieTitlePatten} about
40-
- whats {MovieTitlePatten} about?
38+
- what's the move {MovieTitlePatten} about?
39+
- what's {MovieTitlePatten} about
40+
- what's {MovieTitlePatten} about?
4141
- tell me about the movie {MovieTitlePatten}
4242
- what's {MovieTitlePatten} about
4343

skills/csharp/experimental/bingsearchskill/Dialogs/SearchDialog.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private async Task<DialogTurnResult> ShowResult(WaterfallStepContext stepContext
7979
var bingSearchKey = Settings.BingSearchKey ?? throw new Exception("The BingSearchKey must be provided to use this dialog. Please provide this key in your Skill Configuration.");
8080
var bingAnswerSearchKey = Settings.BingAnswerSearchKey ?? throw new Exception("The BingSearchKey must be provided to use this dialog. Please provide this key in your Skill Configuration.");
8181
var client = new BingSearchClient(bingSearchKey, bingAnswerSearchKey);
82-
var entitiesResult = await client.GetSearchResult(state.SearchEntityName, state.SearchEntityType);
82+
// https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/cognitive-services/Labs/Answer-Search/overview.md
83+
var entitiesResult = await client.GetSearchResult(state.SearchEntityName, "en-us", state.SearchEntityType);
8384

8485
Activity prompt = null;
8586
if (entitiesResult != null && entitiesResult.Count > 0)

skills/csharp/experimental/bingsearchskill/Services/BingSearchClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ private async Task<Entities> GetEntitySearchResult(string query)
5454
}
5555
}
5656

57-
public async Task<List<SearchResultModel>> GetSearchResult(string query, SearchResultModel.EntityType queryType = SearchResultModel.EntityType.Unknown)
57+
public async Task<List<SearchResultModel>> GetSearchResult(string query, string locale, SearchResultModel.EntityType queryType = SearchResultModel.EntityType.Unknown)
5858
{
5959
var results = new List<SearchResultModel>();
60-
var answerSearchResult = await GetAnswerSearchResult(query);
60+
var answerSearchResult = await GetAnswerSearchResult(query, locale);
6161
if (answerSearchResult != null)
6262
{
6363
results.Add(answerSearchResult);
@@ -114,11 +114,11 @@ public async Task<List<SearchResultModel>> GetSearchResult(string query, SearchR
114114
}
115115
}
116116

117-
private async Task<SearchResultModel> GetAnswerSearchResult(string query)
117+
private async Task<SearchResultModel> GetAnswerSearchResult(string query, string locale)
118118
{
119119
var httpClient = new HttpClient();
120120
httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", _bingAnswerSearchKey);
121-
var responseString = await httpClient.GetStringAsync($"https://api.labs.cognitive.microsoft.com/answerSearch/v7.0/search?q={query}&mkt=en-us");
121+
var responseString = await httpClient.GetStringAsync($"https://api.labs.cognitive.microsoft.com/answerSearch/v7.0/search?q={query}&mkt={locale}");
122122
var responseJson = JToken.Parse(responseString);
123123
var factsJson = responseJson["facts"];
124124
if (factsJson != null)

skills/csharp/pointofinterestskill/Deployment/Resources/LU/zh/PointOfInterest.lu

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

skills/csharp/pointofinterestskill/Deployment/Resources/LU/zh/secondary/poi_navigation_get_directions.lu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
- 去 2 a {Keyword=融合餐厅}
147147
- 去 2 a {Keyword=车库}
148148
- {Address=吉布斯村} 地图我怎么才能去那里
149-
- {Keyword=来自地球的礼物} 上 {Address=} 在城里,请我怎么去那里
149+
- {Keyword=来自地球的礼物} 上 {Address=法院} 在城里,请我怎么去那里
150150
- {Keyword=哈德里安的墙} 在这里,请我怎么去那里
151151
- 让我们去一个 {Keyword=君主酒馆} 在 {Address=罗切斯特大道} 和 {Address=杰克逊法院}
152152
- 让我们去一个 {Keyword=帕内拉面包} 在 {Address=麦克基弗地方} 和 {Address=约翰逊街}

skills/csharp/tests/pointofinterestskill.tests/Flow/Fakes/MockServiceManager.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,18 @@ public MockServiceManager()
1313
mockClient = new HttpClient(new MockHttpClientHandlerGen().GetMockHttpClientHandler());
1414
}
1515

16-
public IGeoSpatialService InitMapsService(BotSettings services, string locale = "en-us")
16+
public IGeoSpatialService InitMapsService(BotSettings settings, string locale = "en-us")
1717
{
18-
services.Properties.TryGetValue("FoursquareClientId", out var clientId);
19-
services.Properties.TryGetValue("FoursquareClientSecret", out var clientSecret);
20-
21-
var clientIdStr = (string)clientId;
22-
var clientSecretStr = (string)clientSecret;
18+
var clientIdStr = settings.FoursquareClientId;
19+
var clientSecretStr = settings.FoursquareClientSecret;
2320

2421
if (clientIdStr != null && clientSecretStr != null)
2522
{
2623
return new FoursquareGeoSpatialService().InitClientAsync(clientIdStr, clientSecretStr, MockData.Radius, MockData.Limit, MockData.RouteLimit, MockData.Locale, mockClient).Result;
2724
}
2825
else
2926
{
30-
var key = GetAzureMapsKey(services);
27+
var key = GetAzureMapsKey(settings);
3128

3229
return new AzureMapsGeoSpatialService().InitKeyAsync(key, MockData.Radius, MockData.Limit, MockData.RouteLimit, locale, mockClient).Result;
3330
}
@@ -47,11 +44,9 @@ public IGeoSpatialService InitRoutingMapsService(BotSettings services, string lo
4744
return new AzureMapsGeoSpatialService().InitKeyAsync(key, MockData.Radius, MockData.Limit, MockData.RouteLimit, locale, mockClient).Result;
4845
}
4946

50-
protected string GetAzureMapsKey(BotSettings services)
47+
protected string GetAzureMapsKey(BotSettings settings)
5148
{
52-
services.Properties.TryGetValue("AzureMapsKey", out var key);
53-
54-
var keyStr = (string)key;
49+
var keyStr = settings.AzureMapsKey;
5550
if (string.IsNullOrWhiteSpace(keyStr))
5651
{
5752
throw new Exception("Could not get the required Azure Maps key. Please make sure your settings are correctly configured.");

skills/csharp/tests/pointofinterestskill.tests/Flow/PointOfInterestSkillTestBase.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ public override void Initialize()
3535
Services = new ServiceCollection();
3636
Services.AddSingleton(new BotSettings()
3737
{
38-
Properties = new Dictionary<string, string>()
39-
{
40-
{ "AzureMapsKey", MockData.Key }
41-
}
38+
AzureMapsKey = MockData.Key
4239
});
4340
Services.AddSingleton(new BotServices()
4441
{

0 commit comments

Comments
 (0)