AI-Studio/app/MindWork AI Studio/Chat/StringExtension.cs

18 lines
567 B
C#
Raw Normal View History

2025-06-10 12:32:24 +00:00
namespace AIStudio.Chat;
public static class StringExtensions
{
public static string RemoveThinkTags(this string input)
{
const string OPEN_TAG = "<think>";
const string CLOSE_TAG = "</think>";
2025-06-11 08:20:49 +00:00
if (string.IsNullOrWhiteSpace(input) || !input.StartsWith(OPEN_TAG, StringComparison.Ordinal))
2025-06-10 12:32:24 +00:00
return input;
var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal);
if (endIndex == -1)
return string.Empty;
return input[(endIndex + CLOSE_TAG.Length)..];
}
}