private static void AddCustomSummarizerSkill(ref Index index, ref Indexer indexer, ref Skillset skillset, FunctionAppConfig config) { var targetField = "summary"; var headers = new Dictionary <string, string> { { "Content-Type", "application/json" } }; index.Fields.Add(new Field(targetField, AnalyzerName.StandardLucene)); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/{targetField}", targetField).GetAwaiter().GetResult()); // Create the custom translate skill skillset.Skills.Add(new WebApiSkill { Description = "Custom summarization skill", Context = "/document", Uri = $"{config.Url}/api/Summarize?code={config.DefaultHostKey}", HttpMethod = "POST", //HttpHeaders = new WebApiHttpHeaders(headers), BatchSize = 1, Inputs = new List <InputFieldMappingEntry> { new InputFieldMappingEntry("text", "/document/textTranslated") }, Outputs = new List <OutputFieldMappingEntry> { new OutputFieldMappingEntry("summaryText", targetField) } }); }
private static void AddCustomTranslateSkill(ref Index index, ref Indexer indexer, ref Skillset skillset, FunctionAppConfig config) { var targetField = "textTranslated"; var headers = new Dictionary <string, string> { { "Content-Type", "application/json" } }; index.Fields.Add(new Field(targetField, AnalyzerName.StandardLucene)); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/{targetField}", targetField).GetAwaiter().GetResult()); // Create the custom translate skill skillset.Skills.Add(new WebApiSkill { Description = "Custom translator skill", Context = "/document", Uri = $"{config.Url}/api/Translate?code={config.DefaultHostKey}", HttpMethod = "POST", //HttpHeaders = new WebApiHttpHeaders(headers), BatchSize = 1, Inputs = new List <InputFieldMappingEntry> { new InputFieldMappingEntry("text", "/document/text"), new InputFieldMappingEntry("language", "/document/Language") }, Outputs = new List <OutputFieldMappingEntry> { new OutputFieldMappingEntry("text", targetField) } }); // Update all the other skills, except for the LanguageDetectionSkill, to use the new textTranslated field. foreach (var skill in skillset.Skills) { var type = skill.GetType(); var typeName = type.Name; if (typeName != "WebApiSkill" && typeName != "LanguageDetectionSkill") { foreach (var input in skill.Inputs) { if (input.Source == "/document/text") { input.Source = $"/document/{targetField}"; } } } } }