Added an analyzer which keeps line breaks LF on every system (#1193)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-11 19:30:00 +01:00
1 parent b1c1f13993
commit 65d50de033
96 files changed
+741 -393

No files matched your search

@@ -138,8 +138,8 @@ public sealed class AugmentationOne : IAugmentationProcess
var sb = new StringBuilder();
if (selection.Contexts.Count > 0)
{
sb.AppendLine("The following useful information will help you in processing the user prompt:");
sb.AppendLine();
sb.AppendLineLF("The following useful information will help you in processing the user prompt:");
sb.AppendLineLF();
// Let's convert the retrieval contexts to Markdown:
for (var index = 0; index < selection.Contexts.Count; index++)
@@ -147,7 +147,7 @@ public sealed class AugmentationOne : IAugmentationProcess
}
if (selection.LeftOutCount > 0)
sb.AppendLine(selection.LeftOutCount is 1
sb.AppendLineLF(selection.LeftOutCount is 1
? "Of the passages which the search found in the data sources, 1 did not fit into this request and was left out. An answer based on the data sources may therefore be incomplete."
: $"Of the passages which the search found in the data sources, {selection.LeftOutCount} did not fit into this request and were left out. An answer based on the data sources may therefore be incomplete.");
@@ -29,20 +29,20 @@ public sealed record PreparedRetrievalContext(IRetrievalContext Context, string
switch (index)
{
case > 0 when numTotalRetrievalContexts is null:
sb.AppendLine($"# Retrieval context {index}");
sb.AppendLineLF($"# Retrieval context {index}");
break;
case > 0 when numTotalRetrievalContexts > 0:
sb.AppendLine($"# Retrieval context {index} of {numTotalRetrievalContexts}");
sb.AppendLineLF($"# Retrieval context {index} of {numTotalRetrievalContexts}");
break;
default:
sb.AppendLine("# Retrieval context");
sb.AppendLineLF("# Retrieval context");
break;
}
sb.Append(this.Body);
sb.AppendLine();
sb.AppendLineLF();
return sb.ToString();
}
}
@@ -330,7 +330,7 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess
var builder = new StringBuilder(augmentedData);
if (builder.Length > 0)
builder.AppendLine();
builder.AppendLineLF();
UnreachableDataSources.AppendTo(builder, unreachableDataSources);
return builder.ToString();
@@ -23,23 +23,23 @@ public static class RetrievalContextExtensions
/// <param name="retrievalContext">The context to describe.</param>
internal static void AppendContextDescription(StringBuilder contextBuilder, IRetrievalContext retrievalContext)
{
contextBuilder.AppendLine($"Data source name: {retrievalContext.DataSourceName}");
contextBuilder.AppendLine($"Content category: {retrievalContext.Category}");
contextBuilder.AppendLineLF($"Data source name: {retrievalContext.DataSourceName}");
contextBuilder.AppendLineLF($"Content category: {retrievalContext.Category}");
if(!string.IsNullOrWhiteSpace(retrievalContext.SourceCategory))
contextBuilder.AppendLine($"Source category: {retrievalContext.SourceCategory.ReplaceLineEndings(" ").Trim()}");
contextBuilder.AppendLineLF($"Source category: {retrievalContext.SourceCategory.ReplaceLineEndings(" ").Trim()}");
contextBuilder.AppendLine($"Content type: {retrievalContext.Type}");
contextBuilder.AppendLine($"Content path: {retrievalContext.Path}");
contextBuilder.AppendLineLF($"Content type: {retrievalContext.Type}");
contextBuilder.AppendLineLF($"Content path: {retrievalContext.Path}");
if(retrievalContext is RetrievalTextContext textContext && DescribeLocation(textContext.PageNumber, textContext.EndPageNumber, textContext.SheetName, textContext.StartRow, textContext.EndRow, textContext.StartLine, textContext.EndLine) is { } location)
contextBuilder.AppendLine($"Content location: {location}");
contextBuilder.AppendLineLF($"Content location: {location}");
if(retrievalContext.Links.Count is 0)
return;
contextBuilder.AppendLine("Additional links:");
contextBuilder.AppendLineLF("Additional links:");
foreach(var link in retrievalContext.Links)
contextBuilder.AppendLine($"- {link}");
contextBuilder.AppendLineLF($"- {link}");
}
/// <summary>
@@ -86,8 +86,8 @@ public static class RetrievalContextExtensions
/// <param name="contextBuilder">The builder to write into, after the description of the context.</param>
internal static void AppendImageMatch(StringBuilder contextBuilder)
{
contextBuilder.AppendLine();
contextBuilder.AppendLine("Matched image content: an image matched here, but it is not shown to you. Do not guess what it shows. When it matters for the answer, tell the user that an image matched, and where to find it, using the path and the links above.");
contextBuilder.AppendLineLF();
contextBuilder.AppendLineLF("Matched image content: an image matched here, but it is not shown to you. Do not guess what it shows. When it matters for the answer, tell the user that an image matched, and where to find it, using the path and the links above.");
}
/// <param name="retrievalContexts">The contexts to prepare.</param>
@@ -295,31 +295,31 @@ public static class RetrievalContextExtensions
/// <param name="surroundingContent">The surrounding content, filtered.</param>
private static void AppendTextMatch(StringBuilder contextBuilder, RetrievalTextContext textContext, string matchedText, IReadOnlyList<string> surroundingContent)
{
contextBuilder.AppendLine();
contextBuilder.AppendLine(textContext.IsMatchedTextShortened ? "Matched text content, shortened to fit the size limit:" : "Matched text content:");
contextBuilder.AppendLine("````");
contextBuilder.AppendLine(matchedText);
contextBuilder.AppendLine("````");
contextBuilder.AppendLineLF();
contextBuilder.AppendLineLF(textContext.IsMatchedTextShortened ? "Matched text content, shortened to fit the size limit:" : "Matched text content:");
contextBuilder.AppendLineLF("````");
contextBuilder.AppendLineLF(matchedText);
contextBuilder.AppendLineLF("````");
if (surroundingContent.Count is 0)
{
if (textContext.IsSurroundingContentShortened)
{
contextBuilder.AppendLine();
contextBuilder.AppendLine("Surrounding text content: left out to fit the size limit.");
contextBuilder.AppendLineLF();
contextBuilder.AppendLineLF("Surrounding text content: left out to fit the size limit.");
}
return;
}
contextBuilder.AppendLine();
contextBuilder.AppendLine(textContext.IsSurroundingContentShortened ? "Surrounding text content, shortened to fit the size limit:" : "Surrounding text content:");
contextBuilder.AppendLineLF();
contextBuilder.AppendLineLF(textContext.IsSurroundingContentShortened ? "Surrounding text content, shortened to fit the size limit:" : "Surrounding text content:");
foreach (var surrounding in surroundingContent)
{
contextBuilder.AppendLine();
contextBuilder.AppendLine("````");
contextBuilder.AppendLine(surrounding);
contextBuilder.AppendLine("````");
contextBuilder.AppendLineLF();
contextBuilder.AppendLineLF("````");
contextBuilder.AppendLineLF(surrounding);
contextBuilder.AppendLineLF("````");
}
}
@@ -26,8 +26,8 @@ public static class UnreachableDataSources
/// <param name="dataSources">The data sources whose server could not be reached, in the order to list them.</param>
public static void AppendTo(StringBuilder builder, IReadOnlyList<IDataSource> dataSources)
{
builder.AppendLine("These external data sources of this chat could not be reached or signed in to right now, so they cannot be searched. Their content is missing rather than empty; tell the user so when a question concerns them:");
builder.AppendLineLF("These external data sources of this chat could not be reached or signed in to right now, so they cannot be searched. Their content is missing rather than empty; tell the user so when a question concerns them:");
foreach (var dataSource in dataSources)
builder.AppendLine($"- name='{dataSource.Name}'");
builder.AppendLineLF($"- name='{dataSource.Name}'");
}
}