private static void AddCustomAnomalyDetectorSkill(ref Index index, ref Indexer indexer, ref Skillset skillset, AppConfig config) { var headers = new WebApiHttpHeaders(new Dictionary <string, string> { { "Content-Type", "application/json" } }); var anomalyFields = new List <Field> { new Field($"isAnomaly", DataType.Boolean), new Field($"isPositiveAnomaly", DataType.Boolean), new Field($"isNegativeAnomaly", DataType.Boolean), new Field($"expectedValue", DataType.Double), new Field($"upperMargin", DataType.Double), new Field($"lowerMargin", DataType.Double) }; index.Fields.Add(new Field("engineTemperatureAnalysis", DataType.Complex, anomalyFields)); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/engineTemperatureAnalysis", "engineTemperatureAnalysis").GetAwaiter().GetResult()); // Create the custom translate skill skillset.Skills.Add(new WebApiSkill { Description = "Custom Anomaly Detector skill", Context = "/document", Uri = $"{config.FunctionApp.Url}/api/DetectAnomalies?code={config.FunctionApp.DefaultHostKey}", HttpMethod = "POST", //HttpHeaders = new WebApiHttpHeaders(), // This is broken in the SDK, so handle by sending JSON directly to Rest API. BatchSize = 1, Inputs = new List <InputFieldMappingEntry> { new InputFieldMappingEntry("timestamp", "/document/timestamp"), new InputFieldMappingEntry("engineTemperature", "/document/engineTemperature") }, Outputs = new List <OutputFieldMappingEntry> { new OutputFieldMappingEntry("anomalyResult", "engineTemperatureAnalysis") } }); }
private static void AddCustomFormRecognizerSkill(ref Index index, ref Indexer indexer, ref Skillset skillset, AppConfig config, string modelId) { var headers = new WebApiHttpHeaders(new Dictionary <string, string> { { "Content-Type", "application/json" } }); index.Fields.Add(new Field($"formHeight", DataType.Int32)); index.Fields.Add(new Field($"formWidth", DataType.Int32)); index.Fields.Add(new Field($"formKeyValuePairs", DataType.Collection(DataType.String))); index.Fields.Add(new Field($"formColumns", DataType.Collection(DataType.String))); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/formHeight", "formHeight").GetAwaiter().GetResult()); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/formWidth", "formWidth").GetAwaiter().GetResult()); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/formKeyValuePairs", "formKeyValuePairs").GetAwaiter().GetResult()); indexer.OutputFieldMappings.Add(CognitiveSearchHelper.CreateFieldMapping($"/document/formColumns", "formColumns").GetAwaiter().GetResult()); // Create the custom translate skill skillset.Skills.Add(new WebApiSkill { Description = "Custom Form Recognizer skill", Context = "/document", Uri = $"{config.FunctionApp.Url}/api/AnalyzeForm?code={config.FunctionApp.DefaultHostKey}&modelId={modelId}", HttpMethod = "POST", //HttpHeaders = new WebApiHttpHeaders(), // This is broken in the SDK, so handle by sending JSON directly to Rest API. BatchSize = 1, Inputs = new List <InputFieldMappingEntry> { new InputFieldMappingEntry("contentType", "/document/fileContentType"), new InputFieldMappingEntry("storageUri", "/document/storageUri"), new InputFieldMappingEntry("storageSasToken", "/document/sasToken") }, Outputs = new List <OutputFieldMappingEntry> { new OutputFieldMappingEntry("formHeight", "formHeight"), new OutputFieldMappingEntry("formWidth", "formWidth"), new OutputFieldMappingEntry("formKeyValuePairs", "formKeyValuePairs"), new OutputFieldMappingEntry("formColumns", "formColumns"), } }); }