Skip to content

Commit

Permalink
Enable Summarization in Ingestion Client (#1777)
Browse files Browse the repository at this point in the history
* su

* imp

* arm

* test

* role

* role

* config

* fix new line

* len limit

* fix typo

* Update log to trigger build

* remove BOM

Co-authored-by: Yuantao Wang <[email protected]>
Co-authored-by: Henry van der Vegte <[email protected]>
  • Loading branch information
3 people authored Jan 11, 2023
1 parent ea5dbbd commit 4c62a54
Show file tree
Hide file tree
Showing 21 changed files with 557 additions and 65 deletions.
2 changes: 2 additions & 0 deletions samples/ingestion/ingestion-client/Connector/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ public static class Constants
public const int DefaultFilesPerTranscriptionJob = 100;

public const int DefaultConversationAnalysisMaxChunkSize = 5000;

public const string SummarizationSupportedLocalePrefix = "en";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ namespace Connector.Serializable.Language.Conversations
public class AnalyzeConversationSummarizationResults : AnalyzeConversationResultsBase
{
[JsonProperty("conversations")]
public IEnumerable<IssueResolutionSummary> Conversations { get; set; }
public IEnumerable<ConversationsSummaryResult> Conversations { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// <copyright file="Aspect.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector.Serializable.Language.Conversations
{
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Aspect
{
None = 0,
Issue = 1,
Resolution = 2,
ChapterTitle = 3,
Narrative = 4,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public class ConversationItem
[JsonProperty("maskedItn")]
public string MaskedItn { get; set; }

[JsonProperty("audioTimings")]
[JsonProperty("wordLevelTimings")]
public IEnumerable<WordLevelAudioTiming> AudioTimings { get; set; }

[JsonProperty("conversationItemLevelTiming")]
public AudioTiming ConversationItemLevelTiming { get; set; }

[JsonProperty("role")]
public string Role { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// <copyright file="ConversationSummarizationOptions.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector.Serializable.Language.Conversations
{
using System.Collections.Generic;

public class ConversationSummarizationOptions
{
public bool Enabled { get; init; }

public int InputLengthLimit { get; init; }

public RoleAssignmentStratergy Stratergy { get; init; }

public IEnumerable<Aspect> Aspects { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="IssueResolutionSummary.cs" company="Microsoft Corporation">
// <copyright file="ConversationsSummaryResult.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>
Expand All @@ -8,13 +8,13 @@ namespace Connector.Serializable.Language.Conversations
using System.Collections.Generic;
using Newtonsoft.Json;

public class IssueResolutionSummary
public class ConversationsSummaryResult
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }

[JsonProperty(PropertyName = "summaries")]
public IEnumerable<Summary> Summaries { get; set; }
public IEnumerable<SummaryResultItem> Summaries { get; set; }

[JsonProperty("warnings")]
public IEnumerable<Warning> Warnings { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// <copyright file="ItemizedSummaryContext.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector
{
using Newtonsoft.Json;

public class ItemizedSummaryContext
{
[JsonProperty(PropertyName = "conversationItemId")]
public string ConversationItemId { get; set; }

[JsonProperty(PropertyName = "offset")]
public int Offset { get; set; }

[JsonProperty(PropertyName = "length")]
public int Length { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <copyright file="Role.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector.Serializable.Language.Conversations
{
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Role
{
None = 0,
Agent = 1,
Customer = 2,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <copyright file="RoleAssignmentMappingKey.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector.Serializable.Language.Conversations
{
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum RoleAssignmentMappingKey
{
None = 0,
Channel = 1,
Speaker = 2,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <copyright file="RoleAssignmentStratergy.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector.Serializable.Language.Conversations
{
using System.Collections.Generic;

public class RoleAssignmentStratergy
{
public RoleAssignmentMappingKey Key { get; init; }

public Dictionary<int, Role> Mapping { get; init; }

public Role FallbackRole { get; init; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// <copyright file="SummaryResultItem.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>

namespace Connector
{
using System.Collections.Generic;

using Newtonsoft.Json;

public class SummaryResultItem
{
[JsonProperty("aspect")]
public string Aspect { get; set; }

[JsonProperty("text")]
public string Text { get; set; }

[JsonProperty("contexts")]
public IEnumerable<ItemizedSummaryContext> Contexts { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.AI.Language.Conversations" Version="1.1.0-beta.1" />
<PackageReference Include="Azure.AI.Language.Conversations" Version="1.1.0-beta.2" />
<PackageReference Include="Azure.AI.TextAnalytics" Version="5.1.1" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.8.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace FetchTranscriptionFunction
using Connector;
using Connector.Constants;
using Connector.Enums;
using Connector.Serializable.Language.Conversations;

public static class FetchTranscriptionEnvironmentVariables
{
Expand All @@ -26,6 +27,8 @@ public static class FetchTranscriptionEnvironmentVariables

public static readonly int ConversationPiiMaxChunkSize = int.TryParse(Environment.GetEnvironmentVariable(nameof(ConversationPiiMaxChunkSize), EnvironmentVariableTarget.Process), out ConversationPiiMaxChunkSize) ? ConversationPiiMaxChunkSize : Constants.DefaultConversationAnalysisMaxChunkSize;

public static readonly ConversationSummarizationOptions ConversationSummarizationOptions = System.Text.Json.JsonSerializer.Deserialize<ConversationSummarizationOptions>(Environment.GetEnvironmentVariable(nameof(ConversationSummarizationOptions), EnvironmentVariableTarget.Process));

public static readonly bool UseSqlDatabase = bool.TryParse(Environment.GetEnvironmentVariable(nameof(UseSqlDatabase), EnvironmentVariableTarget.Process), out UseSqlDatabase) && UseSqlDatabase;

public static readonly int InitialPollingDelayInMinutes = int.TryParse(Environment.GetEnvironmentVariable(nameof(InitialPollingDelayInMinutes), EnvironmentVariableTarget.Process), out InitialPollingDelayInMinutes) ? InitialPollingDelayInMinutes.ClampInt(2, Constants.MaxInitialPollingDelayInMinutes) : Constants.DefaultInitialPollingDelayInMinutes;
Expand Down
Loading

0 comments on commit 4c62a54

Please sign in to comment.