Polish news and personal report phrasing
This commit is contained in:
@@ -2432,7 +2432,11 @@ public sealed class JiboInteractionService(
|
||||
cancellationToken);
|
||||
|
||||
if (snapshot?.Headlines.Count > 0)
|
||||
return BuildProviderNewsDecision(snapshot, preferredCategories, requestedHeadlineCount);
|
||||
return BuildProviderNewsDecision(
|
||||
snapshot,
|
||||
catalog,
|
||||
preferredCategories,
|
||||
requestedHeadlineCount);
|
||||
|
||||
var providerStatus = ResolveNewsProviderStatus(snapshot);
|
||||
var providerMessage = snapshot?.ProviderMessage;
|
||||
@@ -2522,6 +2526,7 @@ public sealed class JiboInteractionService(
|
||||
|
||||
private static JiboInteractionDecision BuildProviderNewsDecision(
|
||||
NewsBriefingSnapshot snapshot,
|
||||
JiboExperienceCatalog catalog,
|
||||
IReadOnlyList<string> preferredCategories,
|
||||
int requestedHeadlineCount)
|
||||
{
|
||||
@@ -2543,7 +2548,8 @@ public sealed class JiboInteractionService(
|
||||
|
||||
var leadIn = BuildNewsLeadIn(snapshot.SourceName, preferredCategories);
|
||||
var joinedHeadlines = string.Join(" ", headlines.Select(static headline => $"{headline.Title}."));
|
||||
var spokenBriefing = $"{leadIn} {joinedHeadlines}".Trim();
|
||||
var outroTemplate = ChooseShortestTemplate(catalog.NewsOutroReplies) ?? "And that's the news.";
|
||||
var spokenBriefing = $"{leadIn} {joinedHeadlines} {outroTemplate}".Trim();
|
||||
return BuildNewsDecision(
|
||||
spokenBriefing,
|
||||
snapshot.SourceName,
|
||||
|
||||
@@ -281,12 +281,24 @@ internal static class PersonalReportOrchestrator
|
||||
}
|
||||
|
||||
if (toggles.CalendarEnabled)
|
||||
reportSections.Add((await buildCalendarDecisionAsync(turn, cancellationToken)).ReplyText);
|
||||
{
|
||||
var calendarReply = (await buildCalendarDecisionAsync(turn, cancellationToken)).ReplyText;
|
||||
if (!string.IsNullOrWhiteSpace(calendarReply))
|
||||
{
|
||||
reportSections.Add(calendarReply);
|
||||
|
||||
var calendarOutro = ChooseShortestTemplate(catalog.CalendarOutroReplies);
|
||||
if (!string.IsNullOrWhiteSpace(calendarOutro))
|
||||
reportSections.Add(RenderPersonalReportTemplate(calendarOutro!, userName));
|
||||
}
|
||||
}
|
||||
|
||||
if (toggles.CommuteEnabled)
|
||||
{
|
||||
var commuteReply = (await buildCommuteDecisionAsync(turn, cancellationToken)).ReplyText;
|
||||
reportSections.Add(ChooseFirstSentence(commuteReply));
|
||||
var commuteSnippet = ChooseFirstSentence(commuteReply);
|
||||
if (!string.IsNullOrWhiteSpace(commuteSnippet))
|
||||
reportSections.Add(commuteSnippet);
|
||||
}
|
||||
|
||||
if (toggles.NewsEnabled)
|
||||
@@ -717,6 +729,25 @@ internal static class PersonalReportOrchestrator
|
||||
return string.IsNullOrWhiteSpace(firstSentence) ? value.Trim() : firstSentence;
|
||||
}
|
||||
|
||||
private static string ChooseFirstTwoSentences(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return string.Empty;
|
||||
|
||||
var segments = value
|
||||
.Split(['.', '!', '?'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.Take(2)
|
||||
.ToArray();
|
||||
|
||||
if (segments.Length == 0) return string.Empty;
|
||||
|
||||
var joined = string.Join(". ", segments);
|
||||
return value.TrimEnd().EndsWith(".", StringComparison.Ordinal) ||
|
||||
value.TrimEnd().EndsWith("!", StringComparison.Ordinal) ||
|
||||
value.TrimEnd().EndsWith("?", StringComparison.Ordinal)
|
||||
? $"{joined}."
|
||||
: joined;
|
||||
}
|
||||
|
||||
private static string? ChooseShortestTemplate(IEnumerable<string> templates)
|
||||
{
|
||||
var selected = templates
|
||||
|
||||
Reference in New Issue
Block a user