Skip to content

Commit

Permalink
Remove punctuation from generated session names
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhulen committed Dec 11, 2023
1 parent 6475d27 commit 5fe93a8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/dotnet/Core/Services/CoreService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FoundationaLLM.Common.Constants;
using System.Text.RegularExpressions;
using FoundationaLLM.Common.Constants;
using FoundationaLLM.Common.Interfaces;
using FoundationaLLM.Core.Interfaces;
using FoundationaLLM.Common.Models.Chat;
Expand Down Expand Up @@ -48,11 +49,9 @@ public CoreService(
/// <summary>
/// Returns list of chat session ids and names.
/// </summary>
public async Task<List<Session>> GetAllChatSessionsAsync()
{
return await _cosmosDbService.GetSessionsAsync(_sessionType, _callContext.CurrentUserIdentity?.UPN ??
throw new InvalidOperationException("Failed to retrieve the identity of the signed in user when retrieving chat sessions."));
}
public async Task<List<Session>> GetAllChatSessionsAsync() =>
await _cosmosDbService.GetSessionsAsync(_sessionType, _callContext.CurrentUserIdentity?.UPN ??
throw new InvalidOperationException("Failed to retrieve the identity of the signed in user when retrieving chat sessions."));

/// <summary>
/// Returns the chat messages related to an existing session.
Expand Down Expand Up @@ -167,6 +166,9 @@ public async Task<Completion> SummarizeChatSessionNameAsync(string? sessionId, s

var summary = await _gatekeeperAPIService.GetSummary(summaryRequest);

// Remove any punctuation from the summary.
summary = Regex.Replace(summary, @"[^\w\s]", string.Empty);

await RenameChatSessionAsync(sessionId, summary);

return new Completion { Text = summary };
Expand Down

0 comments on commit 5fe93a8

Please sign in to comment.